typescript 4.6.0-dev.20220210 → 4.7.0-dev.20220216

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsc.js CHANGED
@@ -68,8 +68,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
68
68
  };
69
69
  var ts;
70
70
  (function (ts) {
71
- ts.versionMajorMinor = "4.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220210";
71
+ ts.versionMajorMinor = "4.7";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220216";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -3306,7 +3306,8 @@ var ts;
3306
3306
  { name: "types", optional: true, captureSpan: true },
3307
3307
  { name: "lib", optional: true, captureSpan: true },
3308
3308
  { name: "path", optional: true, captureSpan: true },
3309
- { name: "no-default-lib", optional: true }
3309
+ { name: "no-default-lib", optional: true },
3310
+ { name: "resolution-mode", optional: true }
3310
3311
  ],
3311
3312
  kind: 1
3312
3313
  },
@@ -4885,18 +4886,6 @@ var ts;
4885
4886
  return getCanonicalFileName(nonCanonicalizedPath);
4886
4887
  }
4887
4888
  ts.toPath = toPath;
4888
- function normalizePathAndParts(path) {
4889
- path = normalizeSlashes(path);
4890
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
4891
- if (parts.length) {
4892
- var joinedParts = root + parts.join(ts.directorySeparator);
4893
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
4894
- }
4895
- else {
4896
- return { path: root, parts: parts };
4897
- }
4898
- }
4899
- ts.normalizePathAndParts = normalizePathAndParts;
4900
4889
  function removeTrailingDirectorySeparator(path) {
4901
4890
  if (hasTrailingDirectorySeparator(path)) {
4902
4891
  return path.substr(0, path.length - 1);
@@ -5294,6 +5283,9 @@ var ts;
5294
5283
  An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
5295
5284
  Property_0_cannot_have_an_initializer_because_it_is_marked_abstract: diag(1267, ts.DiagnosticCategory.Error, "Property_0_cannot_have_an_initializer_because_it_is_marked_abstract_1267", "Property '{0}' cannot have an initializer because it is marked abstract."),
5296
5285
  An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type: diag(1268, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268", "An index signature parameter type must be 'string', 'number', 'symbol', or a template literal type."),
5286
+ Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
5287
+ Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
5288
+ Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
5297
5289
  with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
5298
5290
  await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
5299
5291
  Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
@@ -5427,6 +5419,8 @@ var ts;
5427
5419
  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."),
5428
5420
  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"),
5429
5421
  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"),
5422
+ Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node12` or `nodenext`."),
5423
+ 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`."),
5430
5424
  The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
5431
5425
  Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
5432
5426
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -6852,6 +6846,9 @@ var ts;
6852
6846
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
6853
6847
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
6854
6848
  Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
6849
+ Delete_unused_param_tag_0: diag(95171, ts.DiagnosticCategory.Message, "Delete_unused_param_tag_0_95171", "Delete unused '@param' tag '{0}'"),
6850
+ Delete_all_unused_param_tags: diag(95172, ts.DiagnosticCategory.Message, "Delete_all_unused_param_tags_95172", "Delete all unused '@param' tags"),
6851
+ Rename_param_tag_name_0_to_1: diag(95173, ts.DiagnosticCategory.Message, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
6855
6852
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
6856
6853
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
6857
6854
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -10704,7 +10701,10 @@ var ts;
10704
10701
  ts.Debug.assert(names.length === newResolutions.length);
10705
10702
  for (var i = 0; i < names.length; i++) {
10706
10703
  var newResolution = newResolutions[i];
10707
- var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
10704
+ var entry = names[i];
10705
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
10706
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
10707
+ var oldResolution = oldResolutions && oldResolutions.get(name, mode);
10708
10708
  var changed = oldResolution
10709
10709
  ? !newResolution || !comparer(oldResolution, newResolution)
10710
10710
  : newResolution;
@@ -21475,7 +21475,13 @@ var ts;
21475
21475
  referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
21476
21476
  break;
21477
21477
  case "type":
21478
- typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
21478
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
21479
+ break;
21480
+ case "type-import":
21481
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
21482
+ break;
21483
+ case "type-require":
21484
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
21479
21485
  break;
21480
21486
  case "lib":
21481
21487
  libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
@@ -21533,6 +21539,8 @@ var ts;
21533
21539
  case "no-default-lib":
21534
21540
  case "reference":
21535
21541
  case "type":
21542
+ case "type-import":
21543
+ case "type-require":
21536
21544
  case "lib":
21537
21545
  syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
21538
21546
  break;
@@ -24673,7 +24681,7 @@ var ts;
24673
24681
  function parseIsolatedEntityName(content, languageVersion) {
24674
24682
  initializeState("", content, languageVersion, undefined, 1);
24675
24683
  nextToken();
24676
- var entityName = parseEntityName(true);
24684
+ var entityName = parseEntityName(true, false);
24677
24685
  var isInvalid = token() === 1 && !parseDiagnostics.length;
24678
24686
  clearState();
24679
24687
  return isInvalid ? entityName : undefined;
@@ -25971,7 +25979,7 @@ var ts;
25971
25979
  }
25972
25980
  return createMissingList();
25973
25981
  }
25974
- function parseEntityName(allowReservedWords, diagnosticMessage) {
25982
+ function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
25975
25983
  var pos = getNodePos();
25976
25984
  var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
25977
25985
  var dotPos = getNodePos();
@@ -25981,7 +25989,7 @@ var ts;
25981
25989
  break;
25982
25990
  }
25983
25991
  dotPos = getNodePos();
25984
- entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false)), pos);
25992
+ entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
25985
25993
  }
25986
25994
  return entity;
25987
25995
  }
@@ -26084,7 +26092,7 @@ var ts;
26084
26092
  return finishNode(node, pos);
26085
26093
  }
26086
26094
  function parseEntityNameOfTypeReference() {
26087
- return parseEntityName(true, ts.Diagnostics.Type_expected);
26095
+ return parseEntityName(true, false, ts.Diagnostics.Type_expected);
26088
26096
  }
