typescript 4.8.0-dev.20220602 → 4.8.0-dev.20220603

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 = ts.versionMajorMinor + ".0-dev.20220602";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220603";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8396,6 +8396,7 @@ var ts;
8396
8396
  Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
8397
8397
  Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
8398
8398
  _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."),
8399
+ Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0: diag(1209, ts.DiagnosticCategory.Error, "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209", "Invalid optional chain from new expression. Did you mean to call '{0}()'?"),
8399
8400
  Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, ts.DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."),
8400
8401
  A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
8401
8402
  Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -8592,7 +8593,7 @@ var ts;
8592
8593
  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."),
8593
8594
  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"),
8594
8595
  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"),
8595
- 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`."),
8596
+ 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`."),
8596
8597
  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`."),
8597
8598
  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."),
8598
8599
  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."),
@@ -9100,6 +9101,7 @@ var ts;
9100
9101
  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."),
9101
9102
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
9102
9103
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
9104
+ 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'."),
9103
9105
  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}'."),
9104
9106
  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}'."),
9105
9107
  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}'."),
@@ -9207,7 +9209,7 @@ var ts;
9207
9209
  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}'."),
9208
9210
  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}'?"),
9209
9211
  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'."),
9210
- 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'."),
9212
+ 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'."),
9211
9213
  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."),
9212
9214
  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."),
9213
9215
  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}'."),
@@ -16248,6 +16250,8 @@ var ts;
16248
16250
  case 218 /* AwaitExpression */:
16249
16251
  case 231 /* MetaProperty */:
16250
16252
  return true;
16253
+ case 228 /* ExpressionWithTypeArguments */:
16254
+ return !ts.isHeritageClause(node.parent);
16251
16255
  case 161 /* QualifiedName */:
16252
16256
  while (node.parent.kind === 161 /* QualifiedName */) {
16253
16257
  node = node.parent;
@@ -29281,6 +29285,10 @@ var ts;
29281
29285
  return node.kind === 267 /* ImportClause */;
29282
29286
  }
29283
29287
  ts.isImportClause = isImportClause;
29288
+ function isImportTypeAssertionContainer(node) {
29289
+ return node.kind === 295 /* ImportTypeAssertionContainer */;
29290
+ }
29291
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29284
29292
  function isAssertClause(node) {
29285
29293
  return node.kind === 293 /* AssertClause */;
29286
29294
  }
@@ -35853,6 +35861,9 @@ var ts;
35853
35861
  typeArguments = expression.typeArguments;
35854
35862
  expression = expression.expression;
35855
35863
  }
35864
+ if (token() === 28 /* QuestionDotToken */) {
35865
+ parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression));
35866
+ }
35856
35867
  var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35857
35868
  return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35858
35869
  }
@@ -44044,13 +44055,36 @@ var ts;
44044
44055
  }
44045
44056
  return toSearchResult(/*value*/ undefined);
44046
44057
  }
44058
+ /**
44059
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44060
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44061
+ */
44062
+ function comparePatternKeys(a, b) {
44063
+ var aPatternIndex = a.indexOf("*");
44064
+ var bPatternIndex = b.indexOf("*");
44065
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
44066
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
44067
+ if (baseLenA > baseLenB)
44068
+ return -1;
44069
+ if (baseLenB > baseLenA)
44070
+ return 1;
44071
+ if (aPatternIndex === -1)
44072
+ return 1;
44073
+ if (bPatternIndex === -1)
44074
+ return -1;
44075
+ if (a.length > b.length)
44076
+ return -1;
44077
+ if (b.length > a.length)
44078
+ return 1;
44079
+ return 0;
44080
+ }
44047
44081
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44048
44082
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44049
44083
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44050
44084
  var target = lookupTable[moduleName];
44051
44085
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
44052
44086
  }
44053
- 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; });
44087
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44054
44088
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
44055
44089
  var potentialTarget = expandingKeys_1[_i];
44056
44090
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -53629,6 +53663,7 @@ var ts;
53629
53663
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53630
53664
  }
53631
53665
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53666
+ var _a, _b, _c, _d;
53632
53667
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53633
53668
  var isTypeOf = meaning === 111551 /* Value */;
53634
53669
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53646,6 +53681,7 @@ var ts;
53646
53681
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53647
53682
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53648
53683
  ])));
53684
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53649
53685
  }
53650
53686
  }
53651
53687
  if (!specifier) {
@@ -53665,6 +53701,7 @@ var ts;
53665
53701
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53666
53702
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53667
53703
  ])));
53704
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53668
53705
  }
53669
53706
  }
53670
53707
  if (!assertion) {
@@ -81074,8 +81111,11 @@ var ts;
81074
81111
  if (node.assertions) {
81075
81112
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
81076
81113
  if (override) {
81114
+ if (!ts.isNightly()) {
81115
+ 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);
81116
+ }
81077
81117
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
81078
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81118
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81079
81119
  }
81080
81120
  }
81081
81121
  }
@@ -85481,10 +85521,10 @@ var ts;
85481
85521
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85482
85522
  if (validForTypeAssertions && override) {
85483
85523
  if (!ts.isNightly()) {
85484
- 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);
85524
+ 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);
85485
85525
  }
85486
85526
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85487
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85527
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85488
85528
  }
85489
85529
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85490
85530
  }
@@ -108343,7 +108383,8 @@ var ts;
108343
108383
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108344
108384
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108345
108385
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108346
- reportNonSerializableProperty: reportNonSerializableProperty
108386
+ reportNonSerializableProperty: reportNonSerializableProperty,
108387
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108347
108388
  };
108348
108389
  var errorNameNode;
108349
108390
  var errorFallbackNode;
@@ -108470,6 +108511,11 @@ var ts;
108470
108511
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108471
108512
  }
108472
108513
  }
108514
+ function reportImportTypeNodeResolutionModeOverride() {
108515
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108516
+ 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));
108517
+ }
108518
+ }
108473
108519
  function transformDeclarationsForJS(sourceFile, bundled) {
108474
108520
  var oldDiag = getSymbolAccessibilityDiagnostic;
108475
108521
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108920,7 +108966,7 @@ var ts;
108920
108966
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108921
108967
  if (mode !== undefined) {
108922
108968
  if (!ts.isNightly()) {
108923
- 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));
108969
+ 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));
108924
108970
  }
108925
108971
  return assertClause;
108926
108972
  }
@@ -116429,12 +116475,14 @@ var ts;
116429
116475
  }
116430
116476
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116431
116477
  ;
116432
- /* @internal */
116478
+ /**
116479
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116480
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116481
+ */
116433
116482
  function getModeForFileReference(ref, containingFileMode) {
116434
116483
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116435
116484
  }
116436
116485
  ts.getModeForFileReference = getModeForFileReference;
116437
- /* @internal */
116438
116486
  function getModeForResolutionAtIndex(file, index) {
116439
116487
  if (file.impliedNodeFormat === undefined)
116440
116488
  return undefined;
@@ -116455,7 +116503,15 @@ var ts;
116455
116503
  return false;
116456
116504
  }
116457
116505
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116458
- /* @internal */
116506
+ /**
116507
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116508
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116509
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116510
+ * `moduleResolution` is `node16`+.
116511
+ * @param file The file the import or import-like reference is contained within
116512
+ * @param usage The module reference string
116513
+ * @returns The final resolution mode of the import
116514
+ */
116459
116515
  function getModeForUsageLocation(file, usage) {
116460
116516
  var _a, _b;
116461
116517
  if (file.impliedNodeFormat === undefined)
@@ -118691,7 +118747,7 @@ var ts;
118691
118747
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118692
118748
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118693
118749
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118694
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118750
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118695
118751
  }
118696
118752
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118697
118753
  }
@@ -4724,6 +4724,7 @@ declare namespace ts {
4724
4724
  function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
4725
4725
  function isImportDeclaration(node: Node): node is ImportDeclaration;
4726
4726
  function isImportClause(node: Node): node is ImportClause;
4727
+ function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer;
4727
4728
  function isAssertClause(node: Node): node is AssertClause;
4728
4729
  function isAssertEntry(node: Node): node is AssertEntry;
4729
4730
  function isNamespaceImport(node: Node): node is NamespaceImport;
@@ -5102,6 +5103,31 @@ declare namespace ts {
5102
5103
  export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string;
5103
5104
  export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
5104
5105
  export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
5106
+ /**
5107
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
5108
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
5109
+ */
5110
+ export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5111
+ /**
5112
+ * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
5113
+ * 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).
5114
+ * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
5115
+ * @param file File to fetch the resolution mode within
5116
+ * @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
5117
+ */
5118
+ export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5119
+ /**
5120
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
5121
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
5122
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
5123
+ * `moduleResolution` is `node16`+.
5124
+ * @param file The file the import or import-like reference is contained within
5125
+ * @param usage The module reference string
5126
+ * @returns The final resolution mode of the import
5127
+ */
5128
+ export function getModeForUsageLocation(file: {
5129
+ impliedNodeFormat?: SourceFile["impliedNodeFormat"];
5130
+ }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5105
5131
  export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
5106
5132
  /**
5107
5133
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
package/lib/typescript.js CHANGED
@@ -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 = ts.versionMajorMinor + ".0-dev.20220602";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220603";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -8396,6 +8396,7 @@ var ts;
8396
8396
  Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
8397
8397
  Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
8398
8398
  _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."),
8399
+ Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0: diag(1209, ts.DiagnosticCategory.Error, "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209", "Invalid optional chain from new expression. Did you mean to call '{0}()'?"),
8399
8400
  Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, ts.DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."),
8400
8401
  A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
8401
8402
  Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -8592,7 +8593,7 @@ var ts;
8592
8593
  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."),
8593
8594
  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"),
8594
8595
  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"),
8595
- 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`."),
8596
+ 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`."),
8596
8597
  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`."),
