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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = "4.7.2";
297
+ ts.version = "4.7.3";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8583,7 +8583,7 @@ var ts;
8583
8583
  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."),
8584
8584
  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"),
8585
8585
  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"),
8586
- 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`."),
8586
+ 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`."),
8587
8587
  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`."),
8588
8588
  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."),
8589
8589
  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."),
@@ -9087,6 +9087,7 @@ var ts;
9087
9087
  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."),
9088
9088
  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."),
9089
9089
  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."),
9090
+ 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'."),
9090
9091
  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}'."),
9091
9092
  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}'."),
9092
9093
  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}'."),
@@ -9194,7 +9195,7 @@ var ts;
9194
9195
  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}'."),
9195
9196
  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}'?"),
9196
9197
  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'."),
9197
- 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'."),
9198
+ 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'."),
9198
9199
  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."),
9199
9200
  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."),
9200
9201
  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}'."),
@@ -16212,6 +16213,8 @@ var ts;
16212
16213
  case 218 /* SyntaxKind.AwaitExpression */:
16213
16214
  case 231 /* SyntaxKind.MetaProperty */:
16214
16215
  return true;
16216
+ case 228 /* SyntaxKind.ExpressionWithTypeArguments */:
16217
+ return !ts.isHeritageClause(node.parent);
16215
16218
  case 161 /* SyntaxKind.QualifiedName */:
16216
16219
  while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) {
16217
16220
  node = node.parent;
@@ -16383,9 +16386,6 @@ var ts;
16383
16386
  }
16384
16387
  ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
16385
16388
  function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
16386
- if (node.kind === 203 /* SyntaxKind.BindingElement */) {
16387
- node = node.parent.parent;
16388
- }
16389
16389
  return ts.isVariableDeclaration(node) &&
16390
16390
  !!node.initializer &&
16391
16391
  isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
@@ -20207,8 +20207,9 @@ var ts;
20207
20207
  */
20208
20208
  function isFileForcedToBeModuleByFormat(file) {
20209
20209
  // Excludes declaration files - they still require an explicit `export {}` or the like
20210
- // for back compat purposes.
20211
- return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
20210
+ // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
20211
+ // that aren't esm-mode (meaning not in a `type: module` scope).
20212
+ return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]))) && !file.isDeclarationFile ? true : undefined;
20212
20213
  }
20213
20214
  function getSetExternalModuleIndicator(options) {
20214
20215
  // TODO: Should this callback be cached?
@@ -20216,7 +20217,7 @@ var ts;
20216
20217
  case ts.ModuleDetectionKind.Force:
20217
20218
  // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
20218
20219
  return function (file) {
20219
- file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
20220
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file) || !file.isDeclarationFile || undefined;
20220
20221
  };
20221
20222
  case ts.ModuleDetectionKind.Legacy:
20222
20223
  // Files are modules if they have imports, exports, or import.meta
@@ -20276,7 +20277,8 @@ var ts;
20276
20277
  }
20277
20278
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20278
20279
  function getEmitModuleDetectionKind(options) {
20279
- return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20280
+ return options.moduleDetection ||
20281
+ (getEmitModuleKind(options) === ts.ModuleKind.Node16 || getEmitModuleKind(options) === ts.ModuleKind.NodeNext ? ts.ModuleDetectionKind.Force : ts.ModuleDetectionKind.Auto);
20280
20282
  }
20281
20283
  ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
20282
20284
  function hasJsonModuleEmitEnabled(options) {
@@ -29256,6 +29258,10 @@ var ts;
29256
29258
  return node.kind === 267 /* SyntaxKind.ImportClause */;
29257
29259
  }
29258
29260
  ts.isImportClause = isImportClause;
29261
+ function isImportTypeAssertionContainer(node) {
29262
+ return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */;
29263
+ }
29264
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29259
29265
  function isAssertClause(node) {
29260
29266
  return node.kind === 293 /* SyntaxKind.AssertClause */;
29261
29267
  }
@@ -42200,7 +42206,7 @@ var ts;
42200
42206
  }
42201
42207
  if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
42202
42208
  return {
42203
- key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
42209
+ key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)),
42204
42210
  flags: 1 /* WatchDirectoryFlags.Recursive */
42205
42211
  };
42206
42212
  }
@@ -43305,16 +43311,20 @@ var ts;
43305
43311
  function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43306
43312
  return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.NodeNextDefault, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
43307
43313
  }
43314
+ var jsOnlyExtensions = [Extensions.JavaScript];
43315
+ var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43316
+ var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43317
+ var tsconfigExtensions = [Extensions.TSConfig];
43308
43318
  function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
43309
43319
  var containingDirectory = ts.getDirectoryPath(containingFile);
43310
43320
  // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
43311
43321
  var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
43312
- return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
43322
+ var extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions;
43323
+ if (compilerOptions.resolveJsonModule) {
43324
+ extensions = __spreadArray(__spreadArray([], extensions, true), [Extensions.Json], false);
43325
+ }
43326
+ return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference);
43313
43327
  }
43314
- var jsOnlyExtensions = [Extensions.JavaScript];
43315
- var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
43316
- var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
43317
- var tsconfigExtensions = [Extensions.TSConfig];
43318
43328
  function tryResolveJSModuleWorker(moduleName, initialDir, host) {
43319
43329
  return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
43320
43330
  }
@@ -43997,13 +44007,36 @@ var ts;
43997
44007
  }
43998
44008
  return toSearchResult(/*value*/ undefined);
43999
44009
  }
44010
+ /**
44011
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44012
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44013
+ */
44014
+ function comparePatternKeys(a, b) {
44015
+ var aPatternIndex = a.indexOf("*");
44016
+ var bPatternIndex = b.indexOf("*");
44017
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
44018
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
44019
+ if (baseLenA > baseLenB)
44020
+ return -1;
44021
+ if (baseLenB > baseLenA)
44022
+ return 1;
44023
+ if (aPatternIndex === -1)
44024
+ return 1;
44025
+ if (bPatternIndex === -1)
44026
+ return -1;
44027
+ if (a.length > b.length)
44028
+ return -1;
44029
+ if (b.length > a.length)
44030
+ return 1;
44031
+ return 0;
44032
+ }
44000
44033
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44001
44034
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44002
44035
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44003
44036
  var target = lookupTable[moduleName];
44004
44037
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
44005
44038
  }
44006
- 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; });
44039
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44007
44040
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
44008
44041
  var potentialTarget = expandingKeys_1[_i];
44009
44042
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -44322,8 +44355,8 @@ var ts;
44322
44355
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
44323
44356
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
44324
44357
  if (!pathAndExtension && packageInfo
44325
- && packageInfo.packageJsonContent.exports === undefined
44326
- && packageInfo.packageJsonContent.main === undefined
44358
+ // eslint-disable-next-line no-null/no-null
44359
+ && (packageInfo.packageJsonContent.exports === undefined || packageInfo.packageJsonContent.exports === null)
44327
44360
  && state.features & NodeResolutionFeatures.EsmMode) {
44328
44361
  // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume
44329
44362
  // a default `index.js` entrypoint if no `main` or `exports` are present
@@ -47099,12 +47132,14 @@ var ts;
47099
47132
  }
47100
47133
  }
47101
47134
  function setCommonJsModuleIndicator(node) {
47102
- if (file.externalModuleIndicator) {
47135
+ if (file.externalModuleIndicator && file.externalModuleIndicator !== true) {
47103
47136
  return false;
47104
47137
  }
47105
47138
  if (!file.commonJsModuleIndicator) {
47106
47139
  file.commonJsModuleIndicator = node;
47107
- bindSourceFileAsExternalModule();
47140
+ if (!file.externalModuleIndicator) {
47141
+ bindSourceFileAsExternalModule();
47142
+ }
47108
47143
  }
47109
47144
  return true;
47110
47145
  }
@@ -47518,7 +47553,11 @@ var ts;
47518
47553
  checkStrictModeEvalOrArguments(node, node.name);
47519
47554
  }
47520
47555
  if (!ts.isBindingPattern(node.name)) {
47521
- if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node) && !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
47556
+ var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent;
47557
+ if (ts.isInJSFile(node) &&
47558
+ ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) &&
47559
+ !ts.getJSDocTypeTag(node) &&
47560
+ !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) {
47522
47561
  declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */);
47523
47562
  }
47524
47563
  else if (ts.isBlockOrCatchScoped(node)) {
@@ -50345,7 +50384,8 @@ var ts;
50345
50384
  && isAliasableOrJsExpression(node.parent.right)
50346
50385
  || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */
50347
50386
  || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
50348
- || ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
50387
+ || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)
50388
+ || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent);
50349
50389
  }
50350
50390
  function isAliasableOrJsExpression(e) {
50351
50391
  return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
@@ -50438,7 +50478,7 @@ var ts;
50438
50478
  return hasExportAssignmentSymbol(moduleSymbol);
50439
50479
  }
50440
50480
  // 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
50441
- return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50481
+ return typeof file.externalModuleIndicator !== "object" && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias);
50442
50482
  }
50443
50483
  function getTargetOfImportClause(node, dontResolveAlias) {
50444
50484
  var _a;
@@ -53553,6 +53593,7 @@ var ts;
53553
53593
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53554
53594
  }
53555
53595
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53596
+ var _a, _b, _c, _d;
53556
53597
  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
53557
53598
  var isTypeOf = meaning === 111551 /* SymbolFlags.Value */;
53558
53599
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53570,6 +53611,7 @@ var ts;
53570
53611
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53571
53612
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53572
53613
  ])));
53614
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53573
53615
  }
53574
53616
  }
53575
53617
  if (!specifier) {
@@ -53589,6 +53631,7 @@ var ts;
53589
53631
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53590
53632
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53591
53633
  ])));
53634
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53592
53635
  }
53593
53636
  }
53594
53637
  if (!assertion) {
@@ -59077,7 +59120,7 @@ var ts;
59077
59120
  var objectType;
59078
59121
  return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ &&
59079
59122
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
59080
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
59123
+ !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType);
59081
59124
  }
59082
59125
  /**
59083
59126
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -80828,8 +80871,11 @@ var ts;
80828
80871
  if (node.assertions) {
80829
80872
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
80830
80873
  if (override) {
80874
+ if (!ts.isNightly()) {
80875
+ 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);
80876
+ }
80831
80877
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
80832
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80878
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80833
80879
  }
80834
80880
  }
80835
80881
  }
@@ -82532,7 +82578,7 @@ var ts;
82532
82578
  }
82533
82579
  // For a commonjs `const x = require`, validate the alias and exit
82534
82580
  var symbol = getSymbolOfNode(node);
82535
- if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
82581
+ if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) {
82536
82582
  checkAliasSymbol(node);
82537
82583
  return;
82538
82584
  }
@@ -85200,10 +85246,10 @@ var ts;
85200
85246
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85201
85247
  if (validForTypeAssertions && override) {
85202
85248
  if (!ts.isNightly()) {
85203
- 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);
85249
+ 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);
85204
85250
  }
85205
85251
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85206
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85252
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85207
85253
  }
85208
85254
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85209
85255
  }
@@ -108055,7 +108101,8 @@ var ts;
108055
108101
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108056
108102
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108057
108103
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108058
- reportNonSerializableProperty: reportNonSerializableProperty
108104
+ reportNonSerializableProperty: reportNonSerializableProperty,
108105
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108059
108106
  };
108060
108107
  var errorNameNode;
108061
108108
  var errorFallbackNode;
@@ -108182,6 +108229,11 @@ var ts;
108182
108229
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108183
108230
  }
108184
108231
  }
108232
+ function reportImportTypeNodeResolutionModeOverride() {
108233
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108234
+ 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));
108235
+ }
108236
+ }
108185
108237
  function transformDeclarationsForJS(sourceFile, bundled) {
108186
108238
  var oldDiag = getSymbolAccessibilityDiagnostic;
108187
108239
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108632,7 +108684,7 @@ var ts;
108632
108684
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108633
108685
  if (mode !== undefined) {
108634
108686
  if (!ts.isNightly()) {
108635
- 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));
108687
+ 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));
108636
108688
  }
108637
108689
  return assertClause;
108638
108690
  }
@@ -116139,12 +116191,14 @@ var ts;
116139
116191
  }
116140
116192
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116141
116193
  ;
116142
- /* @internal */
116194
+ /**
116195
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116196
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116197
+ */
116143
116198
  function getModeForFileReference(ref, containingFileMode) {
116144
116199
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116145
116200
  }
116146
116201
  ts.getModeForFileReference = getModeForFileReference;
116147
- /* @internal */
116148
116202
  function getModeForResolutionAtIndex(file, index) {
116149
116203
  if (file.impliedNodeFormat === undefined)
116150
116204
  return undefined;
@@ -116165,7 +116219,15 @@ var ts;
116165
116219
  return false;
116166
116220
  }
116167
116221
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116168
- /* @internal */
116222
+ /**
116223
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116224
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116225
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116226
+ * `moduleResolution` is `node16`+.
116227
+ * @param file The file the import or import-like reference is contained within
116228
+ * @param usage The module reference string
116229
+ * @returns The final resolution mode of the import
116230
+ */
116169
116231
  function getModeForUsageLocation(file, usage) {
116170
116232
  var _a, _b;
116171
116233
  if (file.impliedNodeFormat === undefined)
@@ -118399,7 +118461,7 @@ var ts;
118399
118461
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118400
118462
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118401
118463
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118402
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118464
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118403
118465
  }
118404
118466
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118405
118467
  }
@@ -123692,6 +123754,7 @@ var ts;
123692
123754
  }
123693
123755
  function reloadFileNamesFromConfigFile() {
123694
123756
  writeLog("Reloading new file names and options");
123757
+ reloadLevel = ts.ConfigFileProgramReloadLevel.None;
123695
123758
  rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
123696
123759
  if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
123697
123760
  hasChangedConfigFileParsingErrors = true;
@@ -136683,7 +136746,7 @@ var ts;
136683
136746
  ts.Debug.assert(parent.name === node);
136684
136747
  return true;
136685
136748
  case 203 /* SyntaxKind.BindingElement */:
136686
- return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
136749
+ return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent);
136687
136750
  default:
136688
136751
  return false;
136689
136752
  }
@@ -138148,7 +138211,7 @@ var ts;
138148
138211
  // Use the parent symbol if the location is commonjs require syntax on javascript files only.
138149
138212
  if (ts.isInJSFile(referenceLocation)
138150
138213
  && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */
138151
- && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
138214
+ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) {
138152
138215
  referenceSymbol = referenceLocation.parent.symbol;
138153
138216
  // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
138154
138217
  // 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