26089
26097
  function parseTypeArgumentsOfTypeReference() {
26090
26098
  if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
@@ -26198,7 +26206,7 @@ var ts;
26198
26206
  function parseTypeQuery() {
26199
26207
  var pos = getNodePos();
26200
26208
  parseExpected(112);
26201
- return finishNode(factory.createTypeQueryNode(parseEntityName(true)), pos);
26209
+ return finishNode(factory.createTypeQueryNode(parseEntityName(true, true)), pos);
26202
26210
  }
26203
26211
  function parseTypeParameter() {
26204
26212
  var pos = getNodePos();
@@ -28209,11 +28217,12 @@ var ts;
28209
28217
  }
28210
28218
  function parseCaseClause() {
28211
28219
  var pos = getNodePos();
28220
+ var hasJSDoc = hasPrecedingJSDocComment();
28212
28221
  parseExpected(82);
28213
28222
  var expression = allowInAnd(parseExpression);
28214
28223
  parseExpected(58);
28215
28224
  var statements = parseList(3, parseStatement);
28216
- return finishNode(factory.createCaseClause(expression, statements), pos);
28225
+ return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
28217
28226
  }
28218
28227
  function parseDefaultClause() {
28219
28228
  var pos = getNodePos();
@@ -29236,7 +29245,7 @@ var ts;
29236
29245
  function parseModuleReference() {
29237
29246
  return isExternalModuleReference()
29238
29247
  ? parseExternalModuleReference()
29239
- : parseEntityName(false);
29248
+ : parseEntityName(false, false);
29240
29249
  }
29241
29250
  function parseExternalModuleReference() {
29242
29251
  var pos = getNodePos();
@@ -29444,7 +29453,7 @@ var ts;
29444
29453
  var pos = getNodePos();
29445
29454
  var hasBrace = parseOptional(18);
29446
29455
  var p2 = getNodePos();
29447
- var entityName = parseEntityName(false);
29456
+ var entityName = parseEntityName(false, false);
29448
29457
  while (token() === 80) {
29449
29458
  reScanHashToken();
29450
29459
  nextTokenJSDoc();
@@ -29846,7 +29855,7 @@ var ts;
29846
29855
  skipWhitespace();
29847
29856
  var p2 = getNodePos();
29848
29857
  var name = ts.tokenIsIdentifierOrKeyword(token())
29849
- ? parseEntityName(true)
29858
+ ? parseEntityName(true, false)
29850
29859
  : undefined;
29851
29860
  if (name) {
29852
29861
  while (token() === 80) {
@@ -29871,11 +29880,13 @@ var ts;
29871
29880
  && nextTokenJSDoc() === 59
29872
29881
  && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
29873
29882
  var kind = scanner.getTokenValue();
29874
- if (kind === "link" || kind === "linkcode" || kind === "linkplain") {
29883
+ if (isJSDocLinkTag(kind))
29875
29884
  return kind;
29876
- }
29877
29885
  }
29878
29886
  }
29887
+ function isJSDocLinkTag(kind) {
29888
+ return kind === "link" || kind === "linkcode" || kind === "linkplain";
29889
+ }
29879
29890
  function parseUnknownTag(start, tagName, indent, indentText) {
29880
29891
  return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
29881
29892
  }
@@ -29978,7 +29989,7 @@ var ts;
29978
29989
  }
29979
29990
  function parseSeeTag(start, tagName, indent, indentText) {
29980
29991
  var isMarkdownOrJSDocLink = token() === 22
29981
- || lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
29992
+ || lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
29982
29993
  var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
29983
29994
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
29984
29995
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
@@ -30633,6 +30644,19 @@ var ts;
30633
30644
  return ts.fileExtensionIsOneOf(fileName, [".d.ts", ".d.mts", ".d.cts"]);
30634
30645
  }
30635
30646
  ts.isDeclarationFileName = isDeclarationFileName;
30647
+ function parseResolutionMode(mode, pos, end, reportDiagnostic) {
30648
+ if (!mode) {
30649
+ return undefined;
30650
+ }
30651
+ if (mode === "import") {
30652
+ return ts.ModuleKind.ESNext;
30653
+ }
30654
+ if (mode === "require") {
30655
+ return ts.ModuleKind.CommonJS;
30656
+ }
30657
+ reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
30658
+ return undefined;
30659
+ }
30636
30660
  function processCommentPragmas(context, sourceText) {
30637
30661
  var pragmas = [];
30638
30662
  for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
@@ -30671,12 +30695,13 @@ var ts;
30671
30695
  var typeReferenceDirectives_1 = context.typeReferenceDirectives;
30672
30696
  var libReferenceDirectives_1 = context.libReferenceDirectives;
30673
30697
  ts.forEach(ts.toArray(entryOrList), function (arg) {
30674
- var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
30698
+ var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
30675
30699
  if (arg.arguments["no-default-lib"]) {
30676
30700
  context.hasNoDefaultLib = true;
30677
30701
  }
30678
30702
  else if (types) {
30679
- typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
30703
+ var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
30704
+ typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
30680
30705
  }
30681
30706
  else if (lib) {
30682
30707
  libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
@@ -33919,14 +33944,14 @@ var ts;
33919
33944
  var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
33920
33945
  return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0;
33921
33946
  }
33922
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
33947
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
33923
33948
  var traceEnabled = isTraceEnabled(options, host);
33924
33949
  if (redirectedReference) {
33925
33950
  options = redirectedReference.commandLine.options;
33926
33951
  }
33927
33952
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
33928
33953
  var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
33929
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, undefined);
33954
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, resolutionMode);
33930
33955
  if (result) {
33931
33956
  if (traceEnabled) {
33932
33957
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -33961,7 +33986,11 @@ var ts;
33961
33986
  }
33962
33987
  var failedLookupLocations = [];
33963
33988
  var features = getDefaultNodeResolutionFeatures(options);
33964
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
33989
+ if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
33990
+ features |= NodeResolutionFeatures.EsmMode;
33991
+ }
33992
+ var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
33993
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
33965
33994
  var resolved = primaryLookup();
33966
33995
  var primary = true;
33967
33996
  if (!resolved) {
@@ -33981,7 +34010,7 @@ var ts;
33981
34010
  };
33982
34011
  }
33983
34012
  result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
33984
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, undefined, result);
34013
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, resolutionMode, result);
33985
34014
  if (traceEnabled)
33986
34015
  traceResult(result);
33987
34016
  return result;
@@ -34030,7 +34059,7 @@ var ts;
34030
34059
  result_4 = searchResult && searchResult.value;
34031
34060
  }
34032
34061
  else {
34033
- var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
34062
+ var candidate = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName).path;
34034
34063
  result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
34035
34064
  }
34036
34065
  return resolvedTypeScriptOnly(result_4);
@@ -34240,7 +34269,10 @@ var ts;
34240
34269
  ts.Debug.assert(keys.length === values.length);
34241
34270
  var map = createModeAwareCache();
34242
34271
  for (var i = 0; i < keys.length; ++i) {
34243
- map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
34272
+ var entry = keys[i];
34273
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
34274
+ var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
34275
+ map.set(name, mode, values[i]);
34244
34276
  }
34245
34277
  return map;
34246
34278
  }
@@ -34606,12 +34638,19 @@ var ts;
34606
34638
  return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
34607
34639
  }
34608
34640
  else {
34609
- var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
34641
+ var _a = normalizePathForCJSResolution(containingDirectory, moduleName), candidate = _a.path, parts = _a.parts;
34610
34642
  var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
34611
34643
  return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
34612
34644
  }
34613
34645
  }
34614
34646
  }
34647
+ function normalizePathForCJSResolution(containingDirectory, moduleName) {
34648
+ var combined = ts.combinePaths(containingDirectory, moduleName);
34649
+ var parts = ts.getPathComponents(combined);
34650
+ var lastPart = ts.lastOrUndefined(parts);
34651
+ var path = lastPart === "." || lastPart === ".." ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(combined)) : ts.normalizePath(combined);
34652
+ return { path: path, parts: parts };
34653
+ }
34615
34654
  function realPath(path, host, traceEnabled) {
34616
34655
  if (!host.realpath) {
34617
34656
  return path;
@@ -34653,7 +34692,10 @@ var ts;
34653
34692
  onlyRecordFailures = true;
34654
34693
  }
34655
34694
  }
34656
- return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
34695
+ if (!(state.features & NodeResolutionFeatures.EsmMode)) {
34696
+ return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
34697
+ }
34698
+ return undefined;
34657
34699
  }
34658
34700
  ts.nodeModulesPathPart = "/node_modules/";
34659
34701
  function pathContainsNodeModules(path) {
@@ -34981,7 +35023,13 @@ var ts;
34981
35023
  }
34982
35024
  }
34983
35025
  var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
34984
- return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
35026
+ var features = state.features;
35027
+ if ((jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.type) !== "module") {
35028
+ state.features &= ~NodeResolutionFeatures.EsmMode;
35029
+ }
35030
+ var result = nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
35031
+ state.features = features;
35032
+ return result;
34985
35033
  };
34986
35034
  var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
34987
35035
  var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
@@ -35310,6 +35358,12 @@ var ts;
35310
35358
  }
35311
35359
  var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
35312
35360
  loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
35361
+ if (!pathAndExtension && packageInfo
35362
+ && packageInfo.packageJsonContent.exports === undefined
35363
+ && packageInfo.packageJsonContent.main === undefined
35364
+ && state.features & NodeResolutionFeatures.EsmMode) {
35365
+ pathAndExtension = loadModuleFromFile(extensions, ts.combinePaths(candidate, "index.js"), onlyRecordFailures, state);
35366
+ }
35313
35367
  return withPackageId(packageInfo, pathAndExtension);
35314
35368
  };
35315
35369
  if (rest !== "") {
@@ -41417,8 +41471,13 @@ var ts;
41417
41471
  return res;
41418
41472
  }
41419
41473
  var candidates = ts.mapDefined(symbol.declarations, function (d) {
41420
- if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
41421
- return getSymbolOfNode(d.parent);
41474
+ if (!ts.isAmbientModule(d) && d.parent) {
41475
+ if (hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
41476
+ return getSymbolOfNode(d.parent);
41477
+ }
41478
+ if (ts.isModuleBlock(d.parent) && d.parent.parent && resolveExternalModuleSymbol(getSymbolOfNode(d.parent.parent)) === symbol) {
41479
+ return getSymbolOfNode(d.parent.parent);
41480
+ }
41422
41481
  }
41423
41482
  if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
41424
41483
  if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
@@ -45060,12 +45119,9 @@ var ts;
45060
45119
  }
45061
45120
  }
45062
45121
  if (ts.isInJSFile(declaration)) {
45063
- var typeTag = ts.getJSDocType(func);
45064
- if (typeTag && ts.isFunctionTypeNode(typeTag)) {
45065
- var signature = getSignatureFromDeclaration(typeTag);
45066
- var pos = func.parameters.indexOf(declaration);
45067
- return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
45068
- }
45122
+ var type_1 = getParameterTypeOfTypeTag(func, declaration);
45123
+ if (type_1)
45124
+ return type_1;
45069
45125
  }
45070
45126
  var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
45071
45127
  if (type) {
@@ -45557,8 +45613,8 @@ var ts;
45557
45613
  if (typeNode === undefined) {
45558
45614
  return useUnknownInCatchVariables ? unknownType : anyType;
45559
45615
  }
45560
- var type_1 = getTypeOfNode(typeNode);
45561
- return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
45616
+ var type_2 = getTypeOfNode(typeNode);
45617
+ return isTypeAny(type_2) || type_2 === unknownType ? type_2 : errorType;
45562
45618
  }
45563
45619
  if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