8597
8598
  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."),
8598
8599
  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."),
@@ -9100,6 +9101,7 @@ var ts;
9100
9101
  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."),
9101
9102
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
9102
9103
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
9104
+ 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'."),
9103
9105
  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}'."),
9104
9106
  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}'."),
9105
9107
  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}'."),
@@ -9207,7 +9209,7 @@ var ts;
9207
9209
  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}'."),
9208
9210
  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}'?"),
9209
9211
  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'."),
9210
- 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'."),
9212
+ 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'."),
9211
9213
  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."),
9212
9214
  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."),
9213
9215
  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}'."),
@@ -16248,6 +16250,8 @@ var ts;
16248
16250
  case 218 /* AwaitExpression */:
16249
16251
  case 231 /* MetaProperty */:
16250
16252
  return true;
16253
+ case 228 /* ExpressionWithTypeArguments */:
16254
+ return !ts.isHeritageClause(node.parent);
16251
16255
  case 161 /* QualifiedName */:
16252
16256
  while (node.parent.kind === 161 /* QualifiedName */) {
16253
16257
  node = node.parent;
@@ -29281,6 +29285,10 @@ var ts;
29281
29285
  return node.kind === 267 /* ImportClause */;
29282
29286
  }
29283
29287
  ts.isImportClause = isImportClause;
