typescript 4.7.2 → 4.7.3

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
@@ -100,7 +100,7 @@ var ts;
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 = "4.7.2";
103
+ ts.version = "4.7.3";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -8389,7 +8389,7 @@ var ts;
8389
8389
  Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
8390
8390
  Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
8391
8391
  Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
8392
- Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."),
8392
+ resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`."),
8393
8393
  resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
8394
8394
  resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."),
8395
8395
  resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
@@ -8893,6 +8893,7 @@ var ts;
8893
8893
  Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8894
8894
  Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
8895
8895
  All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
8896
+ The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
8896
8897
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8897
8898
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8898
8899
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -9000,7 +9001,7 @@ var ts;
9000
9001
  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
9002
  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
9003
  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'."),
9004
+ 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'."),
9004
9005
  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."),
9005
9006
  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."),
9006
9007
  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}'."),
@@ -16018,6 +16019,8 @@ var ts;
16018
16019
  case 218 /* SyntaxKind.AwaitExpression */:
16019
16020
  case 231 /* SyntaxKind.MetaProperty */:
16020
16021
  return true;
16022
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
16023
+ return !ts.isHeritageClause(node.parent);
16021
16024
  case 161 /* SyntaxKind.QualifiedName */:
16022
16025
  while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
16023
16026
  node = node.parent;
@@ -16189,9 +16192,6 @@ var ts;
16189
16192
  }
16190
16193
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16191
16194
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16192
- if (node.kind === 203 /* SyntaxKind.BindingElement */) {
16193
- node = node.parent.parent;
16194
- }
16195
16195
  return ts.isVariableDeclaration(node) &&
16196
16196
  !!node.initializer &&
16197
16197
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20013,8 +20013,9 @@ var ts;
20013
20013
  */
20014
20014
  function isFileForcedToBeModuleByFormat(file) {
20015
20015
  // Excludes declaration files - they still require an explicit `export {}` or the like
20016
- // for back compat purposes.
20017
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20016
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20017
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20018
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]))) && !file.isDeclarationFile ? true : undefined;
20018
20019
  }
20019
20020
  function getSetExternalModuleIndicator(options) {
20020
20021
  // TODO: Should this callback be cached?
@@ -20022,7 +20023,7 @@ var ts;
20022
20023
  case ts.ModuleDetectionKind.Force:
20023
20024
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20024
20025
  return function (file) {
20025
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20026
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20026
20027
  };
20027
20028
  case ts.ModuleDetectionKind.Legacy:
20028
20029
  // Files are modules if they have imports, exports, or import.meta
@@ -20082,7 +20083,8 @@ var ts;
20082
20083
  }
20083
20084
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20084
20085
  function getEmitModuleDetectionKind(options) {
20085
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20086
+ return options.moduleDetection ||
20087
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20086
20088
  }
20087
20089
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20088
20090
  function hasJsonModuleEmitEnabled(options) {
@@ -29062,6 +29064,10 @@ var ts;
29062
29064
  return node.kind === 267 /* SyntaxKind.ImportClause */;
29063
29065
  }
29064
29066
  ts.isImportClause = isImportClause;
29067
+ function isImportTypeAssertionContainer(node) {
29068
+ return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */;
29069
+ }
29070
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29065
29071
  function isAssertClause(node) {
29066
29072
  return node.kind === 293 /* SyntaxKind.AssertClause */;
29067
29073
  }
@@ -42006,7 +42012,7 @@ var ts;
42006
42012
  }
42007
42013
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42008
42014
  return {
42009
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42015
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42010
42016
  flags: 1 /* WatchDirectoryFlags.Recursive */
42011
42017
  };
42012
42018
  }
@@ -43111,16 +43117,20 @@ var ts;
43111
43117
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43112
43118
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43113
43119
  }
43120
+ var jsOnlyExtensions = [Extensions.JavaScript];
43121
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43122
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43123
+ var tsconfigExtensions = [Extensions.TSConfig];
43114
43124
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43115
43125
  var containingDirectory = ts.getDirectoryPath(containingFile);
43116
43126
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43117
43127
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43118
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43128
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43129
+ if (compilerOptions.resolveJsonModule) {
43130
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43131
+ }
43132
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43119
43133
  }
43120
- var jsOnlyExtensions = [Extensions.JavaScript];
43121
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43122
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43123
- var tsconfigExtensions = [Extensions.TSConfig];
43124
43134
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43125
43135
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43126
43136
  }
@@ -43803,13 +43813,36 @@ var ts;
43803
43813
  }
43804
43814
  return toSearchResult(/*value*/ undefined);
43805
43815
  }
43816
+ /**
43817
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
43818
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
43819
+ */
43820
+ function comparePatternKeys(a, b) {
43821
+ var aPatternIndex = a.indexOf("*");
43822
+ var bPatternIndex = b.indexOf("*");
43823
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
43824
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
43825
+ if (baseLenA > baseLenB)
43826
+ return -1;
43827
+ if (baseLenB > baseLenA)
43828
+ return 1;
43829
+ if (aPatternIndex === -1)
43830
+ return 1;
43831
+ if (bPatternIndex === -1)
43832
+ return -1;
43833
+ if (a.length > b.length)
43834
+ return -1;
43835
+ if (b.length > a.length)
43836
+ return 1;
43837
+ return 0;
43838
+ }
43806
43839
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
43807
43840
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
43808
43841
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
43809
43842
  var target = lookupTable[moduleName];
43810
43843
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
43811
43844
  }
43812
- var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), function (a, b) { return a.length - b.length; });
43845
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
43813
43846
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
43814
43847
  var potentialTarget = expandingKeys_1[_i];
43815
43848
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -44128,8 +44161,8 @@ var ts;
44128
44161
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
44129
44162
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
44130
44163
  if (!pathAndExtension && packageInfo
44131
- && packageInfo.packageJsonContent.exports === undefined
44132
- && packageInfo.packageJsonContent.main === undefined
44164
+ // eslint-disable-next-line no-null/no-null
44165
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
44133
44166
  && state.features & NodeResolutionFeatures.EsmMode) {
44134
44167
  // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
44135
44168
  // a default `index.js` entrypoint if no `main` or `exports` are present
@@ -46905,12 +46938,14 @@ var ts;
46905
46938
  }
46906
46939
  }
46907
46940
  function setCommonJsModuleIndicator(node) {
46908
- if (file.externalModuleIndicator) {
46941
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
46909
46942
  return false;
46910
46943
  }
46911
46944
  if (!file.commonJsModuleIndicator) {
46912
46945
  file.commonJsModuleIndicator = node;
46913
- bindSourceFileAsExternalModule();
46946
+ if (!file.externalModuleIndicator) {
46947
+ bindSourceFileAsExternalModule();
46948
+ }
46914
46949
  }
46915
46950
  return true;
46916
46951
  }
@@ -47324,7 +47359,11 @@ var ts;
47324
47359
  checkStrictModeEvalOrArguments(node, node.name);
47325
47360
  }
47326
47361
  if (!ts.isBindingPattern(node.name)) {
47327
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
47362
+ var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent;
47363
+ if (ts.isInJSFile(node) &&
47364
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47365
+ !ts.getJSDocTypeTag(node) &&
47366
+ !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
47328
47367
  declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
47329
47368
  }
47330
47369
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50151,7 +50190,8 @@ var ts;
50151
50190
  && isAliasableOrJsExpression(node.parent.right)
50152
50191
  || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
50153
50192
  || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50154
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50193
+ || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50194
+ || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50155
50195
  }
50156
50196
  function isAliasableOrJsExpression(e) {
50157
50197
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50244,7 +50284,7 @@ var ts;
50244
50284
  return hasExportAssignmentSymbol(moduleSymbol);
50245
50285
  }
50246
50286
  // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker
50247
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50287
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50248
50288
  }
50249
50289
  function getTargetOfImportClause(node, dontResolveAlias) {
50250
50290
  var _a;
@@ -53359,6 +53399,7 @@ var ts;
53359
53399
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53360
53400
  }
53361
53401
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53402
+ var _a, _b, _c, _d;
53362
53403
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53363
53404
  var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
53364
53405
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53376,6 +53417,7 @@ var ts;
53376
53417
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53377
53418
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53378
53419
  ])));
53420
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53379
53421
  }
53380
53422
  }
53381
53423
  if (!specifier) {
@@ -53395,6 +53437,7 @@ var ts;
53395
53437
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53396
53438
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53397
53439
  ])));
53440
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53398
53441
  }
53399
53442
  }
53400
53443
  if (!assertion) {
@@ -58883,7 +58926,7 @@ var ts;
58883
58926
  var objectType;
58884
58927
  return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
58885
58928
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58886
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
58929
+ !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType);
58887
58930
  }
58888
58931
  /**
58889
58932
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -80634,8 +80677,11 @@ var ts;
80634
80677
  if (node.assertions) {
80635
80678
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
80636
80679
  if (override) {
80680
+ if (!ts.isNightly()) {
80681
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
80682
+ }
80637
80683
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
80638
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80684
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80639
80685
  }
80640
80686
  }
80641
80687
  }
@@ -82338,7 +82384,7 @@ var ts;
82338
82384
  }
82339
82385
  // For a commonjs `const x = require`, validate the alias and exit
82340
82386
  var symbol = getSymbolOfNode(node);
82341
- if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82387
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) {
82342
82388
  checkAliasSymbol(node);
82343
82389
  return;
82344
82390
  }
@@ -85006,10 +85052,10 @@ var ts;
85006
85052
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85007
85053
  if (validForTypeAssertions && override) {
85008
85054
  if (!ts.isNightly()) {
85009
- 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);
85055
+ 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);
85010
85056
  }
85011
85057
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85012
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85058
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85013
85059
  }
85014
85060
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85015
85061
  }
@@ -107861,7 +107907,8 @@ var ts;
107861
107907
  trackReferencedAmbientModule: trackReferencedAmbientModule,
107862
107908
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
107863
107909
  reportNonlocalAugmentation: reportNonlocalAugmentation,
107864
- reportNonSerializableProperty: reportNonSerializableProperty
107910
+ reportNonSerializableProperty: reportNonSerializableProperty,
107911
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
107865
107912
  };
107866
107913
  var errorNameNode;
107867
107914
  var errorFallbackNode;
@@ -107988,6 +108035,11 @@ var ts;
107988
108035
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
107989
108036
  }
107990
108037
  }
108038
+ function reportImportTypeNodeResolutionModeOverride() {
108039
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108040
+ context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
108041
+ }
108042
+ }
107991
108043
  function transformDeclarationsForJS(sourceFile, bundled) {
107992
108044
  var oldDiag = getSymbolAccessibilityDiagnostic;
107993
108045
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108438,7 +108490,7 @@ var ts;
108438
108490
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108439
108491
  if (mode !== undefined) {
108440
108492
  if (!ts.isNightly()) {
108441
- 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));
108493
+ 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));
108442
108494
  }
108443
108495
  return assertClause;
108444
108496
  }
@@ -115945,12 +115997,14 @@ var ts;
115945
115997
  }
115946
115998
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
115947
115999
  ;
115948
- /* @internal */
116000
+ /**
116001
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116002
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116003
+ */
115949
116004
  function getModeForFileReference(ref, containingFileMode) {
115950
116005
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
115951
116006
  }
115952
116007
  ts.getModeForFileReference = getModeForFileReference;
115953
- /* @internal */
115954
116008
  function getModeForResolutionAtIndex(file, index) {
115955
116009
  if (file.impliedNodeFormat === undefined)
115956
116010
  return undefined;
@@ -115971,7 +116025,15 @@ var ts;
115971
116025
  return false;
115972
116026
  }
115973
116027
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
115974
- /* @internal */
116028
+ /**
116029
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116030
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116031
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116032
+ * `moduleResolution` is `node16`+.
116033
+ * @param file The file the import or import-like reference is contained within
116034
+ * @param usage The module reference string
116035
+ * @returns The final resolution mode of the import
116036
+ */
115975
116037
  function getModeForUsageLocation(file, usage) {
115976
116038
  var _a, _b;
115977
116039
  if (file.impliedNodeFormat === undefined)
@@ -118205,7 +118267,7 @@ var ts;
118205
118267
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118206
118268
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118207
118269
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118208
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118270
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118209
118271
  }
118210
118272
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118211
118273
  }
@@ -123498,6 +123560,7 @@ var ts;
123498
123560
  }
123499
123561
  function reloadFileNamesFromConfigFile() {
123500
123562
  writeLog("Reloading new file names and options");
123563
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123501
123564
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123502
123565
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123503
123566
  hasChangedConfigFileParsingErrors = true;
@@ -136072,7 +136135,7 @@ var ts;
136072
136135
  ts.Debug.assert(parent.name === node);
136073
136136
  return true;
136074
136137
  case 203 /* SyntaxKind.BindingElement */:
136075
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136138
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136076
136139
  default:
136077
136140
  return false;
136078
136141
  }
@@ -137537,7 +137600,7 @@ var ts;
137537
137600
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
137538
137601
  if (ts.isInJSFile(referenceLocation)
137539
137602
  && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */
137540
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
137603
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
137541
137604
  referenceSymbol = referenceLocation.parent.symbol;
137542
137605
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
137543
137606
  // this case, just skip it, since the bound identifiers are not an alias of the import.
@@ -4720,6 +4720,7 @@ declare namespace ts {
4720
4720
  function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
4721
4721
  function isImportDeclaration(node: Node): node is ImportDeclaration;
4722
4722
  function isImportClause(node: Node): node is ImportClause;
4723
+ function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer;
4723
4724
  function isAssertClause(node: Node): node is AssertClause;
4724
4725
  function isAssertEntry(node: Node): node is AssertEntry;
4725
4726
  function isNamespaceImport(node: Node): node is NamespaceImport;
@@ -5098,6 +5099,31 @@ declare namespace ts {
5098
5099
  export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string;
5099
5100
  export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
5100
5101
  export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
5102
+ /**
5103
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
5104
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
5105
+ */
5106
+ export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5107
+ /**
5108
+ * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
5109
+ * defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm).
5110
+ * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
5111
+ * @param file File to fetch the resolution mode within
5112
+ * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations
5113
+ */
5114
+ export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5115
+ /**
5116
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
5117
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
5118
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
5119
+ * `moduleResolution` is `node16`+.
5120
+ * @param file The file the import or import-like reference is contained within
5121
+ * @param usage The module reference string
5122
+ * @returns The final resolution mode of the import
5123
+ */
5124
+ export function getModeForUsageLocation(file: {
5125
+ impliedNodeFormat?: SourceFile["impliedNodeFormat"];
5126
+ }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5101
5127
  export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
5102
5128
  /**
5103
5129
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the