45564
45620
  if (!declaration.statements.length) {
@@ -45773,11 +45829,11 @@ var ts;
45773
45829
  return errorType;
45774
45830
  }
45775
45831
  var exportEquals = getMergedSymbol(symbol.exports.get("export="));
45776
- var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
45832
+ var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
45777
45833
  if (!popTypeResolution()) {
45778
45834
  return reportCircularityError(symbol);
45779
45835
  }
45780
- return type_2;
45836
+ return type_3;
45781
45837
  }
45782
45838
  }
45783
45839
  var type = createObjectType(16, symbol);
@@ -47710,10 +47766,10 @@ var ts;
47710
47766
  var baseTypes = [];
47711
47767
  var different = false;
47712
47768
  for (var _i = 0, types_7 = types; _i < types_7.length; _i++) {
47713
- var type_3 = types_7[_i];
47714
- var baseType = getBaseConstraint(type_3);
47769
+ var type_4 = types_7[_i];
47770
+ var baseType = getBaseConstraint(type_4);
47715
47771
  if (baseType) {
47716
- if (baseType !== type_3) {
47772
+ if (baseType !== type_4) {
47717
47773
  different = true;
47718
47774
  }
47719
47775
  baseTypes.push(baseType);
@@ -48323,6 +48379,13 @@ var ts;
48323
48379
  var typeTag = ts.getJSDocTypeTag(node);
48324
48380
  return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
48325
48381
  }
48382
+ function getParameterTypeOfTypeTag(func, parameter) {
48383
+ var signature = getSignatureOfTypeTag(func);
48384
+ if (!signature)
48385
+ return undefined;
48386
+ var pos = func.parameters.indexOf(parameter);
48387
+ return parameter.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
48388
+ }
48326
48389
  function getReturnTypeOfTypeTag(node) {
48327
48390
  var signature = getSignatureOfTypeTag(node);
48328
48391
  return signature && getReturnTypeOfSignature(signature);
@@ -48568,9 +48631,10 @@ var ts;
48568
48631
  return signature;
48569
48632
  }
48570
48633
  function getOrCreateTypeFromSignature(signature) {
48634
+ var _a;
48571
48635
  if (!signature.isolatedSignatureType) {
48572
- var kind = signature.declaration ? signature.declaration.kind : 0;
48573
- var isConstructor = kind === 170 || kind === 174 || kind === 179;
48636
+ var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
48637
+ var isConstructor = kind === undefined || kind === 170 || kind === 174 || kind === 179;
48574
48638
  var type = createObjectType(16);
48575
48639
  type.members = emptySymbols;
48576
48640
  type.properties = ts.emptyArray;
@@ -49407,7 +49471,7 @@ var ts;
49407
49471
  }
49408
49472
  }
49409
49473
  var fixedLength = properties.length;
49410
- var lengthSymbol = createSymbol(4, "length");
49474
+ var lengthSymbol = createSymbol(4, "length", readonly ? 8 : 0);
49411
49475
  if (combinedFlags & 12) {
49412
49476
  lengthSymbol.type = numberType;
49413
49477
  }
@@ -52584,9 +52648,9 @@ var ts;
52584
52648
  isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
52585
52649
  return true;
52586
52650
  }
52587
- if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
52651
+ if (s & 32768 && (!strictNullChecks && !(t & 3145728) || t & (32768 | 16384)))
52588
52652
  return true;
52589
- if (s & 65536 && (!strictNullChecks || t & 65536))
52653
+ if (s & 65536 && (!strictNullChecks && !(t & 3145728) || t & 65536))
52590
52654
  return true;
52591
52655
  if (s & 524288 && t & 67108864)
52592
52656
  return true;
@@ -52661,11 +52725,11 @@ var ts;
52661
52725
  var overflow = false;
52662
52726
  var overrideNextErrorInfo = 0;
52663
52727
  var lastSkippedInfo;
52664
- var incompatibleStack = [];
52728
+ var incompatibleStack;
52665
52729
  var inPropertyCheck = false;
52666
52730
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
52667
52731
  var result = isRelatedTo(source, target, 3, !!errorNode, headMessage);
52668
- if (incompatibleStack.length) {
52732
+ if (incompatibleStack) {
52669
52733
  reportIncompatibleStack();
52670
52734
  }
52671
52735
  if (overflow) {
@@ -52720,19 +52784,19 @@ var ts;
52720
52784
  return {
52721
52785
  errorInfo: errorInfo,
52722
52786
  lastSkippedInfo: lastSkippedInfo,
52723
- incompatibleStack: incompatibleStack.slice(),
52787
+ incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
52724
52788
  overrideNextErrorInfo: overrideNextErrorInfo,
52725
- relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
52789
+ relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
52726
52790
  };
52727
52791
  }
52728
52792
  function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
52729
52793
  overrideNextErrorInfo++;
52730
52794
  lastSkippedInfo = undefined;
52731
- incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
52795
+ (incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
52732
52796
  }
52733
52797
  function reportIncompatibleStack() {
52734
- var stack = incompatibleStack;
52735
- incompatibleStack = [];
52798
+ var stack = incompatibleStack || [];
52799
+ incompatibleStack = undefined;
52736
52800
  var info = lastSkippedInfo;
52737
52801
  lastSkippedInfo = undefined;
52738
52802
  if (stack.length === 1) {
@@ -52826,7 +52890,7 @@ var ts;
52826
52890
  }
52827
52891
  function reportError(message, arg0, arg1, arg2, arg3) {
52828
52892
  ts.Debug.assert(!!errorNode);
52829
- if (incompatibleStack.length)
52893
+ if (incompatibleStack)
52830
52894
  reportIncompatibleStack();
52831
52895
  if (message.elidedInCompatabilityPyramid)
52832
52896
  return;
@@ -52842,7 +52906,7 @@ var ts;
52842
52906
  }
52843
52907
  }
52844
52908
  function reportRelationError(message, source, target) {
52845
- if (incompatibleStack.length)
52909
+ if (incompatibleStack)
52846
52910
  reportIncompatibleStack();
52847
52911
  var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
52848
52912
  var generalizedSource = source;
@@ -52933,7 +52997,9 @@ var ts;
52933
52997
  if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
52934
52998
  return -1;
52935
52999
  }
52936
- reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 2048));
53000
+ if (reportErrors) {
53001
+ reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
53002
+ }
52937
53003
  return 0;
52938
53004
  }
52939
53005
  var source = getNormalizedType(originalSource, false);
@@ -52941,127 +53007,121 @@ var ts;
52941
53007
  if (source === target)
52942
53008
  return -1;
52943
53009
  if (relation === identityRelation) {
52944
- return isIdenticalTo(source, target, recursionFlags);
53010
+ if (source.flags !== target.flags)
53011
+ return 0;
53012
+ if (source.flags & 67358815)
53013
+ return -1;
53014
+ traceUnionsOrIntersectionsTooLarge(source, target);
53015
+ return recursiveTypeRelatedTo(source, target, false, 0, recursionFlags);
52945
53016
  }
52946
53017
  if (source.flags & 262144 && getConstraintOfType(source) === target) {
52947
53018
  return -1;
52948
53019
  }
52949
- if (target.flags & 1048576 && source.flags & 524288 &&
52950
- target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
52951
- var nullStrippedTarget = extractTypesOfKind(target, ~98304);
52952
- if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
52953
- target = getNormalizedType(nullStrippedTarget, true);
53020
+ if (source.flags & 470302716 && target.flags & 1048576) {
53021
+ var types = target.types;
53022
+ var candidate = types.length === 2 && types[0].flags & 98304 ? types[1] :
53023
+ types.length === 3 && types[0].flags & 98304 && types[1].flags & 98304 ? types[2] :
53024
+ undefined;
53025
+ if (candidate && !(candidate.flags & 98304)) {
53026
+ target = getNormalizedType(candidate, true);
53027
+ if (source === target)
53028
+ return -1;
52954
53029
  }
52955
- if (source === nullStrippedTarget)
52956
- return -1;
52957
53030
  }
52958
53031
  if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
52959
53032
  isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
52960
53033
  return -1;
52961
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048);
52962
- var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384);
52963
- if (isPerformingExcessPropertyChecks) {
52964
- if (hasExcessProperties(source, target, reportErrors)) {
53034
+ if (source.flags & 469499904 || target.flags & 469499904) {
53035
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384);
53036
+ if (isPerformingExcessPropertyChecks) {
53037
+ if (hasExcessProperties(source, target, reportErrors)) {
53038
+ if (reportErrors) {
53039
+ reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
53040
+ }
53041
+ return 0;
53042
+ }
53043
+ }
53044
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
53045
+ source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
53046
+ target.flags & (524288 | 2097152) && isWeakType(target) &&
53047
+ (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
53048
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048);
53049
+ if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
52965
53050
  if (reportErrors) {
52966
- reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
53051
+ var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
53052
+ var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
53053
+ var calls = getSignaturesOfType(source, 0);
53054
+ var constructs = getSignaturesOfType(source, 1);
53055
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1, false) ||
53056
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1, false)) {
53057
+ reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
53058
+ }
53059
+ else {
53060
+ reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
53061
+ }
52967
53062
  }