29288
+ function isImportTypeAssertionContainer(node) {
29289
+ return node.kind === 295 /* ImportTypeAssertionContainer */;
29290
+ }
29291
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29284
29292
  function isAssertClause(node) {
29285
29293
  return node.kind === 293 /* AssertClause */;
29286
29294
  }
@@ -35853,6 +35861,9 @@ var ts;
35853
35861
  typeArguments = expression.typeArguments;
35854
35862
  expression = expression.expression;
35855
35863
  }
35864
+ if (token() === 28 /* QuestionDotToken */) {
35865
+ parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression));
35866
+ }
35856
35867
  var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35857
35868
  return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35858
35869
  }
@@ -44044,13 +44055,36 @@ var ts;
44044
44055
  }
44045
44056
  return toSearchResult(/*value*/ undefined);
44046
44057
  }
44058
+ /**
44059
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44060
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44061
+ */
44062
+ function comparePatternKeys(a, b) {
44063
+ var aPatternIndex = a.indexOf("*");
44064
+ var bPatternIndex = b.indexOf("*");
44065
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
44066
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
44067
+ if (baseLenA > baseLenB)
44068
+ return -1;
44069
+ if (baseLenB > baseLenA)
44070
+ return 1;
44071
+ if (aPatternIndex === -1)
44072
+ return 1;
44073
+ if (bPatternIndex === -1)
44074
+ return -1;
44075
+ if (a.length > b.length)
44076
+ return -1;
44077
+ if (b.length > a.length)
44078
+ return 1;
44079
+ return 0;
44080
+ }
44047
44081
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44048
44082
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44049
44083
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44050
44084
  var target = lookupTable[moduleName];
44051
44085
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
44052
44086
  }
44053
- 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; });
44087
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44054
44088
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
44055
44089
  var potentialTarget = expandingKeys_1[_i];
44056
44090
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -53629,6 +53663,7 @@ var ts;
53629
53663
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53630
53664
  }
53631
53665
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53666
+ var _a, _b, _c, _d;
53632
53667
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53633
53668
  var isTypeOf = meaning === 111551 /* Value */;
53634
53669
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53646,6 +53681,7 @@ var ts;
53646
53681
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53647
53682
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53648
53683
  ])));
53684
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53649
53685
  }
53650
53686
  }
53651
53687
  if (!specifier) {
@@ -53665,6 +53701,7 @@ var ts;
53665
53701
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53666
53702
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53667
53703
  ])));
53704
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53668
53705
  }
53669
53706
  }
53670
53707
  if (!assertion) {
@@ -81074,8 +81111,11 @@ var ts;
81074
81111
  if (node.assertions) {
81075
81112
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
81076
81113
  if (override) {
81114
+ if (!ts.isNightly()) {
81115
+ 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);
81116
+ }
81077
81117
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
81078
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81118
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81079
81119
  }
81080
81120
  }