52968
53063
  return 0;
52969
53064
  }
52970
- }
52971
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
52972
- source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
52973
- target.flags & (524288 | 2097152) && isWeakType(target) &&
52974
- (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
52975
- if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
52976
- if (reportErrors) {
52977
- var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
52978
- var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
52979
- var calls = getSignaturesOfType(source, 0);
52980
- var constructs = getSignaturesOfType(source, 1);
52981
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1, false) ||
52982
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1, false)) {
52983
- reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
52984
- }
52985
- else {
52986
- reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
52987
- }
53065
+ traceUnionsOrIntersectionsTooLarge(source, target);
53066
+ var skipCaching = source.flags & 1048576 && source.types.length < 4 && !(target.flags & 1048576) ||
53067
+ target.flags & 1048576 && target.types.length < 4 && !(source.flags & 469499904);
53068
+ var result_7 = skipCaching ?
53069
+ unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
53070
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
53071
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53072
+ isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288); }))) {
53073
+ inPropertyCheck = true;
53074
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53075
+ inPropertyCheck = false;
52988
53076
  }
52989
- return 0;
52990
- }
52991
- traceUnionsOrIntersectionsTooLarge(source, target);
52992
- var result = 0;
52993
- var saveErrorInfo = captureErrorCalculationState();
52994
- if ((source.flags & 1048576 || target.flags & 1048576) && getConstituentCount(source) * getConstituentCount(target) < 4) {
52995
- result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8);
52996
- }
52997
- else if (source.flags & 3145728 || target.flags & 3145728) {
52998
- result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8, recursionFlags);
52999
- }
53000
- if (!result && !(source.flags & 1048576) && (source.flags & (469499904) || target.flags & 469499904)) {
53001
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
53002
- resetErrorInfo(saveErrorInfo);
53077
+ if (result_7) {
53078
+ return result_7;
53003
53079
  }
53004
53080
  }
53005
- if (!result && source.flags & (2097152 | 262144)) {
53006
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
53007
- if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
53008
- if (everyType(constraint, function (c) { return c !== source; })) {
53009
- if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
53010
- resetErrorInfo(saveErrorInfo);
53011
- }
53012
- }
53081
+ if (reportErrors) {
53082
+ reportErrorResults(originalSource, originalTarget, source, target, headMessage);
53083
+ }
53084
+ return 0;
53085
+ }
53086
+ function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
53087
+ var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53088
+ var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53089
+ source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
53090
+ target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
53091
+ var maybeSuppress = overrideNextErrorInfo > 0;
53092
+ if (maybeSuppress) {
53093
+ overrideNextErrorInfo--;
53094
+ }
53095
+ if (source.flags & 524288 && target.flags & 524288) {
53096
+ var currentError = errorInfo;
53097
+ tryElaborateArrayLikeErrors(source, target, true);
53098
+ if (errorInfo !== currentError) {
53099
+ maybeSuppress = !!errorInfo;
53100
+ }
53101
+ }
53102
+ if (source.flags & 524288 && target.flags & 131068) {
53103
+ tryElaborateErrorsForPrimitivesAndObjects(source, target);
53104
+ }
53105
+ else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
53106
+ reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
53107
+ }
53108
+ else if (ts.getObjectFlags(source) & 2048 && target.flags & 2097152) {
53109
+ var targetTypes = target.types;
53110
+ var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
53111
+ var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
53112
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
53113
+ (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
53114
+ return;
53013
53115
  }
53014
53116
  }
53015
- if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
53016
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288); }))) {
53017
- inPropertyCheck = true;
53018
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4, recursionFlags);
53019
- inPropertyCheck = false;
53117
+ else {
53118
+ errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
53020
53119
  }
53021
- reportErrorResults(source, target, result, isComparingJsxAttributes);
53022
- return result;
53023
- function reportErrorResults(source, target, result, isComparingJsxAttributes) {
53024
- if (!result && reportErrors) {
53025
- var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
53026
- var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
53027
- source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
53028
- target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
53029
- var maybeSuppress = overrideNextErrorInfo > 0;
53030
- if (maybeSuppress) {
53031
- overrideNextErrorInfo--;
53032
- }
53033
- if (source.flags & 524288 && target.flags & 524288) {
53034
- var currentError = errorInfo;
53035
- tryElaborateArrayLikeErrors(source, target, reportErrors);
53036
- if (errorInfo !== currentError) {
53037
- maybeSuppress = !!errorInfo;
53038
- }
53039
- }
53040
- if (source.flags & 524288 && target.flags & 131068) {
53041
- tryElaborateErrorsForPrimitivesAndObjects(source, target);
53042
- }
53043
- else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
53044
- reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
53045
- }
53046
- else if (isComparingJsxAttributes && target.flags & 2097152) {
53047
- var targetTypes = target.types;
53048
- var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
53049
- var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
53050
- if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
53051
- (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
53052
- return result;
53053
- }
53054
- }
53055
- else {
53056
- errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
53057
- }
53058
- if (!headMessage && maybeSuppress) {
53059
- lastSkippedInfo = [source, target];
53060
- return result;
53061
- }
53062
- reportRelationError(headMessage, source, target);
53063
- }
53120
+ if (!headMessage && maybeSuppress) {
53121
+ lastSkippedInfo = [source, target];
53122
+ return;
53064
53123
  }
53124
+ reportRelationError(headMessage, source, target);
53065
53125
  }
53066
53126
  function traceUnionsOrIntersectionsTooLarge(source, target) {
53067
53127
  if (!ts.tracing) {
@@ -53087,21 +53147,6 @@ var ts;
53087
53147
  }
53088
53148
  }
53089
53149
  }
53090
- function isIdenticalTo(source, target, recursionFlags) {
53091
- if (source.flags !== target.flags)
53092
- return 0;
53093
- if (source.flags & 67358815)
53094
- return -1;
53095
- traceUnionsOrIntersectionsTooLarge(source, target);
53096
- if (source.flags & 3145728) {
53097
- var result_7 = eachTypeRelatedToSomeType(source, target);
53098
- if (result_7) {
53099
- result_7 &= eachTypeRelatedToSomeType(target, source);
53100
- }
53101
- return result_7;
53102
- }
53103
- return recursiveTypeRelatedTo(source, target, false, 0, recursionFlags);
53104
- }
53105
53150
  function getTypeOfPropertyInTypes(types, name) {
53106
53151
  var appendPropType = function (propTypes, type) {
53107
53152
  var _a;
@@ -53190,6 +53235,29 @@ var ts;
53190
53235
  function shouldCheckAsExcessProperty(prop, container) {
53191
53236
  return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
53192
53237
  }
53238
+ function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
53239
+ if (source.flags & 1048576) {
53240
+ return relation === comparableRelation ?
53241
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState) :
53242
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState);
53243
+ }
53244
+ if (target.flags & 1048576) {
53245
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
53246
+ }
53247
+ if (target.flags & 2097152) {
53248
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
53249
+ }
53250
+ if (relation === comparableRelation && target.flags & 131068) {
53251
+ var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
53252
+ if (constraints !== source.types) {
53253
+ source = getIntersectionType(constraints);
53254
+ if (!(source.flags & 2097152)) {
53255
+ return isRelatedTo(source, target, 1, false);
53256
+ }
53257
+ }
53258
+ }
53259
+ return someTypeRelatedToType(source, target, false, 1);
53260
+ }
53193
53261
  function eachTypeRelatedToSomeType(source, target) {
53194
53262
  var result = -1;
53195
53263
  var sourceTypes = source.types;
@@ -53226,7 +53294,9 @@ var ts;
53226
53294
  }
53227
53295
  if (reportErrors) {
53228
53296
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
53229
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2, true);
53297
+ if (bestMatchingType) {
53298
+ isRelatedTo(source, bestMatchingType, 2, true);
53299
+ }
53230
53300
  }
53231
53301
  return 0;
53232
53302
  }
@@ -53334,7 +53404,7 @@ var ts;
53334
53404
  if (overflow) {
53335
53405
  return 0;
53336
53406
  }
53337
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 : 0);
53407
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 : 0);
53338
53408
  var id = getRelationKey(source, target, keyIntersectionState, relation, false);
53339
53409
  var entry = relation.get(id);
53340
53410
  if (entry !== undefined) {
@@ -53395,6 +53465,7 @@ var ts;
53395
53465
  return originalHandler(onlyUnreliable);
53396
53466
  };
53397
53467
  }
53468
+ var result;
53398
53469
  if (expandingFlags === 3) {
53399
53470
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "recursiveTypeRelatedTo_DepthLimit", {
53400
53471
  sourceId: source.id,
@@ -53404,8 +53475,13 @@ var ts;
53404
53475
  depth: sourceDepth,
53405
53476
  targetDepth: targetDepth
53406
53477
  });
53478
+ result = 3;
53479
+ }
53480
+ else {
53481
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
53482
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
53483
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
53407
53484
  }
53408
- var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3;
53409
53485
  if (outofbandVarianceMarkerHandler) {
53410
53486
  outofbandVarianceMarkerHandler = originalHandler;
53411
53487
  }
@@ -53433,74 +53509,73 @@ var ts;
53433
53509
  return result;
53434
53510
  }
53435
53511
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
53436
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
53437
- var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
53438
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
53439
- return result;
53440
- }
53441
- function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
53442
53512
  if (intersectionState & 4) {
53443
53513
  return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
53444
53514
  }
53445
- if (intersectionState & 8) {
53446
- if (source.flags & 1048576) {
53447
- return relation === comparableRelation ?
53448
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8) :
53449
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8);
53450
- }
53451
- if (target.flags & 1048576) {
53452
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
53453
- }
53454
- if (target.flags & 2097152) {
53455
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
53456
- }
53457
- if (relation === comparableRelation && target.flags & 131068) {
53458
- var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
53459
- if (constraints !== source.types) {
53460
- source = getIntersectionType(constraints);
53461
- if (!(source.flags & 2097152)) {
53462
- return isRelatedTo(source, target, 1, false);
53463
- }
53515
+ var result;
53516
+ var originalErrorInfo;
53517
+ var varianceCheckFailed = false;
53518
+ var saveErrorInfo = captureErrorCalculationState();
53519
+ var sourceFlags = source.flags;
53520
+ var targetFlags = target.flags;
53521
+ if (relation === identityRelation) {
53522
+ if (sourceFlags & 3145728) {
53523
+ var result_8 = eachTypeRelatedToSomeType(source, target);
53524
+ if (result_8) {
53525
+ result_8 &= eachTypeRelatedToSomeType(target, source);
53464
53526
  }
53527
+ return result_8;
53465
53528
  }
53466
- return someTypeRelatedToType(source, target, false, 1);
53467
- }
53468
- var flags = source.flags & target.flags;
53469
- if (relation === identityRelation && !(flags & 524288)) {
53470
- if (flags & 4194304) {
53529
+ if (sourceFlags & 4194304) {
53471
53530
  return isRelatedTo(source.type, target.type, 3, false);
53472
53531
  }
53473
- var result_8 = 0;
53474
- if (flags & 8388608) {
53475
- if (result_8 = isRelatedTo(source.objectType, target.objectType, 3, false)) {
53476
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3, false)) {
53477
- return result_8;
53532
+ if (sourceFlags & 8388608) {
53533
+ if (result = isRelatedTo(source.objectType, target.objectType, 3, false)) {
53534
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3, false)) {
53535
+ return result;
53478
53536
  }
53479
53537
  }
53480
53538
  }
53481
- if (flags & 16777216) {
53539
+ if (sourceFlags & 16777216) {
53482
53540
  if (source.root.isDistributive === target.root.isDistributive) {
53483
- if (result_8 = isRelatedTo(source.checkType, target.checkType, 3, false)) {
53484
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3, false)) {
53485
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3, false)) {
53486
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, false)) {
53487
- return result_8;
53541
+ if (result = isRelatedTo(source.checkType, target.checkType, 3, false)) {
53542
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3, false)) {
53543
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3, false)) {
53544
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, false)) {
53545
+ return result;
53488
53546
  }
53489
53547
  }
53490
53548
  }
53491
53549
  }
53492
53550
  }
53493
53551
  }
53494
- if (flags & 33554432) {
53552
+ if (sourceFlags & 33554432) {
53495
53553
  return isRelatedTo(source.substitute, target.substitute, 3, false);
53496
53554
  }
53497
- return 0;
53555
+ if (!(sourceFlags & 524288)) {
53556
+ return 0;
53557
+ }
53498
53558
  }
53499
- var result;
53500
- var originalErrorInfo;
53501
- var varianceCheckFailed = false;
53502
- var saveErrorInfo = captureErrorCalculationState();
53503
- if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
53559
+ else if (sourceFlags & 3145728 || targetFlags & 3145728) {
53560
+ if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
53561
+ return result;
53562
+ }
53563
+ if (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576) {
53564
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
53565
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) {
53566
+ if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) {
53567
+ resetErrorInfo(saveErrorInfo);
53568
+ return result;
53569
+ }
53570
+ }
53571
+ }
53572
+ if (!(sourceFlags & 465829888 ||
53573
+ sourceFlags & 524288 && targetFlags & 1048576 ||
53574
+ sourceFlags & 2097152 && targetFlags & (524288 | 1048576 | 465829888))) {
53575
+ return 0;
53576
+ }
53577
+ }
53578
+ if (sourceFlags & (524288 | 16777216) && source.aliasSymbol &&
53504
53579
  source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
53505
53580
  !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
53506
53581
  var variances = getAliasVariances(source.aliasSymbol);
@@ -53516,7 +53591,7 @@ var ts;
53516
53591
  isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2))) {
53517
53592
  return result;
53518
53593
  }
53519
- if (target.flags & 262144) {
53594
+ if (targetFlags & 262144) {
53520
53595
  if (ts.getObjectFlags(source) & 32 && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3)) {
53521
53596
  if (!(getMappedTypeModifiers(source) & 4)) {
53522
53597
  var templateType = getTemplateTypeFromMappedType(source);
@@ -53527,9 +53602,9 @@ var ts;
53527
53602
  }
53528
53603
  }
53529
53604
  }
53530
- else if (target.flags & 4194304) {
53605
+ else if (targetFlags & 4194304) {
53531
53606
  var targetType_1 = target.type;
53532
- if (source.flags & 4194304) {
53607
+ if (sourceFlags & 4194304) {
53533
53608
  if (result = isRelatedTo(targetType_1, source.type, 3, false)) {
53534
53609
  return result;
53535
53610
  }
@@ -53565,8 +53640,8 @@ var ts;
53565
53640
  }
53566
53641
  }
53567
53642
  }
53568
- else if (target.flags & 8388608) {
53569
- if (source.flags & 8388608) {
53643
+ else if (targetFlags & 8388608) {
53644
+ if (sourceFlags & 8388608) {
53570
53645
  if (result = isRelatedTo(source.objectType, target.objectType, 3, reportErrors)) {
53571
53646
  result &= isRelatedTo(source.indexType, target.indexType, 3, reportErrors);
53572
53647
  }
@@ -53645,7 +53720,7 @@ var ts;
53645
53720
  }
53646
53721
  }
53647
53722
  }
53648
- else if (target.flags & 16777216) {
53723
+ else if (targetFlags & 16777216) {
53649
53724
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
53650
53725
  resetErrorInfo(saveErrorInfo);
53651
53726
  return 3;
@@ -53663,8 +53738,8 @@ var ts;
53663
53738
  }
53664
53739
  }
53665
53740
  }
53666
- else if (target.flags & 134217728) {
53667
- if (source.flags & 134217728) {
53741
+ else if (targetFlags & 134217728) {
53742
+ if (sourceFlags & 134217728) {
53668
53743
  if (relation === comparableRelation) {
53669
53744
  return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 : -1;
53670
53745
  }
@@ -53674,10 +53749,10 @@ var ts;
53674
53749
  return -1;
53675
53750
  }
53676
53751
  }
53677
- if (source.flags & 8650752) {
53678
- if (!(source.flags & 8388608 && target.flags & 8388608)) {
53752
+ if (sourceFlags & 8650752) {
53753
+ if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
53679
53754
  var constraint = getConstraintOfType(source);
53680
- if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
53755
+ if (!constraint || (sourceFlags & 262144 && constraint.flags & 1)) {
53681
53756
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864), 3)) {
53682
53757
  resetErrorInfo(saveErrorInfo);
53683
53758
  return result;
@@ -53687,7 +53762,7 @@ var ts;
53687
53762
  resetErrorInfo(saveErrorInfo);
53688
53763
  return result;
53689
53764
  }
53690
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(target.flags & source.flags & 262144), undefined, intersectionState)) {
53765
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) {
53691
53766
  resetErrorInfo(saveErrorInfo);
53692
53767
  return result;
53693
53768
  }
@@ -53702,14 +53777,14 @@ var ts;
53702
53777
  }
53703
53778
  }
53704
53779
  }