81081
81121
  }
@@ -85481,10 +85521,10 @@ var ts;
85481
85521
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85482
85522
  if (validForTypeAssertions && override) {
85483
85523
  if (!ts.isNightly()) {
85484
- 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);
85524
+ 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);
85485
85525
  }
85486
85526
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85487
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85527
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85488
85528
  }
85489
85529
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85490
85530
  }
@@ -108343,7 +108383,8 @@ var ts;
108343
108383
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108344
108384
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108345
108385
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108346
- reportNonSerializableProperty: reportNonSerializableProperty
108386
+ reportNonSerializableProperty: reportNonSerializableProperty,
108387
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108347
108388
  };
108348
108389
  var errorNameNode;
108349
108390
  var errorFallbackNode;
@@ -108470,6 +108511,11 @@ var ts;
108470
108511
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108471
108512
  }
108472
108513
  }
108514
+ function reportImportTypeNodeResolutionModeOverride() {
108515
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108516
+ 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));
108517
+ }
108518
+ }
108473
108519
  function transformDeclarationsForJS(sourceFile, bundled) {
108474
108520
  var oldDiag = getSymbolAccessibilityDiagnostic;
108475
108521
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108920,7 +108966,7 @@ var ts;
108920
108966
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108921
108967
  if (mode !== undefined) {
108922
108968
  if (!ts.isNightly()) {
108923
- 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));
108969
+ 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));
108924
108970
  }
108925
108971
  return assertClause;
108926
108972
  }
@@ -116429,12 +116475,14 @@ var ts;
116429
116475
  }
116430
116476
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116431
116477
  ;
116432
- /* @internal */
116478
+ /**
116479
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116480
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116481
+ */
116433
116482
  function getModeForFileReference(ref, containingFileMode) {
116434
116483
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116435
116484
  }
116436
116485
  ts.getModeForFileReference = getModeForFileReference;
116437
- /* @internal */
116438
116486
  function getModeForResolutionAtIndex(file, index) {
116439
116487
  if (file.impliedNodeFormat === undefined)
116440
116488
  return undefined;
@@ -116455,7 +116503,15 @@ var ts;
116455
116503
  return false;
116456
116504
  }
116457
116505
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116458
- /* @internal */
116506
+ /**
116507
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116508
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116509
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116510
+ * `moduleResolution` is `node16`+.
116511
+ * @param file The file the import or import-like reference is contained within
116512
+ * @param usage The module reference string
116513
+ * @returns The final resolution mode of the import
116514
+ */
116459
116515
  function getModeForUsageLocation(file, usage) {
116460
116516
  var _a, _b;
116461
116517
  if (file.impliedNodeFormat === undefined)
@@ -118691,7 +118747,7 @@ var ts;
118691
118747
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118692
118748
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118693
118749
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118694
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118750
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118695
118751
  }
118696
118752
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118697
118753
  }
@@ -4724,6 +4724,7 @@ declare namespace ts {
4724
4724
  function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
4725
4725
  function isImportDeclaration(node: Node): node is ImportDeclaration;
4726
4726
  function isImportClause(node: Node): node is ImportClause;
4727
+ function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer;
4727
4728
  function isAssertClause(node: Node): node is AssertClause;
4728
4729
  function isAssertEntry(node: Node): node is AssertEntry;
4729
4730
  function isNamespaceImport(node: Node): node is NamespaceImport;
@@ -5102,6 +5103,31 @@ declare namespace ts {
5102
5103
  export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string;
5103
5104
  export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string;
5104
5105
  export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string;
5106
+ /**
5107
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
5108
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
5109
+ */
5110
+ export function getModeForFileReference(ref: FileReference | string, containingFileMode: SourceFile["impliedNodeFormat"]): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5111
+ /**
5112
+ * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly
5113
+ * 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).
5114
+ * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node.
5115
+ * @param file File to fetch the resolution mode within
5116
+ * @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
5117
+ */
5118
+ export function getModeForResolutionAtIndex(file: SourceFile, index: number): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5119
+ /**
5120
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
5121
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
5122
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
5123
+ * `moduleResolution` is `node16`+.
5124
+ * @param file The file the import or import-like reference is contained within
5125
+ * @param usage The module reference string
5126
+ * @returns The final resolution mode of the import
5127
+ */
5128
+ export function getModeForUsageLocation(file: {
5129
+ impliedNodeFormat?: SourceFile["impliedNodeFormat"];
5130
+ }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined;
5105
5131
  export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[];
5106
5132
  /**
5107
5133
  * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the