53705
- else if (source.flags & 4194304) {
53780
+ else if (sourceFlags & 4194304) {
53706
53781
  if (result = isRelatedTo(keyofConstraintType, target, 1, reportErrors)) {
53707
53782
  resetErrorInfo(saveErrorInfo);
53708
53783
  return result;
53709
53784
  }
53710
53785
  }
53711
- else if (source.flags & 134217728 && !(target.flags & 524288)) {
53712
- if (!(target.flags & 134217728)) {
53786
+ else if (sourceFlags & 134217728 && !(targetFlags & 524288)) {
53787
+ if (!(targetFlags & 134217728)) {
53713
53788
  var constraint = getBaseConstraintOfType(source);
53714
53789
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1, reportErrors))) {
53715
53790
  resetErrorInfo(saveErrorInfo);
@@ -53717,8 +53792,8 @@ var ts;
53717
53792
  }
53718
53793
  }
53719
53794
  }
53720
- else if (source.flags & 268435456) {
53721
- if (target.flags & 268435456 && source.symbol === target.symbol) {
53795
+ else if (sourceFlags & 268435456) {
53796
+ if (targetFlags & 268435456 && source.symbol === target.symbol) {
53722
53797
  if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) {
53723
53798
  resetErrorInfo(saveErrorInfo);
53724
53799
  return result;
@@ -53732,12 +53807,12 @@ var ts;
53732
53807
  }
53733
53808
  }
53734
53809
  }
53735
- else if (source.flags & 16777216) {
53810
+ else if (sourceFlags & 16777216) {
53736
53811
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
53737
53812
  resetErrorInfo(saveErrorInfo);
53738
53813
  return 3;
53739
53814
  }
53740
- if (target.flags & 16777216) {
53815
+ if (targetFlags & 16777216) {
53741
53816
  var sourceParams = source.root.inferTypeParameters;
53742
53817
  var sourceExtends = source.extendsType;
53743
53818
  var mapper = void 0;
@@ -53788,15 +53863,19 @@ var ts;
53788
53863
  }
53789
53864
  return 0;
53790
53865
  }
53791
- var sourceIsPrimitive = !!(source.flags & 131068);
53866
+ var sourceIsPrimitive = !!(sourceFlags & 131068);
53792
53867
  if (relation !== identityRelation) {
53793
53868
  source = getApparentType(source);
53869
+ sourceFlags = source.flags;
53794
53870
  }
53795
53871
  else if (isGenericMappedType(source)) {
53796
53872
  return 0;
53797
53873
  }
53798
53874
  if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
53799
53875
  !isTupleType(source) && !(ts.getObjectFlags(source) & 4096 || ts.getObjectFlags(target) & 4096)) {
53876
+ if (isEmptyArrayLiteralType(source)) {
53877
+ return -1;
53878
+ }
53800
53879
  var variances = getVariances(source.target);
53801
53880
  if (variances === ts.emptyArray) {
53802
53881
  return 1;
@@ -53817,7 +53896,7 @@ var ts;
53817
53896
  else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 && !isEmptyObjectType(source)) {
53818
53897
  return 0;
53819
53898
  }
53820
- if (source.flags & (524288 | 2097152) && target.flags & 524288) {
53899
+ if (sourceFlags & (524288 | 2097152) && targetFlags & 524288) {
53821
53900
  var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
53822
53901
  result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
53823
53902
  if (result) {
@@ -53836,7 +53915,7 @@ var ts;
53836
53915
  return result;
53837
53916
  }
53838
53917
  }
53839
- if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
53918
+ if (sourceFlags & (524288 | 2097152) && targetFlags & 1048576) {
53840
53919
  var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
53841
53920
  if (objectOnlyTarget.flags & 1048576) {
53842
53921
  var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
@@ -54032,6 +54111,10 @@ var ts;
54032
54111
  }
54033
54112
  return 0;
54034
54113
  }
54114
+ if ((relation === subtypeRelation || relation === strictSubtypeRelation) &&
54115
+ !!(sourcePropFlags & 64) && !(targetPropFlags & 64)) {
54116
+ return 0;
54117
+ }
54035
54118
  var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
54036
54119
  if (!related) {
54037
54120
  if (reportErrors) {
@@ -54282,7 +54365,6 @@ var ts;
54282
54365
  }
54283
54366
  }
54284
54367
  var result = -1;
54285
- var saveErrorInfo = captureErrorCalculationState();
54286
54368
  var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
54287
54369
  var sourceObjectFlags = ts.getObjectFlags(source);
54288
54370
  var targetObjectFlags = ts.getObjectFlags(target);
@@ -54314,6 +54396,7 @@ var ts;
54314
54396
  else {
54315
54397
  outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
54316
54398
  var t = targetSignatures_1[_i];
54399
+ var saveErrorInfo = captureErrorCalculationState();
54317
54400
  var shouldElaborateErrors = reportErrors;
54318
54401
  for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
54319
54402
  var s = sourceSignatures_1[_c];
@@ -57102,9 +57185,6 @@ var ts;
57102
57185
  getUnionType(ts.map(type.types, mapper), 1, aliasSymbol, aliasTypeArguments) :
57103
57186
  mapType(type, mapper);
57104
57187
  }
57105
- function getConstituentCount(type) {
57106
- return type.flags & 1048576 ? type.types.length : 1;
57107
- }
57108
57188
  function extractTypesOfKind(type, kind) {
57109
57189
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
57110
57190
  }
@@ -61062,6 +61142,9 @@ var ts;
61062
61142
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
61063
61143
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
61064
61144
  }
61145
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728) {
61146
+ addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
61147
+ }
61065
61148
  }
61066
61149
  else {
61067
61150
  if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
@@ -63168,8 +63251,8 @@ var ts;
63168
63251
  if (hasDefaultOnly && type && !isErrorType(type)) {
63169
63252
  var synthType = type;
63170
63253
  if (!synthType.defaultOnlyType) {
63171
- var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
63172
- synthType.defaultOnlyType = type_4;
63254
+ var type_5 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
63255
+ synthType.defaultOnlyType = type_5;
63173
63256
  }
63174
63257
  return synthType.defaultOnlyType;
63175
63258
  }
@@ -63613,19 +63696,20 @@ var ts;
63613
63696
  if (links.type === unknownType) {
63614
63697
  links.type = getTypeFromBindingPattern(declaration.name);
63615
63698
  }
63616
- assignBindingElementTypes(declaration.name);
63699
+ assignBindingElementTypes(declaration.name, links.type);
63617
63700
  }
63618
63701
  }
63619
63702
  }
63620
- function assignBindingElementTypes(pattern) {
63703
+ function assignBindingElementTypes(pattern, parentType) {
63621
63704
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
63622
63705
  var element = _a[_i];
63623
63706
  if (!ts.isOmittedExpression(element)) {
63707
+ var type = getBindingElementTypeFromParentType(element, parentType);
63624
63708
  if (element.name.kind === 79) {
63625
- getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
63709
+ getSymbolLinks(getSymbolOfNode(element)).type = type;
63626
63710
  }
63627
63711
  else {
63628
- assignBindingElementTypes(element.name);
63712
+ assignBindingElementTypes(element.name, type);
63629
63713
  }
63630
63714
  }
63631
63715
  }
@@ -63835,11 +63919,11 @@ var ts;
63835
63919
  var operandType = getTypeOfExpression(node.expression.expression);
63836
63920
  var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
63837
63921
  var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
63838
- var type_5 = getBaseConstraintOfType(operandType) || operandType;
63839
- if (type_5.flags & 3) {
63922
+ var type_6 = getBaseConstraintOfType(operandType) || operandType;
63923
+ if (type_6.flags & 3) {
63840
63924
  return (556800 & notEqualFacts_1) === 556800;
63841
63925
  }
63842
- return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
63926
+ return !!(filterType(type_6, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
63843
63927
  }
63844
63928
  var type = getTypeOfExpression(node.expression);
63845
63929
  if (!isLiteralType(type)) {
@@ -65724,6 +65808,7 @@ var ts;
65724
65808
  }
65725
65809
  }
65726
65810
  checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
65811
+ checkUnmatchedJSDocParameters(node);
65727
65812
  ts.forEach(node.parameters, checkParameter);
65728
65813
  if (node.type) {
65729
65814
  checkSourceElement(node.type);
@@ -66819,26 +66904,24 @@ var ts;
66819
66904
  if (returnType.flags & 1) {
66820
66905
  return;
66821
66906
  }
66907
+ var headMessage;
66822
66908
  var expectedReturnType;
66823
- var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
66824
- var errorInfo;
66825
66909
  switch (node.parent.kind) {
66826
66910
  case 256:
66911
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
66827
66912
  var classSymbol = getSymbolOfNode(node.parent);
66828
66913
  var classConstructorType = getTypeOfSymbol(classSymbol);
66829
66914
  expectedReturnType = getUnionType([classConstructorType, voidType]);
66830
66915
  break;
66831
- case 163:
66832
- expectedReturnType = voidType;
66833
- errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
66834
- break;
66835
66916
  case 166:
66917
+ case 163:
66918
+ headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
66836
66919
  expectedReturnType = voidType;
66837
- errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
66838
66920
  break;
66839
66921
  case 168:
66840
66922
  case 171:
66841
66923
  case 172:
66924
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
66842
66925
  var methodType = getTypeOfNode(node.parent);
66843
66926
  var descriptorType = createTypedPropertyDescriptorType(methodType);
66844
66927
  expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -66846,7 +66929,7 @@ var ts;
66846
66929
  default:
66847
66930
  return ts.Debug.fail();
66848
66931
  }
66849
- checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
66932
+ checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
66850
66933
  }
66851
66934
  function markTypeNodeAsReferenced(node) {
66852
66935
  markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
@@ -67005,28 +67088,6 @@ var ts;
67005
67088
  }
67006
67089
  function checkJSDocParameterTag(node) {
67007
67090
  checkSourceElement(node.typeExpression);
67008
- if (!ts.getParameterSymbolFromJSDoc(node)) {
67009
- var decl = ts.getHostSignatureFromJSDoc(node);
67010
- if (decl) {
67011
- var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
67012
- if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
67013
- return;
67014
- }
67015
- if (!containsArgumentsReference(decl)) {
67016
- if (ts.isQualifiedName(node.name)) {
67017
- error(node.name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(node.name), ts.entityNameToString(node.name.left));
67018
- }
67019
- else {
67020
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
67021
- }
67022
- }
67023
- else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
67024
- node.typeExpression && node.typeExpression.type &&
67025
- !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
67026
- error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 160 ? node.name.right : node.name));
67027
- }
67028
- }
67029
- }
67030
67091
  }
67031
67092
  function checkJSDocPropertyTag(node) {
67032
67093
  checkSourceElement(node.typeExpression);
@@ -68710,6 +68771,45 @@ var ts;
68710
68771
  error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
68711
68772
  }
68712
68773
  }
68774
+ function checkUnmatchedJSDocParameters(node) {
68775
+ var jsdocParameters = ts.filter(ts.getJSDocTags(node), ts.isJSDocParameterTag);
68776
+ if (!ts.length(jsdocParameters))
68777
+ return;
68778
+ var isJs = ts.isInJSFile(node);
68779
+ var parameters = new ts.Set();
68780
+ var excludedParameters = new ts.Set();
68781
+ ts.forEach(node.parameters, function (_a, index) {
68782
+ var name = _a.name;
68783
+ if (ts.isIdentifier(name)) {
68784
+ parameters.add(name.escapedText);
68785
+ }
68786
+ if (ts.isBindingPattern(name)) {
68787
+ excludedParameters.add(index);
68788
+ }
68789
+ });
68790
+ var containsArguments = containsArgumentsReference(node);
68791
+ if (containsArguments) {
68792
+ var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
68793
+ if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
68794
+ lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
68795
+ errorOrSuggestion(isJs, lastJSDocParam.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(lastJSDocParam.name));
68796
+ }
68797
+ }
68798
+ else {
68799
+ ts.forEach(jsdocParameters, function (_a, index) {
68800
+ var name = _a.name;
68801
+ if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
68802
+ return;
68803
+ }
68804
+ if (ts.isQualifiedName(name)) {
68805
+ errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
68806
+ }
68807
+ else {
68808
+ errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
68809
+ }
68810
+ });
68811
+ }
68812
+ }
68713
68813
  function checkTypeParameters(typeParameterDeclarations) {
68714
68814
  if (typeParameterDeclarations) {
68715
68815
  var seenDefault = false;
@@ -69787,6 +69887,9 @@ var ts;
69787
69887
  var name = ts.idText(node.kind === 269 ? node.propertyName || node.name : node.name);
69788
69888
  addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name);
69789
69889
  }
69890
+ if (isType && node.kind === 264 && ts.hasEffectiveModifier(node, 1)) {
69891
+ error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided);
69892
+ }
69790
69893
  break;
69791
69894
  }
69792
69895
  case 274: {
@@ -71611,13 +71714,13 @@ var ts;
71611
71714
  var fileToDirective;
71612
71715
  if (resolvedTypeReferenceDirectives) {
71613
71716
  fileToDirective = new ts.Map();
71614
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
71717
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
71615
71718
  if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
71616
71719
  return;
71617
71720
  }
71618
71721
  var file = host.getSourceFile(resolvedDirective.resolvedFileName);
71619
71722
  if (file) {
71620
- addReferencedFilesToTypeDirective(file, key);
71723
+ addReferencedFilesToTypeDirective(file, key, mode);
71621
71724
  }
71622
71725
  });
71623
71726
  }
@@ -71795,16 +71898,16 @@ var ts;
71795
71898
  }
71796
71899
  return false;
71797
71900
  }
71798
- function addReferencedFilesToTypeDirective(file, key) {
71901
+ function addReferencedFilesToTypeDirective(file, key, mode) {
71799
71902
  if (fileToDirective.has(file.path))
71800
71903
  return;
71801
- fileToDirective.set(file.path, key);
71904
+ fileToDirective.set(file.path, [key, mode]);
71802
71905
  for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
71803
- var fileName = _a[_i].fileName;
71906
+ var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
71804
71907
  var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
71805
71908
  var referencedFile = host.getSourceFile(resolvedFile);
71806
71909
  if (referencedFile) {
71807
- addReferencedFilesToTypeDirective(referencedFile, key);
71910
+ addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
71808
71911
  }
71809
71912
  }
71810
71913
  }
@@ -73395,25 +73498,24 @@ var ts;
73395
73498
  }
73396
73499
  function findMostOverlappyType(source, unionTarget) {
73397
73500
  var bestMatch;
73398
- var matchingCount = 0;
73399
- for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
73400
- var target = _a[_i];
73401
- var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
73402
- if (overlap.flags & 4194304) {
73403
- bestMatch = target;
73404
- matchingCount = Infinity;
73405
- }
73406
- else if (overlap.flags & 1048576) {
73407
- var len = ts.length(ts.filter(overlap.types, isUnitType));
73408
- if (len >= matchingCount) {
73409
- bestMatch = target;
73410
- matchingCount = len;
73501
+ if (!(source.flags & (131068 | 406847488))) {
73502
+ var matchingCount = 0;
73503
+ for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
73504
+ var target = _a[_i];
73505
+ if (!(target.flags & (131068 | 406847488))) {
73506
+ var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
73507
+ if (overlap.flags & 4194304) {
73508
+ return target;
73509
+ }
73510
+ else if (isUnitType(overlap) || overlap.flags & 1048576) {
73511
+ var len = overlap.flags & 1048576 ? ts.countWhere(overlap.types, isUnitType) : 1;
73512
+ if (len >= matchingCount) {
73513
+ bestMatch = target;
73514
+ matchingCount = len;
73515
+ }
73516
+ }
73411
73517
  }
73412
73518
  }
73413
- else if (isUnitType(overlap) && 1 >= matchingCount) {
73414
- bestMatch = target;
73415
- matchingCount = 1;
73416
- }
73417
73519
  }
73418
73520
  return bestMatch;
73419
73521
  }
@@ -87097,7 +87199,7 @@ var ts;
87097
87199
  var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
87098
87200
  hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
87099
87201
  collectReferences(sourceFile, refs);
87100
- recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
87202
+ recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
87101
87203
  collectLibs(sourceFile, libs);
87102
87204
  return sourceFile;
87103
87205
  }
@@ -87151,9 +87253,10 @@ var ts;
87151
87253
  return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
87152
87254
  }
87153
87255
  function getFileReferencesForUsedTypeReferences() {
87154
- return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
87256
+ return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
87155
87257
  }
87156
- function getFileReferenceForTypeName(typeName) {
87258
+ function getFileReferenceForSpecifierModeTuple(_a) {
87259
+ var typeName = _a[0], mode = _a[1];
87157
87260
  if (emittedImports) {
87158
87261
  for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
87159
87262
  var importStatement = emittedImports_1[_i];
@@ -87168,7 +87271,7 @@ var ts;
87168
87271
  }
87169
87272
  }
87170
87273
  }
87171
- return { fileName: typeName, pos: -1, end: -1 };
87274
+ return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
87172
87275
  }
87173
87276
  function mapReferencesIntoArray(references, outputFilePath) {
87174
87277
  return function (file) {
@@ -87185,7 +87288,7 @@ var ts;
87185
87288
  if (declFileName) {
87186
87289
  var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host);
87187
87290
  if (!ts.pathIsRelative(specifier)) {
87188
- recordTypeReferenceDirectivesIfNecessary([specifier]);
87291
+ recordTypeReferenceDirectivesIfNecessary([[specifier, undefined]]);
87189
87292
  return;
87190
87293
  }
87191
87294
  var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
@@ -91820,9 +91923,12 @@ var ts;
91820
91923
  for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
91821
91924
  var directive = types_24[_d];
91822
91925
  var pos = writer.getTextPos();
91823
- writeComment("/// <reference types=\"" + directive.fileName + "\" />");
91926
+ var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
91927
+ ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
91928
+ : "";
91929
+ writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
91824
91930
  if (bundleFileInfo)
91825
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
91931
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" : "type-require", data: directive.fileName });
91826
91932
  writeLine();
91827
91933
  }
91828
91934
  for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
@@ -94128,7 +94234,7 @@ var ts;
94128
94234
  return result;
94129
94235
  }
94130
94236
  ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
94131
- function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
94237
+ function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
94132
94238
  if (names.length === 0) {
94133
94239
  return [];
94134
94240
  }
@@ -94137,18 +94243,25 @@ var ts;
94137
94243
  for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
94138
94244
  var name = names_2[_i];
94139
94245
  var result = void 0;
94140
- if (cache.has(name)) {
94141
- result = cache.get(name);
94246
+ var mode = getModeForFileReference(name, containingFileMode);
94247
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
94248
+ var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
94249
+ if (cache.has(cacheKey)) {
94250
+ result = cache.get(cacheKey);
94142
94251
  }
94143
94252
  else {
94144
- cache.set(name, result = loader(name, containingFile, redirectedReference));
94253
+ cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
94145
94254
  }
94146
94255
  resolutions.push(result);
94147
94256
  }
94148
94257
  return resolutions;
94149
94258
  }
94150
- ts.loadWithLocalCache = loadWithLocalCache;
94259
+ ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
94151
94260
  ;
94261
+ function getModeForFileReference(ref, containingFileMode) {
94262
+ return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
94263
+ }
94264
+ ts.getModeForFileReference = getModeForFileReference;
94152
94265
  function getModeForResolutionAtIndex(file, index) {
94153
94266
  if (file.impliedNodeFormat === undefined)
94154
94267
  return undefined;
@@ -94237,7 +94350,7 @@ var ts;
94237
94350
  var _d, _e, _f, _g;
94238
94351
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
94239
94352
  var kind = ref.kind, index = ref.index;
94240
- var pos, end, packageId;
94353
+ var pos, end, packageId, resolutionMode;
94241
94354
  switch (kind) {
94242
94355
  case ts.FileIncludeKind.Import:
94243
94356
  var importLiteral = getModuleNameStringLiteralAt(file, index);
@@ -94251,8 +94364,8 @@ var ts;
94251
94364
  (_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
94252
94365
  break;
94253
94366
  case ts.FileIncludeKind.TypeReferenceDirective:
94254
- (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
94255
- packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
94367
+ (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
94368
+ packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId;
94256
94369
  break;
94257
94370
  case ts.FileIncludeKind.LibReferenceDirective:
94258
94371
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -94458,7 +94571,7 @@ var ts;
94458
94571
  var fileReasons = ts.createMultiMap();
94459
94572
  var cachedBindAndCheckDiagnosticsForFile = {};
94460
94573
  var cachedDeclarationDiagnosticsForFile = {};
94461
- var resolvedTypeReferenceDirectives = new ts.Map();
94574
+ var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
94462
94575
  var fileProcessingDiagnostics;
94463
94576
  var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
94464
94577
  var currentNodeModulesDepth = 0;
@@ -94499,12 +94612,12 @@ var ts;
94499
94612
  }
94500
94613
  var actualResolveTypeReferenceDirectiveNamesWorker;
94501
94614
  if (host.resolveTypeReferenceDirectives) {
94502
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
94615
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
94503
94616
  }
94504
94617
  else {
94505
94618
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
94506
- var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
94507
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
94619
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; };
94620
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
94508
94621
  }
94509
94622
  var packageIdToSourceFile = new ts.Map();
94510
94623
  var sourceFileToPackageName = new ts.Map();
@@ -94583,7 +94696,7 @@ var ts;
94583
94696
  var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
94584
94697
  var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
94585
94698
  for (var i = 0; i < typeReferences.length; i++) {
94586
- processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
94699
+ processTypeReferenceDirective(typeReferences[i], undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
94587
94700
  }
94588
94701
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
94589
94702
  }
@@ -94731,9 +94844,10 @@ var ts;
94731
94844
  return [];
94732
94845
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
94733
94846
  var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
94847
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
94734
94848
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
94735
94849
  ts.performance.mark("beforeResolveTypeReference");
94736
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
94850
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
94737
94851
  ts.performance.mark("afterResolveTypeReference");
94738
94852
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
94739
94853
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -95035,7 +95149,7 @@ var ts;
95035
95149
  else {
95036
95150
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
95037
95151
  }
95038
- var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
95152
+ var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
95039
95153
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
95040
95154
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
95041
95155
  if (typeReferenceResolutionsChanged) {
@@ -95986,7 +96100,7 @@ var ts;
95986
96100
  });
95987
96101
  }
95988
96102
  function processTypeReferenceDirectives(file) {
95989
- var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
96103
+ var typeDirectives = file.typeReferenceDirectives;
95990
96104
  if (!typeDirectives) {
95991
96105
  return;
95992
96106
  }
@@ -95996,16 +96110,20 @@ var ts;
95996
96110
  var resolvedTypeReferenceDirective = resolutions[index];
95997
96111
  var fileName = ts.toFileNameLowerCase(ref.fileName);
95998
96112
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
95999
- processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
96113
+ var mode = ref.resolutionMode || file.impliedNodeFormat;
96114
+ if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
96115
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
96116
+ }
96117
+ processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
96000
96118
  }
96001
96119
  }
96002
- function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
96120
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
96003
96121
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
96004
- processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
96122
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
96005
96123
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
96006
96124
  }
96007
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
96008
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
96125
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
96126
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
96009
96127
  if (previousResolution && previousResolution.primary) {
96010
96128
  return;
96011
96129
  }
@@ -96038,7 +96156,7 @@ var ts;
96038
96156
  addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
96039
96157
  }
96040
96158
  if (saveResolution) {
96041
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
96159
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
96042
96160
  }
96043
96161
  }
96044
96162
  function pathForLibFile(libFileName) {
@@ -98447,9 +98565,9 @@ var ts;
98447
98565
  });
98448
98566
  hasChangedAutomaticTypeDirectiveNames = false;
98449
98567
  }
98450
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
98568
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
98451
98569
  var _a;
98452
- var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
98570
+ var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
98453
98571
  if (!resolutionHost.getGlobalCache) {
98454
98572
  return primaryResult;
98455
98573
  }
@@ -98464,12 +98582,12 @@ var ts;
98464
98582
  }
98465
98583
  return primaryResult;
98466
98584
  }
98467
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
98468
- return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
98585
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
98586
+ return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
98469
98587
  }
98470
98588
  function resolveNamesWithLocalCache(_a) {
98471
98589
  var _b, _c, _d;
98472
- var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
98590
+ var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
98473
98591
  var path = resolutionHost.toPath(containingFile);
98474
98592
  var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
98475
98593
  var dirPath = ts.getDirectoryPath(path);
@@ -98490,8 +98608,10 @@ var ts;
98490
98608
  var seenNamesInFile = ts.createModeAwareCache();
98491
98609
  var i = 0;
98492
98610
  for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
98493
- var name = names_4[_i];
98494
- var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
98611
+ var entry = names_4[_i];
98612
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
98613
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
98614
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
98495
98615
  i++;
98496
98616
  var resolution = resolutionsInFile.get(name, mode);
98497
98617
  if (!seenNamesInFile.has(name, mode) &&
@@ -98518,7 +98638,7 @@ var ts;
98518
98638
  }
98519
98639
  }
98520
98640
  else {
98521
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
98641
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
98522
98642
  perDirectoryResolution.set(name, mode, resolution);
98523
98643
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
98524
98644
  resolutionHost.onDiscoveredSymlink();
@@ -98580,7 +98700,7 @@ var ts;
98580
98700
  return oldResult.resolvedFileName === newResult.resolvedFileName;
98581
98701
  }
98582
98702
  }
98583
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
98703
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
98584
98704
  return resolveNamesWithLocalCache({
98585
98705
  names: typeDirectiveNames,
98586
98706
  containingFile: containingFile,
@@ -98590,6 +98710,7 @@ var ts;
98590
98710
  loader: resolveTypeReferenceDirective,
98591
98711
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
98592
98712
  shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
98713
+ containingSourceFileMode: containingFileMode
98593
98714
  });
98594
98715
  }
98595
98716
  function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
@@ -100281,7 +100402,7 @@ var ts;
100281
100402
  }
100282
100403
  return host.resolveTypeReferenceDirectives.apply(host, args);
100283
100404
  }) :
100284
- (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
100405
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
100285
100406
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
100286
100407
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
100287
100408
  synchronizeProgram();
@@ -100935,9 +101056,9 @@ var ts;
100935
101056
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
100936
101057
  }
100937
101058
  if (!compilerHost.resolveTypeReferenceDirectives) {
100938
- var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
100939
- compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
100940
- return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4);
101059
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
101060
+ compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
101061
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
100941
101062
  };
100942
101063
  }
100943
101064
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;