typescript 4.7.0-dev.20220215 → 4.7.0-dev.20220219

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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220215";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220219";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -2412,7 +2412,7 @@ var ts;
2412
2412
  Debug.checkEachDefined = checkEachDefined;
2413
2413
  function assertNever(member, message, stackCrawlMark) {
2414
2414
  if (message === void 0) { message = "Illegal value:"; }
2415
- var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2415
+ var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
2416
2416
  return fail(message + " " + detail, stackCrawlMark || assertNever);
2417
2417
  }
2418
2418
  Debug.assertNever = assertNever;
@@ -4829,6 +4829,8 @@ var ts;
4829
4829
  TypeFlags[TypeFlags["ESSymbolLike"] = 12288] = "ESSymbolLike";
4830
4830
  TypeFlags[TypeFlags["VoidLike"] = 49152] = "VoidLike";
4831
4831
  /* @internal */
4832
+ TypeFlags[TypeFlags["DefinitelyNonNullable"] = 470302716] = "DefinitelyNonNullable";
4833
+ /* @internal */
4832
4834
  TypeFlags[TypeFlags["DisjointDomains"] = 469892092] = "DisjointDomains";
4833
4835
  TypeFlags[TypeFlags["UnionOrIntersection"] = 3145728] = "UnionOrIntersection";
4834
4836
  TypeFlags[TypeFlags["StructuredType"] = 3670016] = "StructuredType";
@@ -4907,13 +4909,14 @@ var ts;
4907
4909
  // Flags that require TypeFlags.Object
4908
4910
  ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
4909
4911
  ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
4912
+ ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
4910
4913
  /* @internal */
4911
- ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
4914
+ ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 33554432] = "IsClassInstanceClone";
4912
4915
  // Flags that require TypeFlags.Object and ObjectFlags.Reference
4913
4916
  /* @internal */
4914
- ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
4917
+ ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 67108864] = "IdenticalBaseTypeCalculated";
4915
4918
  /* @internal */
4916
- ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
4919
+ ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 134217728] = "IdenticalBaseTypeExists";
4917
4920
  // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
4918
4921
  /* @internal */
4919
4922
  ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
@@ -5561,6 +5564,8 @@ var ts;
5561
5564
  BundleFileSectionKind["NoDefaultLib"] = "no-default-lib";
5562
5565
  BundleFileSectionKind["Reference"] = "reference";
5563
5566
  BundleFileSectionKind["Type"] = "type";
5567
+ BundleFileSectionKind["TypeResolutionModeRequire"] = "type-require";
5568
+ BundleFileSectionKind["TypeResolutionModeImport"] = "type-import";
5564
5569
  BundleFileSectionKind["Lib"] = "lib";
5565
5570
  BundleFileSectionKind["Prepend"] = "prepend";
5566
5571
  BundleFileSectionKind["Text"] = "text";
@@ -5677,7 +5682,8 @@ var ts;
5677
5682
  { name: "types", optional: true, captureSpan: true },
5678
5683
  { name: "lib", optional: true, captureSpan: true },
5679
5684
  { name: "path", optional: true, captureSpan: true },
5680
- { name: "no-default-lib", optional: true }
5685
+ { name: "no-default-lib", optional: true },
5686
+ { name: "resolution-mode", optional: true }
5681
5687
  ],
5682
5688
  kind: 1 /* TripleSlashXML */
5683
5689
  },
@@ -8058,6 +8064,8 @@ var ts;
8058
8064
  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."),
8059
8065
  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."),
8060
8066
  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."),
8067
+ 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}'."),
8068
+ 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'."),
8061
8069
  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."),
8062
8070
  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."),
8063
8071
  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."),
@@ -8126,7 +8134,6 @@ var ts;
8126
8134
  Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
8127
8135
  Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"),
8128
8136
  Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
8129
- A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
8130
8137
  Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
8131
8138
  Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
8132
8139
  Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
@@ -8191,6 +8198,8 @@ var ts;
8191
8198
  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."),
8192
8199
  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"),
8193
8200
  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"),
8201
+ 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`."),
8202
+ 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`."),
8194
8203
  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."),
8195
8204
  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."),
8196
8205
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
@@ -8510,6 +8519,7 @@ var ts;
8510
8519
  Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."),
8511
8520
  JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"),
8512
8521
  _0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
8522
+ Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
8513
8523
  Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
8514
8524
  A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
8515
8525
  Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
@@ -9555,7 +9565,7 @@ var ts;
9555
9565
  Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
9556
9566
  Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"),
9557
9567
  Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"),
9558
- Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"),
9568
+ Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig to read more about this file"),
9559
9569
  Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
9560
9570
  Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
9561
9571
  Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"),
@@ -13401,6 +13411,7 @@ var ts;
13401
13411
  case 110 /* TrueKeyword */:
13402
13412
  case 106 /* SuperKeyword */:
13403
13413
  case 229 /* NonNullExpression */:
13414
+ case 227 /* ExpressionWithTypeArguments */:
13404
13415
  case 230 /* MetaProperty */:
13405
13416
  case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
13406
13417
  return true;
@@ -14074,7 +14085,11 @@ var ts;
14074
14085
  ts.Debug.assert(names.length === newResolutions.length);
14075
14086
  for (var i = 0; i < names.length; i++) {
14076
14087
  var newResolution = newResolutions[i];
14077
- var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
14088
+ var entry = names[i];
14089
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
14090
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
14091
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.impliedNodeFormat) : oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i);
14092
+ var oldResolution = oldResolutions && oldResolutions.get(name, mode);
14078
14093
  var changed = oldResolution
14079
14094
  ? !newResolution || !comparer(oldResolution, newResolution)
14080
14095
  : newResolution;
@@ -15110,7 +15125,7 @@ var ts;
15110
15125
  case 114 /* VoidKeyword */:
15111
15126
  return node.parent.kind !== 216 /* VoidExpression */;
15112
15127
  case 227 /* ExpressionWithTypeArguments */:
15113
- return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
15128
+ return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
15114
15129
  case 162 /* TypeParameter */:
15115
15130
  return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
15116
15131
  // Identifiers and qualified names may be type nodes, depending on their context. Climb
@@ -15147,7 +15162,7 @@ var ts;
15147
15162
  }
15148
15163
  switch (parent.kind) {
15149
15164
  case 227 /* ExpressionWithTypeArguments */:
15150
- return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
15165
+ return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
15151
15166
  case 162 /* TypeParameter */:
15152
15167
  return node === parent.constraint;
15153
15168
  case 342 /* JSDocTemplateTag */:
@@ -15850,7 +15865,7 @@ var ts;
15850
15865
  case 296 /* SpreadAssignment */:
15851
15866
  return true;
15852
15867
  case 227 /* ExpressionWithTypeArguments */:
15853
- return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
15868
+ return parent.expression === node && !isPartOfTypeNode(parent);
15854
15869
  case 295 /* ShorthandPropertyAssignment */:
15855
15870
  return parent.objectAssignmentInitializer === node;
15856
15871
  default:
@@ -22837,16 +22852,18 @@ var ts;
22837
22852
  return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
22838
22853
  }
22839
22854
  // @api
22840
- function createTypeQueryNode(exprName) {
22855
+ function createTypeQueryNode(exprName, typeArguments) {
22841
22856
  var node = createBaseNode(180 /* TypeQuery */);
22842
22857
  node.exprName = exprName;
22858
+ node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
22843
22859
  node.transformFlags = 1 /* ContainsTypeScript */;
22844
22860
  return node;
22845
22861
  }
22846
22862
  // @api
22847
- function updateTypeQueryNode(node, exprName) {
22863
+ function updateTypeQueryNode(node, exprName, typeArguments) {
22848
22864
  return node.exprName !== exprName
22849
- ? update(createTypeQueryNode(exprName), node)
22865
+ || node.typeArguments !== typeArguments
22866
+ ? update(createTypeQueryNode(exprName, typeArguments), node)
22850
22867
  : node;
22851
22868
  }
22852
22869
  // @api
@@ -26669,7 +26686,13 @@ var ts;
26669
26686
  referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
26670
26687
  break;
26671
26688
  case "type" /* Type */:
26672
- typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
26689
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
26690
+ break;
26691
+ case "type-import" /* TypeResolutionModeImport */:
26692
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext });
26693
+ break;
26694
+ case "type-require" /* TypeResolutionModeRequire */:
26695
+ typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS });
26673
26696
  break;
26674
26697
  case "lib" /* Lib */:
26675
26698
  libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
@@ -26728,6 +26751,8 @@ var ts;
26728
26751
  case "no-default-lib" /* NoDefaultLib */:
26729
26752
  case "reference" /* Reference */:
26730
26753
  case "type" /* Type */:
26754
+ case "type-import" /* TypeResolutionModeImport */:
26755
+ case "type-require" /* TypeResolutionModeRequire */:
26731
26756
  case "lib" /* Lib */:
26732
26757
  syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
26733
26758
  break;
@@ -29962,7 +29987,8 @@ var ts;
29962
29987
  visitNode(cbNode, node.parameterName) ||
29963
29988
  visitNode(cbNode, node.type);
29964
29989
  case 180 /* TypeQuery */:
29965
- return visitNode(cbNode, node.exprName);
29990
+ return visitNode(cbNode, node.exprName) ||
29991
+ visitNodes(cbNode, cbNodes, node.typeArguments);
29966
29992
  case 181 /* TypeLiteral */:
29967
29993
  return visitNodes(cbNode, cbNodes, node.members);
29968
29994
  case 182 /* ArrayType */:
@@ -30641,7 +30667,7 @@ var ts;
30641
30667
  initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
30642
30668
  // Prime the scanner.
30643
30669
  nextToken();
30644
- var entityName = parseEntityName(/*allowReservedWords*/ true);
30670
+ var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
30645
30671
  var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
30646
30672
  clearState();
30647
30673
  return isInvalid ? entityName : undefined;
@@ -32218,7 +32244,7 @@ var ts;
32218
32244
  }
32219
32245
  return createMissingList();
32220
32246
  }
32221
- function parseEntityName(allowReservedWords, diagnosticMessage) {
32247
+ function parseEntityName(allowReservedWords, allowPrivateIdentifiers, diagnosticMessage) {
32222
32248
  var pos = getNodePos();
32223
32249
  var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
32224
32250
  var dotPos = getNodePos();
@@ -32229,7 +32255,7 @@ var ts;
32229
32255
  break;
32230
32256
  }
32231
32257
  dotPos = getNodePos();
32232
- entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos);
32258
+ entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
32233
32259
  }
32234
32260
  return entity;
32235
32261
  }
@@ -32362,7 +32388,7 @@ var ts;
32362
32388
  }
32363
32389
  // TYPES
32364
32390
  function parseEntityNameOfTypeReference() {
32365
- return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
32391
+ return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, ts.Diagnostics.Type_expected);
32366
32392
  }
32367
32393
  function parseTypeArgumentsOfTypeReference() {
32368
32394
  if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
@@ -32495,7 +32521,9 @@ var ts;
32495
32521
  function parseTypeQuery() {
32496
32522
  var pos = getNodePos();
32497
32523
  parseExpected(112 /* TypeOfKeyword */);
32498
- return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true)), pos);
32524
+ var entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
32525
+ var typeArguments = tryParseTypeArguments();
32526
+ return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
32499
32527
  }
32500
32528
  function parseTypeParameter() {
32501
32529
  var pos = getNodePos();
@@ -34565,20 +34593,30 @@ var ts;
34565
34593
  expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
34566
34594
  continue;
34567
34595
  }
34568
- if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
34569
- nextToken();
34570
- expression = finishNode(factory.createNonNullExpression(expression), pos);
34571
- continue;
34572
- }
34573
34596
  // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
34574
34597
  if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
34575
34598
  expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
34576
34599
  continue;
34577
34600
  }
34578
34601
  if (isTemplateStartOfTaggedTemplate()) {
34579
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
34602
+ // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
34603
+ expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
34604
+ parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
34605
+ parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
34580
34606
  continue;
34581
34607
  }
34608
+ if (!questionDotToken) {
34609
+ if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
34610
+ nextToken();
34611
+ expression = finishNode(factory.createNonNullExpression(expression), pos);
34612
+ continue;
34613
+ }
34614
+ var typeArguments = tryParse(parseTypeArgumentsInExpression);
34615
+ if (typeArguments) {
34616
+ expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
34617
+ continue;
34618
+ }
34619
+ }
34582
34620
  return expression;
34583
34621
  }
34584
34622
  }
@@ -34598,38 +34636,30 @@ var ts;
34598
34636
  function parseCallExpressionRest(pos, expression) {
34599
34637
  while (true) {
34600
34638
  expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
34639
+ var typeArguments = void 0;
34601
34640
  var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
34602
- // handle 'foo<<T>()'
34603
- // parse template arguments only in TypeScript files (not in JavaScript files).
34604
- if ((contextFlags & 131072 /* JavaScriptFile */) === 0 && (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */)) {
34605
- // See if this is the start of a generic invocation. If so, consume it and
34606
- // keep checking for postfix expressions. Otherwise, it's just a '<' that's
34607
- // part of an arithmetic expression. Break out so we consume it higher in the
34608
- // stack.
34609
- var typeArguments = tryParse(parseTypeArgumentsInExpression);
34610
- if (typeArguments) {
34611
- if (isTemplateStartOfTaggedTemplate()) {
34612
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
34613
- continue;
34614
- }
34615
- var argumentList = parseArgumentList();
34616
- var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
34617
- factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
34618
- factory.createCallExpression(expression, typeArguments, argumentList);
34619
- expression = finishNode(callExpr, pos);
34641
+ if (questionDotToken) {
34642
+ typeArguments = tryParse(parseTypeArgumentsInExpression);
34643
+ if (isTemplateStartOfTaggedTemplate()) {
34644
+ expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
34620
34645
  continue;
34621
34646
  }
34622
34647
  }
34623
- else if (token() === 20 /* OpenParenToken */) {
34648
+ if (typeArguments || token() === 20 /* OpenParenToken */) {
34649
+ // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
34650
+ if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
34651
+ typeArguments = expression.typeArguments;
34652
+ expression = expression.expression;
34653
+ }
34624
34654
  var argumentList = parseArgumentList();
34625
34655
  var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
34626
- factory.createCallChain(expression, questionDotToken, /*typeArguments*/ undefined, argumentList) :
34627
- factory.createCallExpression(expression, /*typeArguments*/ undefined, argumentList);
34656
+ factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
34657
+ factory.createCallExpression(expression, typeArguments, argumentList);
34628
34658
  expression = finishNode(callExpr, pos);
34629
34659
  continue;
34630
34660
  }
34631
34661
  if (questionDotToken) {
34632
- // We failed to parse anything, so report a missing identifier here.
34662
+ // We parsed `?.` but then failed to parse anything, so report a missing identifier here.
34633
34663
  var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
34634
34664
  expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
34635
34665
  }
@@ -34657,21 +34687,25 @@ var ts;
34657
34687
  // If it doesn't have the closing `>` then it's definitely not an type argument list.
34658
34688
  return undefined;
34659
34689
  }
34660
- // If we have a '<', then only parse this as a argument list if the type arguments
34661
- // are complete and we have an open paren. if we don't, rewind and return nothing.
34662
- return typeArguments && canFollowTypeArgumentsInExpression()
34663
- ? typeArguments
34664
- : undefined;
34690
+ // We successfully parsed a type argument list. The next token determines whether we want to
34691
+ // treat it as such. If the type argument list is followed by `(` or a template literal, as in
34692
+ // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
34693
+ // it as a relational expression.
34694
+ return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
34665
34695
  }
34666
34696
  function canFollowTypeArgumentsInExpression() {
34667
34697
  switch (token()) {
34698
+ // These tokens can follow a type argument list in a call expression.
34668
34699
  case 20 /* OpenParenToken */: // foo<x>(
34669
34700
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
34670
34701
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
34671
- // these are the only tokens can legally follow a type argument
34672
- // list. So we definitely want to treat them as type arg lists.
34702
+ // These tokens can't follow in a call expression, nor can they start an
34703
+ // expression. So, consider the type argument list part of an instantiation
34704
+ // expression.
34673
34705
  // falls through
34706
+ case 27 /* CommaToken */: // foo<x>,
34674
34707
  case 24 /* DotToken */: // foo<x>.
34708
+ case 28 /* QuestionDotToken */: // foo<x>?.
34675
34709
  case 21 /* CloseParenToken */: // foo<x>)
34676
34710
  case 23 /* CloseBracketToken */: // foo<x>]
34677
34711
  case 58 /* ColonToken */: // foo<x>:
@@ -34689,20 +34723,10 @@ var ts;
34689
34723
  case 51 /* BarToken */: // foo<x> |
34690
34724
  case 19 /* CloseBraceToken */: // foo<x> }
34691
34725
  case 1 /* EndOfFileToken */: // foo<x>
34692
- // these cases can't legally follow a type arg list. However, they're not legal
34693
- // expressions either. The user is probably in the middle of a generic type. So
34694
- // treat it as such.
34695
34726
  return true;
34696
- case 27 /* CommaToken */: // foo<x>,
34697
- case 18 /* OpenBraceToken */: // foo<x> {
34698
- // We don't want to treat these as type arguments. Otherwise we'll parse this
34699
- // as an invocation expression. Instead, we want to parse out the expression
34700
- // in isolation from the type arguments.
34701
- // falls through
34702
- default:
34703
- // Anything else treat as an expression.
34704
- return false;
34705
34727
  }
34728
+ // Treat anything else as an expression.
34729
+ return false;
34706
34730
  }
34707
34731
  function parsePrimaryExpression() {
34708
34732
  switch (token()) {
@@ -34883,26 +34907,15 @@ var ts;
34883
34907
  return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
34884
34908
  }
34885
34909
  var expressionPos = getNodePos();
34886
- var expression = parsePrimaryExpression();
34910
+ var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
34887
34911
  var typeArguments;
34888
- while (true) {
34889
- expression = parseMemberExpressionRest(expressionPos, expression, /*allowOptionalChain*/ false);
34890
- typeArguments = tryParse(parseTypeArgumentsInExpression);
34891
- if (isTemplateStartOfTaggedTemplate()) {
34892
- ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
34893
- expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
34894
- typeArguments = undefined;
34895
- }
34896
- break;
34912
+ // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
34913
+ if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
34914
+ typeArguments = expression.typeArguments;
34915
+ expression = expression.expression;
34897
34916
  }
34898
- var argumentsArray;
34899
- if (token() === 20 /* OpenParenToken */) {
34900
- argumentsArray = parseArgumentList();
34901
- }
34902
- else if (typeArguments) {
34903
- parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
34904
- }
34905
- return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
34917
+ var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
34918
+ return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
34906
34919
  }
34907
34920
  // STATEMENTS
34908
34921
  function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
@@ -35066,11 +35079,12 @@ var ts;
35066
35079
  }
35067
35080
  function parseCaseClause() {
35068
35081
  var pos = getNodePos();
35082
+ var hasJSDoc = hasPrecedingJSDocComment();
35069
35083
  parseExpected(82 /* CaseKeyword */);
35070
35084
  var expression = allowInAnd(parseExpression);
35071
35085
  parseExpected(58 /* ColonToken */);
35072
35086
  var statements = parseList(3 /* SwitchClauseStatements */, parseStatement);
35073
- return finishNode(factory.createCaseClause(expression, statements), pos);
35087
+ return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc);
35074
35088
  }
35075
35089
  function parseDefaultClause() {
35076
35090
  var pos = getNodePos();
@@ -35990,6 +36004,9 @@ var ts;
35990
36004
  function parseExpressionWithTypeArguments() {
35991
36005
  var pos = getNodePos();
35992
36006
  var expression = parseLeftHandSideExpressionOrHigher();
36007
+ if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
36008
+ return expression;
36009
+ }
35993
36010
  var typeArguments = tryParseTypeArguments();
35994
36011
  return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
35995
36012
  }
@@ -36233,7 +36250,7 @@ var ts;
36233
36250
  function parseModuleReference() {
36234
36251
  return isExternalModuleReference()
36235
36252
  ? parseExternalModuleReference()
36236
- : parseEntityName(/*allowReservedWords*/ false);
36253
+ : parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
36237
36254
  }
36238
36255
  function parseExternalModuleReference() {
36239
36256
  var pos = getNodePos();
@@ -36515,7 +36532,7 @@ var ts;
36515
36532
  var pos = getNodePos();
36516
36533
  var hasBrace = parseOptional(18 /* OpenBraceToken */);
36517
36534
  var p2 = getNodePos();
36518
- var entityName = parseEntityName(/* allowReservedWords*/ false);
36535
+ var entityName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
36519
36536
  while (token() === 80 /* PrivateIdentifier */) {
36520
36537
  reScanHashToken(); // rescan #id as # id
36521
36538
  nextTokenJSDoc(); // then skip the #
@@ -36958,7 +36975,7 @@ var ts;
36958
36975
  // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
36959
36976
  var p2 = getNodePos();
36960
36977
  var name = ts.tokenIsIdentifierOrKeyword(token())
36961
- ? parseEntityName(/*allowReservedWords*/ true)
36978
+ ? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
36962
36979
  : undefined;
36963
36980
  if (name) {
36964
36981
  while (token() === 80 /* PrivateIdentifier */) {
@@ -36983,11 +37000,13 @@ var ts;
36983
37000
  && nextTokenJSDoc() === 59 /* AtToken */
36984
37001
  && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) {
36985
37002
  var kind = scanner.getTokenValue();
36986
- if (kind === "link" || kind === "linkcode" || kind === "linkplain") {
37003
+ if (isJSDocLinkTag(kind))
36987
37004
  return kind;
36988
- }
36989
37005
  }
36990
37006
  }
37007
+ function isJSDocLinkTag(kind) {
37008
+ return kind === "link" || kind === "linkcode" || kind === "linkplain";
37009
+ }
36991
37010
  function parseUnknownTag(start, tagName, indent, indentText) {
36992
37011
  return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start);
36993
37012
  }
@@ -37093,7 +37112,7 @@ var ts;
37093
37112
  }
37094
37113
  function parseSeeTag(start, tagName, indent, indentText) {
37095
37114
  var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */
37096
- || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; });
37115
+ || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); });
37097
37116
  var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
37098
37117
  var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
37099
37118
  return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
@@ -37960,6 +37979,19 @@ var ts;
37960
37979
  return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
37961
37980
  }
37962
37981
  ts.isDeclarationFileName = isDeclarationFileName;
37982
+ function parseResolutionMode(mode, pos, end, reportDiagnostic) {
37983
+ if (!mode) {
37984
+ return undefined;
37985
+ }
37986
+ if (mode === "import") {
37987
+ return ts.ModuleKind.ESNext;
37988
+ }
37989
+ if (mode === "require") {
37990
+ return ts.ModuleKind.CommonJS;
37991
+ }
37992
+ reportDiagnostic(pos, end - pos, ts.Diagnostics.resolution_mode_should_be_either_require_or_import);
37993
+ return undefined;
37994
+ }
37963
37995
  /*@internal*/
37964
37996
  function processCommentPragmas(context, sourceText) {
37965
37997
  var pragmas = [];
@@ -38002,12 +38034,13 @@ var ts;
38002
38034
  var typeReferenceDirectives_1 = context.typeReferenceDirectives;
38003
38035
  var libReferenceDirectives_1 = context.libReferenceDirectives;
38004
38036
  ts.forEach(ts.toArray(entryOrList), function (arg) {
38005
- var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
38037
+ var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
38006
38038
  if (arg.arguments["no-default-lib"]) {
38007
38039
  context.hasNoDefaultLib = true;
38008
38040
  }
38009
38041
  else if (types) {
38010
- typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
38042
+ var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
38043
+ typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
38011
38044
  }
38012
38045
  else if (lib) {
38013
38046
  libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
@@ -40419,7 +40452,7 @@ var ts;
40419
40452
  var result = [];
40420
40453
  result.push("{");
40421
40454
  result.push(tab + "\"compilerOptions\": {");
40422
- result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
40455
+ result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */");
40423
40456
  result.push("");
40424
40457
  // Print out each row, aligning all the descriptions on the same column.
40425
40458
  for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
@@ -41585,14 +41618,14 @@ var ts;
41585
41618
  * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
41586
41619
  * is assumed to be the same as root directory of the project.
41587
41620
  */
41588
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) {
41621
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
41589
41622
  var traceEnabled = isTraceEnabled(options, host);
41590
41623
  if (redirectedReference) {
41591
41624
  options = redirectedReference.commandLine.options;
41592
41625
  }
41593
41626
  var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
41594
41627
  var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
41595
- var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
41628
+ var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ resolutionMode);
41596
41629
  if (result) {
41597
41630
  if (traceEnabled) {
41598
41631
  trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
@@ -41627,7 +41660,18 @@ var ts;
41627
41660
  }
41628
41661
  var failedLookupLocations = [];
41629
41662
  var features = getDefaultNodeResolutionFeatures(options);
41630
- var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
41663
+ // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution
41664
+ // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being
41665
+ // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports
41666
+ // are present in a non-modal project; while in theory we'd like to either ignore the mode or provide faithful modern resolution, depending on what we feel is best,
41667
+ // in practice, not every cache has the options available to intelligently make the choice to ignore the mode request, and it's unclear how modern "faithful modern
41668
+ // resolution" should be (`node12`? `nodenext`?). As such, witnessing a mode-overriding triple-slash reference in a non-modal module resolution
41669
+ // context should _probably_ be an error - and that should likely be handled by the `Program` (which is what we do).
41670
+ if (resolutionMode === ts.ModuleKind.ESNext && (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext)) {
41671
+ features |= NodeResolutionFeatures.EsmMode;
41672
+ }
41673
+ var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
41674
+ var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: conditions };
41631
41675
  var resolved = primaryLookup();
41632
41676
  var primary = true;
41633
41677
  if (!resolved) {
@@ -41647,7 +41691,7 @@ var ts;
41647
41691
  };
41648
41692
  }
41649
41693
  result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
41650
- perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
41694
+ perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
41651
41695
  if (traceEnabled)
41652
41696
  traceResult(result);
41653
41697
  return result;
@@ -41933,7 +41977,11 @@ var ts;
41933
41977
  ts.Debug.assert(keys.length === values.length);
41934
41978
  var map = createModeAwareCache();
41935
41979
  for (var i = 0; i < keys.length; ++i) {
41936
- map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
41980
+ var entry = keys[i];
41981
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
41982
+ var name = !ts.isString(entry) ? entry.fileName.toLowerCase() : entry;
41983
+ var mode = !ts.isString(entry) ? entry.resolutionMode || file.impliedNodeFormat : ts.getModeForResolutionAtIndex(file, i);
41984
+ map.set(name, mode, values[i]);
41937
41985
  }
41938
41986
  return map;
41939
41987
  }
@@ -46953,8 +47001,7 @@ var ts;
46953
47001
  IntersectionState[IntersectionState["Source"] = 1] = "Source";
46954
47002
  IntersectionState[IntersectionState["Target"] = 2] = "Target";
46955
47003
  IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
46956
- IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
46957
- IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
47004
+ IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
46958
47005
  })(IntersectionState || (IntersectionState = {}));
46959
47006
  var RecursionFlags;
46960
47007
  (function (RecursionFlags) {
@@ -50968,7 +51015,7 @@ var ts;
50968
51015
  // get symbol of the first identifier of the entityName
50969
51016
  var meaning;
50970
51017
  if (entityName.parent.kind === 180 /* TypeQuery */ ||
50971
- ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
51018
+ entityName.parent.kind === 227 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
50972
51019
  entityName.parent.kind === 161 /* ComputedPropertyName */) {
50973
51020
  // Typeof value
50974
51021
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
@@ -51079,7 +51126,7 @@ var ts;
51079
51126
  return flags & 814775659 /* NodeBuilderFlagsMask */;
51080
51127
  }
51081
51128
  function isClassInstanceSide(type) {
51082
- return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */)));
51129
+ return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 33554432 /* IsClassInstanceClone */)));
51083
51130
  }
51084
51131
  function createNodeBuilder() {
51085
51132
  return {
@@ -55008,7 +55055,7 @@ var ts;
55008
55055
  members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
55009
55056
  result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
55010
55057
  if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
55011
- result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
55058
+ result.objectFlags |= 33554432 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
55012
55059
  }
55013
55060
  return result;
55014
55061
  }
@@ -57054,87 +57101,87 @@ var ts;
57054
57101
  * Converts an AnonymousType to a ResolvedType.
57055
57102
  */
57056
57103
  function resolveAnonymousTypeMembers(type) {
57057
- var symbol = getMergedSymbol(type.symbol);
57058
57104
  if (type.target) {
57059
57105
  setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
57060
- var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
57106
+ var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
57061
57107
  var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
57062
57108
  var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
57063
- var indexInfos = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
57064
- setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
57109
+ var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
57110
+ setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
57111
+ return;
57065
57112
  }
57066
- else if (symbol.flags & 2048 /* TypeLiteral */) {
57113
+ var symbol = getMergedSymbol(type.symbol);
57114
+ if (symbol.flags & 2048 /* TypeLiteral */) {
57067
57115
  setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
57068
- var members = getMembersOfSymbol(symbol);
57069
- var callSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */));
57070
- var constructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */));
57071
- var indexInfos = getIndexInfosOfSymbol(symbol);
57072
- setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
57116
+ var members_7 = getMembersOfSymbol(symbol);
57117
+ var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */));
57118
+ var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */));
57119
+ var indexInfos_2 = getIndexInfosOfSymbol(symbol);
57120
+ setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
57121
+ return;
57073
57122
  }
57074
- else {
57075
- // Combinations of function, class, enum and module
57076
- var members = emptySymbols;
57077
- var indexInfos = void 0;
57078
- if (symbol.exports) {
57079
- members = getExportsOfSymbol(symbol);
57080
- if (symbol === globalThisSymbol) {
57081
- var varsOnly_1 = new ts.Map();
57082
- members.forEach(function (p) {
57083
- if (!(p.flags & 418 /* BlockScoped */)) {
57084
- varsOnly_1.set(p.escapedName, p);
57085
- }
57086
- });
57087
- members = varsOnly_1;
57088
- }
57123
+ // Combinations of function, class, enum and module
57124
+ var members = emptySymbols;
57125
+ var indexInfos;
57126
+ if (symbol.exports) {
57127
+ members = getExportsOfSymbol(symbol);
57128
+ if (symbol === globalThisSymbol) {
57129
+ var varsOnly_1 = new ts.Map();
57130
+ members.forEach(function (p) {
57131
+ if (!(p.flags & 418 /* BlockScoped */)) {
57132
+ varsOnly_1.set(p.escapedName, p);
57133
+ }
57134
+ });
57135
+ members = varsOnly_1;
57089
57136
  }
57090
- var baseConstructorIndexInfo = void 0;
57091
- setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
57092
- if (symbol.flags & 32 /* Class */) {
57093
- var classType = getDeclaredTypeOfClassOrInterface(symbol);
57094
- var baseConstructorType = getBaseConstructorTypeOfClass(classType);
57095
- if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
57096
- members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
57097
- addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
57098
- }
57099
- else if (baseConstructorType === anyType) {
57100
- baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
57101
- }
57137
+ }
57138
+ var baseConstructorIndexInfo;
57139
+ setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
57140
+ if (symbol.flags & 32 /* Class */) {
57141
+ var classType = getDeclaredTypeOfClassOrInterface(symbol);
57142
+ var baseConstructorType = getBaseConstructorTypeOfClass(classType);
57143
+ if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
57144
+ members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
57145
+ addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
57102
57146
  }
57103
- var indexSymbol = getIndexSymbolFromSymbolTable(members);
57104
- if (indexSymbol) {
57105
- indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
57147
+ else if (baseConstructorType === anyType) {
57148
+ baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
57106
57149
  }
57107
- else {
57108
- if (baseConstructorIndexInfo) {
57109
- indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
57110
- }
57111
- if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
57112
- ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
57113
- indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
57114
- }
57150
+ }
57151
+ var indexSymbol = getIndexSymbolFromSymbolTable(members);
57152
+ if (indexSymbol) {
57153
+ indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
57154
+ }
57155
+ else {
57156
+ if (baseConstructorIndexInfo) {
57157
+ indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
57115
57158
  }
57116
- setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
57117
- // We resolve the members before computing the signatures because a signature may use
57118
- // typeof with a qualified name expression that circularly references the type we are
57119
- // in the process of resolving (see issue #6072). The temporarily empty signature list
57120
- // will never be observed because a qualified name can't reference signatures.
57121
- if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
57122
- type.callSignatures = getSignaturesOfSymbol(symbol);
57159
+ if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
57160
+ ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
57161
+ indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
57123
57162
  }
57124
- // And likewise for construct signatures for classes
57125
- if (symbol.flags & 32 /* Class */) {
57126
- var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
57127
- var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
57128
- if (symbol.flags & 16 /* Function */) {
57129
- constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
57130
- createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
57131
- undefined; }));
57132
- }
57133
- if (!constructSignatures.length) {
57134
- constructSignatures = getDefaultConstructSignatures(classType_1);
57135
- }
57136
- type.constructSignatures = constructSignatures;
57163
+ }
57164
+ setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
57165
+ // We resolve the members before computing the signatures because a signature may use
57166
+ // typeof with a qualified name expression that circularly references the type we are
57167
+ // in the process of resolving (see issue #6072). The temporarily empty signature list
57168
+ // will never be observed because a qualified name can't reference signatures.
57169
+ if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
57170
+ type.callSignatures = getSignaturesOfSymbol(symbol);
57171
+ }
57172
+ // And likewise for construct signatures for classes
57173
+ if (symbol.flags & 32 /* Class */) {
57174
+ var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
57175
+ var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
57176
+ if (symbol.flags & 16 /* Function */) {
57177
+ constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
57178
+ createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
57179
+ undefined; }));
57137
57180
  }
57181
+ if (!constructSignatures.length) {
57182
+ constructSignatures = getDefaultConstructSignatures(classType_1);
57183
+ }
57184
+ type.constructSignatures = constructSignatures;
57138
57185
  }
57139
57186
  }
57140
57187
  function replaceIndexedAccess(instantiable, type, replacement) {
@@ -58135,8 +58182,8 @@ var ts;
58135
58182
  var stringIndexInfo;
58136
58183
  var applicableInfo;
58137
58184
  var applicableInfos;
58138
- for (var _i = 0, indexInfos_1 = indexInfos; _i < indexInfos_1.length; _i++) {
58139
- var info = indexInfos_1[_i];
58185
+ for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
58186
+ var info = indexInfos_3[_i];
58140
58187
  if (info.keyType === stringType) {
58141
58188
  stringIndexInfo = info;
58142
58189
  }
@@ -58675,13 +58722,15 @@ var ts;
58675
58722
  return signature;
58676
58723
  }
58677
58724
  function getOrCreateTypeFromSignature(signature) {
58725
+ var _a;
58678
58726
  // There are two ways to declare a construct signature, one is by declaring a class constructor
58679
58727
  // using the constructor keyword, and the other is declaring a bare construct signature in an
58680
58728
  // object type literal or interface (using the new keyword). Each way of declaring a constructor
58681
58729
  // will result in a different declaration kind.
58682
58730
  if (!signature.isolatedSignatureType) {
58683
- var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */;
58684
- var isConstructor = kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
58731
+ var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind;
58732
+ // If declaration is undefined, it is likely to be the signature of the default constructor.
58733
+ var isConstructor = kind === undefined || kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */;
58685
58734
  var type = createObjectType(16 /* Anonymous */);
58686
58735
  type.members = emptySymbols;
58687
58736
  type.properties = ts.emptyArray;
@@ -58707,14 +58756,14 @@ var ts;
58707
58756
  }
58708
58757
  function getIndexInfosOfIndexSymbol(indexSymbol) {
58709
58758
  if (indexSymbol.declarations) {
58710
- var indexInfos_2 = [];
58759
+ var indexInfos_4 = [];
58711
58760
  var _loop_14 = function (declaration) {
58712
58761
  if (declaration.parameters.length === 1) {
58713
58762
  var parameter = declaration.parameters[0];
58714
58763
  if (parameter.type) {
58715
58764
  forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
58716
- if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_2, keyType)) {
58717
- indexInfos_2.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
58765
+ if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
58766
+ indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
58718
58767
  }
58719
58768
  });
58720
58769
  }
@@ -58724,7 +58773,7 @@ var ts;
58724
58773
  var declaration = _a[_i];
58725
58774
  _loop_14(declaration);
58726
58775
  }
58727
- return indexInfos_2;
58776
+ return indexInfos_4;
58728
58777
  }
58729
58778
  return ts.emptyArray;
58730
58779
  }
@@ -59272,7 +59321,7 @@ var ts;
59272
59321
  // The expression is processed as an identifier expression (section 4.3)
59273
59322
  // or property access expression(section 4.10),
59274
59323
  // the widened type(section 3.9) of which becomes the result.
59275
- var type = ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
59324
+ var type = checkExpressionWithTypeArguments(node);
59276
59325
  links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
59277
59326
  }
59278
59327
  return links.resolvedType;
@@ -59609,7 +59658,7 @@ var ts;
59609
59658
  }
59610
59659
  }
59611
59660
  var fixedLength = properties.length;
59612
- var lengthSymbol = createSymbol(4 /* Property */, "length");
59661
+ var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
59613
59662
  if (combinedFlags & 12 /* Variable */) {
59614
59663
  lengthSymbol.type = numberType;
59615
59664
  }
@@ -61976,7 +62025,9 @@ var ts;
61976
62025
  return result;
61977
62026
  }
61978
62027
  function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
61979
- var declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0];
62028
+ var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
62029
+ type.objectFlags & 16777216 /* InstantiationExpressionType */ ? type.node :
62030
+ type.symbol.declarations[0];
61980
62031
  var links = getNodeLinks(declaration);
61981
62032
  var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
61982
62033
  type.objectFlags & 64 /* Instantiated */ ? type.target : type;
@@ -61992,8 +62043,8 @@ var ts;
61992
62043
  outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
61993
62044
  }
61994
62045
  typeParameters = outerTypeParameters || ts.emptyArray;
61995
- var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
61996
- typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
62046
+ var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
62047
+ typeParameters = (target.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
61997
62048
  ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
61998
62049
  typeParameters;
61999
62050
  links.outerTypeParameters = typeParameters;
@@ -62165,6 +62216,9 @@ var ts;
62165
62216
  mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
62166
62217
  freshTypeParameter.mapper = mapper;
62167
62218
  }
62219
+ if (type.objectFlags & 16777216 /* InstantiationExpressionType */) {
62220
+ result.node = type.node;
62221
+ }
62168
62222
  result.target = type;
62169
62223
  result.mapper = mapper;
62170
62224
  result.aliasSymbol = aliasSymbol || type.aliasSymbol;
@@ -62930,10 +62984,6 @@ var ts;
62930
62984
  if (sourceRestType || targetRestType) {
62931
62985
  void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
62932
62986
  }
62933
- if (sourceRestType && targetRestType && sourceCount !== targetCount) {
62934
- // We're not able to relate misaligned complex rest parameters
62935
- return 0 /* False */;
62936
- }
62937
62987
  var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
62938
62988
  var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
62939
62989
  kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
@@ -63249,11 +63299,11 @@ var ts;
63249
63299
  var overflow = false;
63250
63300
  var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
63251
63301
  var lastSkippedInfo;
63252
- var incompatibleStack = [];
63302
+ var incompatibleStack;
63253
63303
  var inPropertyCheck = false;
63254
63304
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
63255
63305
  var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
63256
- if (incompatibleStack.length) {
63306
+ if (incompatibleStack) {
63257
63307
  reportIncompatibleStack();
63258
63308
  }
63259
63309
  if (overflow) {
@@ -63310,19 +63360,19 @@ var ts;
63310
63360
  return {
63311
63361
  errorInfo: errorInfo,
63312
63362
  lastSkippedInfo: lastSkippedInfo,
63313
- incompatibleStack: incompatibleStack.slice(),
63363
+ incompatibleStack: incompatibleStack === null || incompatibleStack === void 0 ? void 0 : incompatibleStack.slice(),
63314
63364
  overrideNextErrorInfo: overrideNextErrorInfo,
63315
- relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
63365
+ relatedInfo: relatedInfo === null || relatedInfo === void 0 ? void 0 : relatedInfo.slice(),
63316
63366
  };
63317
63367
  }
63318
63368
  function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
63319
63369
  overrideNextErrorInfo++; // Suppress the next relation error
63320
63370
  lastSkippedInfo = undefined; // Reset skipped info cache
63321
- incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
63371
+ (incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
63322
63372
  }
63323
63373
  function reportIncompatibleStack() {
63324
- var stack = incompatibleStack;
63325
- incompatibleStack = [];
63374
+ var stack = incompatibleStack || [];
63375
+ incompatibleStack = undefined;
63326
63376
  var info = lastSkippedInfo;
63327
63377
  lastSkippedInfo = undefined;
63328
63378
  if (stack.length === 1) {
@@ -63428,7 +63478,7 @@ var ts;
63428
63478
  }
63429
63479
  function reportError(message, arg0, arg1, arg2, arg3) {
63430
63480
  ts.Debug.assert(!!errorNode);
63431
- if (incompatibleStack.length)
63481
+ if (incompatibleStack)
63432
63482
  reportIncompatibleStack();
63433
63483
  if (message.elidedInCompatabilityPyramid)
63434
63484
  return;
@@ -63444,7 +63494,7 @@ var ts;
63444
63494
  }
63445
63495
  }
63446
63496
  function reportRelationError(message, source, target) {
63447
- if (incompatibleStack.length)
63497
+ if (incompatibleStack)
63448
63498
  reportIncompatibleStack();
63449
63499
  var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
63450
63500
  var generalizedSource = source;
@@ -63556,7 +63606,9 @@ var ts;
63556
63606
  if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
63557
63607
  return -1 /* True */;
63558
63608
  }
63559
- reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */));
63609
+ if (reportErrors) {
63610
+ reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage);
63611
+ }
63560
63612
  return 0 /* False */;
63561
63613
  }
63562
63614
  // Normalize the source and target types: Turn fresh literal types into regular literal types,
@@ -63568,7 +63620,12 @@ var ts;
63568
63620
  if (source === target)
63569
63621
  return -1 /* True */;
63570
63622
  if (relation === identityRelation) {
63571
- return isIdenticalTo(source, target, recursionFlags);
63623
+ if (source.flags !== target.flags)
63624
+ return 0 /* False */;
63625
+ if (source.flags & 67358815 /* Singleton */)
63626
+ return -1 /* True */;
63627
+ traceUnionsOrIntersectionsTooLarge(source, target);
63628
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63572
63629
  }
63573
63630
  // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
63574
63631
  // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
@@ -63578,163 +63635,130 @@ var ts;
63578
63635
  if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) {
63579
63636
  return -1 /* True */;
63580
63637
  }
63581
- // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
63582
- // If so, reporting the `null` and `undefined` in the type is hardly useful.
63583
- // First, see if we're even relating an object type to a union.
63584
- // Then see if the target is stripped down to a single non-union type.
63585
- // Note
63586
- // * We actually want to remove null and undefined naively here (rather than using getNonNullableType),
63587
- // since we don't want to end up with a worse error like "`Foo` is not assignable to `NonNullable<T>`"
63588
- // when dealing with generics.
63589
- // * We also don't deal with primitive source types, since we already halt elaboration below.
63590
- if (target.flags & 1048576 /* Union */ && source.flags & 524288 /* Object */ &&
63591
- target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) {
63592
- var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */);
63593
- if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) {
63594
- target = getNormalizedType(nullStrippedTarget, /*writing*/ true);
63595
- }
63596
- if (source === nullStrippedTarget)
63597
- return -1 /* True */;
63638
+ // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined
63639
+ // plus a single non-nullable type. If so, remove null and/or undefined from the target type.
63640
+ if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) {
63641
+ var types = target.types;
63642
+ var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] :
63643
+ types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] :
63644
+ undefined;
63645
+ if (candidate && !(candidate.flags & 98304 /* Nullable */)) {
63646
+ target = getNormalizedType(candidate, /*writing*/ true);
63647
+ if (source === target)
63648
+ return -1 /* True */;
63649
+ }
63598
63650
  }
63599
63651
  if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) ||
63600
63652
  isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
63601
63653
  return -1 /* True */;
63602
- var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63603
- var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63604
- if (isPerformingExcessPropertyChecks) {
63605
- if (hasExcessProperties(source, target, reportErrors)) {
63654
+ if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) {
63655
+ var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */);
63656
+ if (isPerformingExcessPropertyChecks) {
63657
+ if (hasExcessProperties(source, target, reportErrors)) {
63658
+ if (reportErrors) {
63659
+ reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63660
+ }
63661
+ return 0 /* False */;
63662
+ }
63663
+ }
63664
+ var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63665
+ source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63666
+ target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63667
+ (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63668
+ var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */);
63669
+ if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63606
63670
  if (reportErrors) {
63607
- reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
63671
+ var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63672
+ var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63673
+ var calls = getSignaturesOfType(source, 0 /* Call */);
63674
+ var constructs = getSignaturesOfType(source, 1 /* Construct */);
63675
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63676
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63677
+ reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63678
+ }
63679
+ else {
63680
+ reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63681
+ }
63608
63682
  }
63609
63683
  return 0 /* False */;
63610
63684
  }
63611
- }
63612
- var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) &&
63613
- source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType &&
63614
- target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) &&
63615
- (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
63616
- if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
63617
- if (reportErrors) {
63618
- var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
63619
- var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63620
- var calls = getSignaturesOfType(source, 0 /* Call */);
63621
- var constructs = getSignaturesOfType(source, 1 /* Construct */);
63622
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63623
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63624
- reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63625
- }
63626
- else {
63627
- reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
63628
- }
63685
+ traceUnionsOrIntersectionsTooLarge(source, target);
63686
+ var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) ||
63687
+ target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */);
63688
+ var result_7 = skipCaching ?
63689
+ unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
63690
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
63691
+ // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63692
+ // an extra property check where the intersection is viewed as a single object. The following are motivating
63693
+ // examples that all should be errors, but aren't without this extra property check:
63694
+ //
63695
+ // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63696
+ //
63697
+ // declare let wrong: { a: { y: string } };
63698
+ // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63699
+ //
63700
+ // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63701
+ // x = y; // Mismatched property in source intersection
63702
+ // }
63703
+ //
63704
+ // We suppress recursive intersection property checks because they can generate lots of work when relating
63705
+ // recursive intersections that are structurally similar but not exactly identical. See #37854.
63706
+ if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63707
+ isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
63708
+ inPropertyCheck = true;
63709
+ result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63710
+ inPropertyCheck = false;
63711
+ }
63712
+ if (result_7) {
63713
+ return result_7;
63629
63714
  }
63630
- return 0 /* False */;
63631
- }
63632
- traceUnionsOrIntersectionsTooLarge(source, target);
63633
- var result = 0 /* False */;
63634
- var saveErrorInfo = captureErrorCalculationState();
63635
- if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
63636
- // We skip caching when source or target is a union with no more than three constituents.
63637
- result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63638
63715
  }
63639
- else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63640
- result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
63716
+ if (reportErrors) {
63717
+ reportErrorResults(originalSource, originalTarget, source, target, headMessage);
63641
63718
  }
63642
- if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63643
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
63644
- resetErrorInfo(saveErrorInfo);
63719
+ return 0 /* False */;
63720
+ }
63721
+ function reportErrorResults(originalSource, originalTarget, source, target, headMessage) {
63722
+ var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63723
+ var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63724
+ source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63725
+ target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63726
+ var maybeSuppress = overrideNextErrorInfo > 0;
63727
+ if (maybeSuppress) {
63728
+ overrideNextErrorInfo--;
63729
+ }
63730
+ if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63731
+ var currentError = errorInfo;
63732
+ tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true);
63733
+ if (errorInfo !== currentError) {
63734
+ maybeSuppress = !!errorInfo;
63735
+ }
63736
+ }
63737
+ if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63738
+ tryElaborateErrorsForPrimitivesAndObjects(source, target);
63739
+ }
63740
+ else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63741
+ reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63742
+ }
63743
+ else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) {
63744
+ var targetTypes = target.types;
63745
+ var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63746
+ var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63747
+ if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63748
+ (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63749
+ // do not report top error
63750
+ return;
63645
63751
  }
63646
63752
  }
63647
- if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) {
63648
- // The combined constraint of an intersection type is the intersection of the constraints of
63649
- // the constituents. When an intersection type contains instantiable types with union type
63650
- // constraints, there are situations where we need to examine the combined constraint. One is
63651
- // when the target is a union type. Another is when the intersection contains types belonging
63652
- // to one of the disjoint domains. For example, given type variables T and U, each with the
63653
- // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
63654
- // we need to check this constraint against a union on the target side. Also, given a type
63655
- // variable V constrained to 'string | number', 'V & number' has a combined constraint of
63656
- // 'string & number | number & number' which reduces to just 'number'.
63657
- // This also handles type parameters, as a type parameter with a union constraint compared against a union
63658
- // needs to have its constraint hoisted into an intersection with said type parameter, this way
63659
- // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
63660
- // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
63661
- var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
63662
- if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
63663
- if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
63664
- // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
63665
- if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63666
- resetErrorInfo(saveErrorInfo);
63667
- }
63668
- }
63669
- }
63753
+ else {
63754
+ errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63670
63755
  }
63671
- // For certain combinations involving intersections and optional, excess, or mismatched properties we need
63672
- // an extra property check where the intersection is viewed as a single object. The following are motivating
63673
- // examples that all should be errors, but aren't without this extra property check:
63674
- //
63675
- // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
63676
- //
63677
- // declare let wrong: { a: { y: string } };
63678
- // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
63679
- //
63680
- // function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
63681
- // x = y; // Mismatched property in source intersection
63682
- // }
63683
- //
63684
- // We suppress recursive intersection property checks because they can generate lots of work when relating
63685
- // recursive intersections that are structurally similar but not exactly identical. See #37854.
63686
- if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63687
- isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
63688
- inPropertyCheck = true;
63689
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63690
- inPropertyCheck = false;
63691
- }
63692
- reportErrorResults(source, target, result, isComparingJsxAttributes);
63693
- return result;
63694
- function reportErrorResults(source, target, result, isComparingJsxAttributes) {
63695
- if (!result && reportErrors) {
63696
- var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource);
63697
- var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget);
63698
- source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source;
63699
- target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target;
63700
- var maybeSuppress = overrideNextErrorInfo > 0;
63701
- if (maybeSuppress) {
63702
- overrideNextErrorInfo--;
63703
- }
63704
- if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
63705
- var currentError = errorInfo;
63706
- tryElaborateArrayLikeErrors(source, target, reportErrors);
63707
- if (errorInfo !== currentError) {
63708
- maybeSuppress = !!errorInfo;
63709
- }
63710
- }
63711
- if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) {
63712
- tryElaborateErrorsForPrimitivesAndObjects(source, target);
63713
- }
63714
- else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) {
63715
- reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
63716
- }
63717
- else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) {
63718
- var targetTypes = target.types;
63719
- var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
63720
- var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
63721
- if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
63722
- (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
63723
- // do not report top error
63724
- return result;
63725
- }
63726
- }
63727
- else {
63728
- errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
63729
- }
63730
- if (!headMessage && maybeSuppress) {
63731
- lastSkippedInfo = [source, target];
63732
- // Used by, eg, missing property checking to replace the top-level message with a more informative one
63733
- return result;
63734
- }
63735
- reportRelationError(headMessage, source, target);
63736
- }
63756
+ if (!headMessage && maybeSuppress) {
63757
+ lastSkippedInfo = [source, target];
63758
+ // Used by, eg, missing property checking to replace the top-level message with a more informative one
63759
+ return;
63737
63760
  }
63761
+ reportRelationError(headMessage, source, target);
63738
63762
  }
63739
63763
  function traceUnionsOrIntersectionsTooLarge(source, target) {
63740
63764
  if (!ts.tracing) {
@@ -63761,21 +63785,6 @@ var ts;
63761
63785
  }
63762
63786
  }
63763
63787
  }
63764
- function isIdenticalTo(source, target, recursionFlags) {
63765
- if (source.flags !== target.flags)
63766
- return 0 /* False */;
63767
- if (source.flags & 67358815 /* Singleton */)
63768
- return -1 /* True */;
63769
- traceUnionsOrIntersectionsTooLarge(source, target);
63770
- if (source.flags & 3145728 /* UnionOrIntersection */) {
63771
- var result_7 = eachTypeRelatedToSomeType(source, target);
63772
- if (result_7) {
63773
- result_7 &= eachTypeRelatedToSomeType(target, source);
63774
- }
63775
- return result_7;
63776
- }
63777
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63778
- }
63779
63788
  function getTypeOfPropertyInTypes(types, name) {
63780
63789
  var appendPropType = function (propTypes, type) {
63781
63790
  var _a;
@@ -63874,6 +63883,41 @@ var ts;
63874
63883
  function shouldCheckAsExcessProperty(prop, container) {
63875
63884
  return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
63876
63885
  }
63886
+ function unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) {
63887
+ // Note that these checks are specifically ordered to produce correct results. In particular,
63888
+ // we need to deconstruct unions before intersections (because unions are always at the top),
63889
+ // and we need to handle "each" relations before "some" relations for the same kind of type.
63890
+ if (source.flags & 1048576 /* Union */) {
63891
+ return relation === comparableRelation ?
63892
+ someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) :
63893
+ eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState);
63894
+ }
63895
+ if (target.flags & 1048576 /* Union */) {
63896
+ return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
63897
+ }
63898
+ if (target.flags & 2097152 /* Intersection */) {
63899
+ return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
63900
+ }
63901
+ // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
63902
+ // constraints of all non-primitive types in the source into a new intersection. We do this because the
63903
+ // intersection may further constrain the constraints of the non-primitive types. For example, given a type
63904
+ // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
63905
+ // appear to be comparable to '2'.
63906
+ if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
63907
+ var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
63908
+ if (constraints !== source.types) {
63909
+ source = getIntersectionType(constraints);
63910
+ if (!(source.flags & 2097152 /* Intersection */)) {
63911
+ return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
63912
+ }
63913
+ }
63914
+ }
63915
+ // Check to see if any constituents of the intersection are immediately related to the target.
63916
+ // Don't report errors though. Elaborating on whether a source constituent is related to the target is
63917
+ // not actually useful and leads to some confusing error messages. Instead, we rely on the caller
63918
+ // checking whether the full intersection viewed as an object is related to the target.
63919
+ return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
63920
+ }
63877
63921
  function eachTypeRelatedToSomeType(source, target) {
63878
63922
  var result = -1 /* True */;
63879
63923
  var sourceTypes = source.types;
@@ -63909,8 +63953,11 @@ var ts;
63909
63953
  }
63910
63954
  }
63911
63955
  if (reportErrors) {
63956
+ // Elaborate only if we can find a best matching type in the target union
63912
63957
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
63913
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
63958
+ if (bestMatchingType) {
63959
+ isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true);
63960
+ }
63914
63961
  }
63915
63962
  return 0 /* False */;
63916
63963
  }
@@ -64046,7 +64093,7 @@ var ts;
64046
64093
  if (overflow) {
64047
64094
  return 0 /* False */;
64048
64095
  }
64049
- var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
64096
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0);
64050
64097
  var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
64051
64098
  var entry = relation.get(id);
64052
64099
  if (entry !== undefined) {
@@ -64114,6 +64161,7 @@ var ts;
64114
64161
  return originalHandler(onlyUnreliable);
64115
64162
  };
64116
64163
  }
64164
+ var result;
64117
64165
  if (expandingFlags === 3 /* Both */) {
64118
64166
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", {
64119
64167
  sourceId: source.id,
@@ -64123,8 +64171,13 @@ var ts;
64123
64171
  depth: sourceDepth,
64124
64172
  targetDepth: targetDepth
64125
64173
  });
64174
+ result = 3 /* Maybe */;
64175
+ }
64176
+ else {
64177
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64178
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState);
64179
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64126
64180
  }
64127
- var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
64128
64181
  if (outofbandVarianceMarkerHandler) {
64129
64182
  outofbandVarianceMarkerHandler = originalHandler;
64130
64183
  }
@@ -64156,98 +64209,97 @@ var ts;
64156
64209
  return result;
64157
64210
  }
64158
64211
  function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
64159
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
64160
- var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
64161
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
64162
- return result;
64163
- }
64164
- function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
64165
64212
  if (intersectionState & 4 /* PropertyCheck */) {
64166
64213
  return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */);
64167
64214
  }
64168
- if (intersectionState & 8 /* UnionIntersectionCheck */) {
64169
- // Note that these checks are specifically ordered to produce correct results. In particular,
64170
- // we need to deconstruct unions before intersections (because unions are always at the top),
64171
- // and we need to handle "each" relations before "some" relations for the same kind of type.
64172
- if (source.flags & 1048576 /* Union */) {
64173
- return relation === comparableRelation ?
64174
- someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */) :
64175
- eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState & ~8 /* UnionIntersectionCheck */);
64176
- }
64177
- if (target.flags & 1048576 /* Union */) {
64178
- return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
64179
- }
64180
- if (target.flags & 2097152 /* Intersection */) {
64181
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
64182
- }
64183
- // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
64184
- // constraints of all non-primitive types in the source into a new intersection. We do this because the
64185
- // intersection may further constrain the constraints of the non-primitive types. For example, given a type
64186
- // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't
64187
- // appear to be comparable to '2'.
64188
- if (relation === comparableRelation && target.flags & 131068 /* Primitive */) {
64189
- var constraints = ts.sameMap(source.types, getBaseConstraintOrType);
64190
- if (constraints !== source.types) {
64191
- source = getIntersectionType(constraints);
64192
- if (!(source.flags & 2097152 /* Intersection */)) {
64193
- return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
64194
- }
64215
+ var result;
64216
+ var originalErrorInfo;
64217
+ var varianceCheckFailed = false;
64218
+ var saveErrorInfo = captureErrorCalculationState();
64219
+ var sourceFlags = source.flags;
64220
+ var targetFlags = target.flags;
64221
+ if (relation === identityRelation) {
64222
+ // We've already checked that source.flags and target.flags are identical
64223
+ if (sourceFlags & 3145728 /* UnionOrIntersection */) {
64224
+ var result_8 = eachTypeRelatedToSomeType(source, target);
64225
+ if (result_8) {
64226
+ result_8 &= eachTypeRelatedToSomeType(target, source);
64195
64227
  }
64228
+ return result_8;
64196
64229
  }
64197
- // Check to see if any constituents of the intersection are immediately related to the target.
64198
- //
64199
- // Don't report errors though. Checking whether a constituent is related to the source is not actually
64200
- // useful and leads to some confusing error messages. Instead it is better to let the below checks
64201
- // take care of this, or to not elaborate at all. For instance,
64202
- //
64203
- // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
64204
- //
64205
- // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
64206
- // than to report that 'D' is not assignable to 'A' or 'B'.
64207
- //
64208
- // - For a primitive type or type parameter (such as 'number = A & B') there is no point in
64209
- // breaking the intersection apart.
64210
- return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */);
64211
- }
64212
- var flags = source.flags & target.flags;
64213
- if (relation === identityRelation && !(flags & 524288 /* Object */)) {
64214
- if (flags & 4194304 /* Index */) {
64230
+ if (sourceFlags & 4194304 /* Index */) {
64215
64231
  return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
64216
64232
  }
64217
- var result_8 = 0 /* False */;
64218
- if (flags & 8388608 /* IndexedAccess */) {
64219
- if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64220
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64221
- return result_8;
64233
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64234
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
64235
+ if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
64236
+ return result;
64222
64237
  }
64223
64238
  }
64224
64239
  }
64225
- if (flags & 16777216 /* Conditional */) {
64240
+ if (sourceFlags & 16777216 /* Conditional */) {
64226
64241
  if (source.root.isDistributive === target.root.isDistributive) {
64227
- if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64228
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64229
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64230
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64231
- return result_8;
64242
+ if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
64243
+ if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
64244
+ if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64245
+ if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
64246
+ return result;
64232
64247
  }
64233
64248
  }
64234
64249
  }
64235
64250
  }
64236
64251
  }
64237
64252
  }
64238
- if (flags & 33554432 /* Substitution */) {
64253
+ if (sourceFlags & 33554432 /* Substitution */) {
64239
64254
  return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
64240
64255
  }
64241
- return 0 /* False */;
64256
+ if (!(sourceFlags & 524288 /* Object */)) {
64257
+ return 0 /* False */;
64258
+ }
64259
+ }
64260
+ else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) {
64261
+ if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) {
64262
+ return result;
64263
+ }
64264
+ if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) {
64265
+ // The combined constraint of an intersection type is the intersection of the constraints of
64266
+ // the constituents. When an intersection type contains instantiable types with union type
64267
+ // constraints, there are situations where we need to examine the combined constraint. One is
64268
+ // when the target is a union type. Another is when the intersection contains types belonging
64269
+ // to one of the disjoint domains. For example, given type variables T and U, each with the
64270
+ // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and
64271
+ // we need to check this constraint against a union on the target side. Also, given a type
64272
+ // variable V constrained to 'string | number', 'V & number' has a combined constraint of
64273
+ // 'string & number | number & number' which reduces to just 'number'.
64274
+ // This also handles type parameters, as a type parameter with a union constraint compared against a union
64275
+ // needs to have its constraint hoisted into an intersection with said type parameter, this way
64276
+ // the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
64277
+ // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
64278
+ var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */));
64279
+ if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
64280
+ // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
64281
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
64282
+ resetErrorInfo(saveErrorInfo);
64283
+ return result;
64284
+ }
64285
+ }
64286
+ }
64287
+ // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle:
64288
+ // Source is instantiable (e.g. source has union or intersection constraint).
64289
+ // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }).
64290
+ // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }).
64291
+ // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }).
64292
+ // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }).
64293
+ if (!(sourceFlags & 465829888 /* Instantiable */ ||
64294
+ sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ ||
64295
+ sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) {
64296
+ return 0 /* False */;
64297
+ }
64242
64298
  }
64243
- var result;
64244
- var originalErrorInfo;
64245
- var varianceCheckFailed = false;
64246
- var saveErrorInfo = captureErrorCalculationState();
64247
64299
  // We limit alias variance probing to only object and conditional types since their alias behavior
64248
64300
  // is more predictable than other, interned types, which may or may not have an alias depending on
64249
64301
  // the order in which things were checked.
64250
- if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64302
+ if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol &&
64251
64303
  source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
64252
64304
  !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
64253
64305
  var variances = getAliasVariances(source.aliasSymbol);
@@ -64265,7 +64317,7 @@ var ts;
64265
64317
  isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
64266
64318
  return result;
64267
64319
  }
64268
- if (target.flags & 262144 /* TypeParameter */) {
64320
+ if (targetFlags & 262144 /* TypeParameter */) {
64269
64321
  // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
64270
64322
  if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
64271
64323
  if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
@@ -64277,10 +64329,10 @@ var ts;
64277
64329
  }
64278
64330
  }
64279
64331
  }
64280
- else if (target.flags & 4194304 /* Index */) {
64332
+ else if (targetFlags & 4194304 /* Index */) {
64281
64333
  var targetType_1 = target.type;
64282
64334
  // A keyof S is related to a keyof T if T is related to S.
64283
- if (source.flags & 4194304 /* Index */) {
64335
+ if (sourceFlags & 4194304 /* Index */) {
64284
64336
  if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
64285
64337
  return result;
64286
64338
  }
@@ -64331,8 +64383,8 @@ var ts;
64331
64383
  }
64332
64384
  }
64333
64385
  }
64334
- else if (target.flags & 8388608 /* IndexedAccess */) {
64335
- if (source.flags & 8388608 /* IndexedAccess */) {
64386
+ else if (targetFlags & 8388608 /* IndexedAccess */) {
64387
+ if (sourceFlags & 8388608 /* IndexedAccess */) {
64336
64388
  // Relate components directly before falling back to constraint relationships
64337
64389
  // A type S[K] is related to a type T[J] if S is related to T and K is related to J.
64338
64390
  if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
@@ -64438,7 +64490,7 @@ var ts;
64438
64490
  }
64439
64491
  }
64440
64492
  }
64441
- else if (target.flags & 16777216 /* Conditional */) {
64493
+ else if (targetFlags & 16777216 /* Conditional */) {
64442
64494
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64443
64495
  // conditional type and bail out with a Ternary.Maybe result.
64444
64496
  if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
@@ -64463,8 +64515,8 @@ var ts;
64463
64515
  }
64464
64516
  }
64465
64517
  }
64466
- else if (target.flags & 134217728 /* TemplateLiteral */) {
64467
- if (source.flags & 134217728 /* TemplateLiteral */) {
64518
+ else if (targetFlags & 134217728 /* TemplateLiteral */) {
64519
+ if (sourceFlags & 134217728 /* TemplateLiteral */) {
64468
64520
  if (relation === comparableRelation) {
64469
64521
  return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
64470
64522
  }
@@ -64476,11 +64528,11 @@ var ts;
64476
64528
  return -1 /* True */;
64477
64529
  }
64478
64530
  }
64479
- if (source.flags & 8650752 /* TypeVariable */) {
64480
- // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch
64481
- if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) {
64531
+ if (sourceFlags & 8650752 /* TypeVariable */) {
64532
+ // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
64533
+ if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
64482
64534
  var constraint = getConstraintOfType(source);
64483
- if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64535
+ if (!constraint || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
64484
64536
  // A type variable with no constraint is not related to the non-primitive object type.
64485
64537
  if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
64486
64538
  resetErrorInfo(saveErrorInfo);
@@ -64493,7 +64545,7 @@ var ts;
64493
64545
  return result;
64494
64546
  }
64495
64547
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
64496
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64548
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64497
64549
  resetErrorInfo(saveErrorInfo);
64498
64550
  return result;
64499
64551
  }
@@ -64510,14 +64562,14 @@ var ts;
64510
64562
  }
64511
64563
  }
64512
64564
  }
64513
- else if (source.flags & 4194304 /* Index */) {
64565
+ else if (sourceFlags & 4194304 /* Index */) {
64514
64566
  if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
64515
64567
  resetErrorInfo(saveErrorInfo);
64516
64568
  return result;
64517
64569
  }
64518
64570
  }
64519
- else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
64520
- if (!(target.flags & 134217728 /* TemplateLiteral */)) {
64571
+ else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
64572
+ if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
64521
64573
  var constraint = getBaseConstraintOfType(source);
64522
64574
  if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
64523
64575
  resetErrorInfo(saveErrorInfo);
@@ -64525,8 +64577,8 @@ var ts;
64525
64577
  }
64526
64578
  }
64527
64579
  }
64528
- else if (source.flags & 268435456 /* StringMapping */) {
64529
- if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64580
+ else if (sourceFlags & 268435456 /* StringMapping */) {
64581
+ if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
64530
64582
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
64531
64583
  resetErrorInfo(saveErrorInfo);
64532
64584
  return result;
@@ -64540,14 +64592,14 @@ var ts;
64540
64592
  }
64541
64593
  }
64542
64594
  }
64543
- else if (source.flags & 16777216 /* Conditional */) {
64595
+ else if (sourceFlags & 16777216 /* Conditional */) {
64544
64596
  // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
64545
64597
  // conditional type and bail out with a Ternary.Maybe result.
64546
64598
  if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
64547
64599
  resetErrorInfo(saveErrorInfo);
64548
64600
  return 3 /* Maybe */;
64549
64601
  }
64550
- if (target.flags & 16777216 /* Conditional */) {
64602
+ if (targetFlags & 16777216 /* Conditional */) {
64551
64603
  // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64552
64604
  // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64553
64605
  // and Y1 is related to Y2.
@@ -64607,9 +64659,10 @@ var ts;
64607
64659
  }
64608
64660
  return 0 /* False */;
64609
64661
  }
64610
- var sourceIsPrimitive = !!(source.flags & 131068 /* Primitive */);
64662
+ var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */);
64611
64663
  if (relation !== identityRelation) {
64612
64664
  source = getApparentType(source);
64665
+ sourceFlags = source.flags;
64613
64666
  }
64614
64667
  else if (isGenericMappedType(source)) {
64615
64668
  return 0 /* False */;
@@ -64656,7 +64709,7 @@ var ts;
64656
64709
  // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates
64657
64710
  // to X. Failing both of those we want to check if the aggregation of A and B's members structurally
64658
64711
  // relates to X. Thus, we include intersection types on the source side here.
64659
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) {
64712
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) {
64660
64713
  // Report structural errors only if we haven't reported any errors yet
64661
64714
  var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
64662
64715
  result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState);
@@ -64680,7 +64733,7 @@ var ts;
64680
64733
  // there exists a constituent of T for every combination of the discriminants of S
64681
64734
  // with respect to T. We do not report errors here, as we will use the existing
64682
64735
  // error result from checking each constituent of the union.
64683
- if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
64736
+ if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) {
64684
64737
  var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
64685
64738
  if (objectOnlyTarget.flags & 1048576 /* Union */) {
64686
64739
  var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
@@ -65204,7 +65257,6 @@ var ts;
65204
65257
  }
65205
65258
  }
65206
65259
  var result = -1 /* True */;
65207
- var saveErrorInfo = captureErrorCalculationState();
65208
65260
  var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
65209
65261
  var sourceObjectFlags = ts.getObjectFlags(source);
65210
65262
  var targetObjectFlags = ts.getObjectFlags(target);
@@ -65245,6 +65297,7 @@ var ts;
65245
65297
  else {
65246
65298
  outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
65247
65299
  var t = targetSignatures_1[_i];
65300
+ var saveErrorInfo = captureErrorCalculationState();
65248
65301
  // Only elaborate errors from the first failure
65249
65302
  var shouldElaborateErrors = reportErrors;
65250
65303
  for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
@@ -65355,8 +65408,8 @@ var ts;
65355
65408
  var indexInfos = getIndexInfosOfType(target);
65356
65409
  var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
65357
65410
  var result = -1 /* True */;
65358
- for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
65359
- var targetInfo = indexInfos_3[_i];
65411
+ for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
65412
+ var targetInfo = indexInfos_5[_i];
65360
65413
  var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
65361
65414
  isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
65362
65415
  typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
@@ -65963,10 +66016,10 @@ var ts;
65963
66016
  if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
65964
66017
  return undefined;
65965
66018
  }
65966
- if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) {
65967
- return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
66019
+ if (ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeCalculated */) {
66020
+ return ts.getObjectFlags(type) & 134217728 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
65968
66021
  }
65969
- type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */;
66022
+ type.objectFlags |= 67108864 /* IdenticalBaseTypeCalculated */;
65970
66023
  var target = type.target;
65971
66024
  if (ts.getObjectFlags(target) & 1 /* Class */) {
65972
66025
  var baseTypeNode = getBaseTypeNodeOfClass(target);
@@ -65987,7 +66040,7 @@ var ts;
65987
66040
  if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
65988
66041
  instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
65989
66042
  }
65990
- type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */;
66043
+ type.objectFlags |= 134217728 /* IdenticalBaseTypeExists */;
65991
66044
  return type.cachedEquivalentBaseType = instantiatedBase;
65992
66045
  }
65993
66046
  function isEmptyLiteralType(type) {
@@ -66651,7 +66704,7 @@ var ts;
66651
66704
  var result = !!(type.flags & 465829888 /* Instantiable */ ||
66652
66705
  type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
66653
66706
  objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
66654
- objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
66707
+ objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */ | 16777216 /* InstantiationExpressionType */)) ||
66655
66708
  type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
66656
66709
  if (type.flags & 3899393 /* ObjectFlagsType */) {
66657
66710
  type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
@@ -67568,8 +67621,8 @@ var ts;
67568
67621
  var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
67569
67622
  var indexInfos = getIndexInfosOfType(target);
67570
67623
  if (isObjectTypeWithInferableIndex(source)) {
67571
- for (var _i = 0, indexInfos_4 = indexInfos; _i < indexInfos_4.length; _i++) {
67572
- var targetInfo = indexInfos_4[_i];
67624
+ for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
67625
+ var targetInfo = indexInfos_6[_i];
67573
67626
  var propTypes = [];
67574
67627
  for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
67575
67628
  var prop = _b[_a];
@@ -67589,8 +67642,8 @@ var ts;
67589
67642
  }
67590
67643
  }
67591
67644
  }
67592
- for (var _e = 0, indexInfos_5 = indexInfos; _e < indexInfos_5.length; _e++) {
67593
- var targetInfo = indexInfos_5[_e];
67645
+ for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
67646
+ var targetInfo = indexInfos_7[_e];
67594
67647
  var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
67595
67648
  if (sourceInfo) {
67596
67649
  inferWithPriority(sourceInfo.type, targetInfo.type, priority);
@@ -68415,9 +68468,6 @@ var ts;
68415
68468
  getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) :
68416
68469
  mapType(type, mapper);
68417
68470
  }
68418
- function getConstituentCount(type) {
68419
- return type.flags & 1048576 /* Union */ ? type.types.length : 1;
68420
- }
68421
68471
  function extractTypesOfKind(type, kind) {
68422
68472
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
68423
68473
  }
@@ -69991,7 +70041,7 @@ var ts;
69991
70041
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69992
70042
  someType(type, isGenericTypeWithUnionConstraint) &&
69993
70043
  (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
69994
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
70044
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69995
70045
  }
69996
70046
  function isExportOrExportExpression(location) {
69997
70047
  return !!ts.findAncestor(location, function (n) {
@@ -73138,6 +73188,9 @@ var ts;
73138
73188
  if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
73139
73189
  error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
73140
73190
  }
73191
+ if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
73192
+ addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
73193
+ }
73141
73194
  }
73142
73195
  else {
73143
73196
  if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
@@ -75754,6 +75807,72 @@ var ts;
75754
75807
  return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
75755
75808
  getNonNullableType(checkExpression(node.expression));
75756
75809
  }
75810
+ function checkExpressionWithTypeArguments(node) {
75811
+ checkGrammarExpressionWithTypeArguments(node);
75812
+ var exprType = node.kind === 227 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
75813
+ ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
75814
+ checkExpression(node.exprName);
75815
+ var typeArguments = node.typeArguments;
75816
+ if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
75817
+ return exprType;
75818
+ }
75819
+ var hasSomeApplicableSignature = false;
75820
+ var nonApplicableType;
75821
+ var result = getInstantiatedType(exprType);
75822
+ var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
75823
+ if (errorType) {
75824
+ diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
75825
+ }
75826
+ return result;
75827
+ function getInstantiatedType(type) {
75828
+ var hasSignatures = false;
75829
+ var hasApplicableSignature = false;
75830
+ var result = getInstantiatedTypePart(type);
75831
+ hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
75832
+ if (hasSignatures && !hasApplicableSignature) {
75833
+ nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
75834
+ }
75835
+ return result;
75836
+ function getInstantiatedTypePart(type) {
75837
+ if (type.flags & 524288 /* Object */) {
75838
+ var resolved = resolveStructuredTypeMembers(type);
75839
+ var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
75840
+ var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
75841
+ hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
75842
+ hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
75843
+ if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
75844
+ var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
75845
+ result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
75846
+ result_11.node = node;
75847
+ return result_11;
75848
+ }
75849
+ }
75850
+ else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
75851
+ var constraint = getBaseConstraintOfType(type);
75852
+ if (constraint) {
75853
+ var instantiated = getInstantiatedTypePart(constraint);
75854
+ if (instantiated !== constraint) {
75855
+ return instantiated;
75856
+ }
75857
+ }
75858
+ }
75859
+ else if (type.flags & 1048576 /* Union */) {
75860
+ return mapType(type, getInstantiatedType);
75861
+ }
75862
+ else if (type.flags & 2097152 /* Intersection */) {
75863
+ return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
75864
+ }
75865
+ return type;
75866
+ }
75867
+ }
75868
+ function getInstantiatedSignatures(signatures) {
75869
+ var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
75870
+ return ts.sameMap(applicableSignatures, function (sig) {
75871
+ var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
75872
+ return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
75873
+ });
75874
+ }
75875
+ }
75757
75876
  function checkMetaProperty(node) {
75758
75877
  checkGrammarMetaProperty(node);
75759
75878
  if (node.keywordToken === 103 /* NewKeyword */) {
@@ -76083,21 +76202,22 @@ var ts;
76083
76202
  if (links.type === unknownType) {
76084
76203
  links.type = getTypeFromBindingPattern(declaration.name);
76085
76204
  }
76086
- assignBindingElementTypes(declaration.name);
76205
+ assignBindingElementTypes(declaration.name, links.type);
76087
76206
  }
76088
76207
  }
76089
76208
  }
76090
76209
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76091
76210
  // the destructured type into the contained binding elements.
76092
- function assignBindingElementTypes(pattern) {
76211
+ function assignBindingElementTypes(pattern, parentType) {
76093
76212
  for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
76094
76213
  var element = _a[_i];
76095
76214
  if (!ts.isOmittedExpression(element)) {
76215
+ var type = getBindingElementTypeFromParentType(element, parentType);
76096
76216
  if (element.name.kind === 79 /* Identifier */) {
76097
- getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
76217
+ getSymbolLinks(getSymbolOfNode(element)).type = type;
76098
76218
  }
76099
76219
  else {
76100
- assignBindingElementTypes(element.name);
76220
+ assignBindingElementTypes(element.name, type);
76101
76221
  }
76102
76222
  }
76103
76223
  }
@@ -77242,7 +77362,7 @@ var ts;
77242
77362
  if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
77243
77363
  if (operator === 55 /* AmpersandAmpersandToken */) {
77244
77364
  var parent = ts.walkUpParenthesizedExpressions(node.parent);
77245
- checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77365
+ checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
77246
77366
  }
77247
77367
  checkTruthinessOfType(leftType, node.left);
77248
77368
  }
@@ -77749,8 +77869,8 @@ var ts;
77749
77869
  return type;
77750
77870
  }
77751
77871
  function checkConditionalExpression(node, checkMode) {
77752
- var type = checkTruthinessExpression(node.condition);
77753
- checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue);
77872
+ checkTruthinessExpression(node.condition);
77873
+ checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
77754
77874
  var type1 = checkExpression(node.whenTrue, checkMode);
77755
77875
  var type2 = checkExpression(node.whenFalse, checkMode);
77756
77876
  return getUnionType([type1, type2], 2 /* Subtype */);
@@ -78269,6 +78389,8 @@ var ts;
78269
78389
  return checkAssertion(node);
78270
78390
  case 229 /* NonNullExpression */:
78271
78391
  return checkNonNullAssertion(node);
78392
+ case 227 /* ExpressionWithTypeArguments */:
78393
+ return checkExpressionWithTypeArguments(node);
78272
78394
  case 230 /* MetaProperty */:
78273
78395
  return checkMetaProperty(node);
78274
78396
  case 214 /* DeleteExpression */:
@@ -79472,12 +79594,12 @@ var ts;
79472
79594
  case 264 /* ImportEqualsDeclaration */:
79473
79595
  case 267 /* NamespaceImport */:
79474
79596
  case 266 /* ImportClause */:
79475
- var result_11 = 0 /* None */;
79597
+ var result_12 = 0 /* None */;
79476
79598
  var target = resolveAlias(getSymbolOfNode(d));
79477
79599
  ts.forEach(target.declarations, function (d) {
79478
- result_11 |= getDeclarationSpaces(d);
79600
+ result_12 |= getDeclarationSpaces(d);
79479
79601
  });
79480
- return result_11;
79602
+ return result_12;
79481
79603
  case 253 /* VariableDeclaration */:
79482
79604
  case 202 /* BindingElement */:
79483
79605
  case 255 /* FunctionDeclaration */:
@@ -79838,28 +79960,24 @@ var ts;
79838
79960
  if (returnType.flags & 1 /* Any */) {
79839
79961
  return;
79840
79962
  }
79963
+ var headMessage;
79841
79964
  var expectedReturnType;
79842
- var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
79843
- var errorInfo;
79844
79965
  switch (node.parent.kind) {
79845
79966
  case 256 /* ClassDeclaration */:
79967
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
79846
79968
  var classSymbol = getSymbolOfNode(node.parent);
79847
79969
  var classConstructorType = getTypeOfSymbol(classSymbol);
79848
79970
  expectedReturnType = getUnionType([classConstructorType, voidType]);
79849
79971
  break;
79850
- case 163 /* Parameter */:
79851
- expectedReturnType = voidType;
79852
- errorInfo = ts.chainDiagnosticMessages(
79853
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
79854
- break;
79855
79972
  case 166 /* PropertyDeclaration */:
79973
+ case 163 /* Parameter */:
79974
+ headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any;
79856
79975
  expectedReturnType = voidType;
79857
- errorInfo = ts.chainDiagnosticMessages(
79858
- /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
79859
79976
  break;
79860
79977
  case 168 /* MethodDeclaration */:
79861
79978
  case 171 /* GetAccessor */:
79862
79979
  case 172 /* SetAccessor */:
79980
+ headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1;
79863
79981
  var methodType = getTypeOfNode(node.parent);
79864
79982
  var descriptorType = createTypedPropertyDescriptorType(methodType);
79865
79983
  expectedReturnType = getUnionType([descriptorType, voidType]);
@@ -79867,7 +79985,7 @@ var ts;
79867
79985
  default:
79868
79986
  return ts.Debug.fail();
79869
79987
  }
79870
- checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
79988
+ checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
79871
79989
  }
79872
79990
  /**
79873
79991
  * If a TypeNode can be resolved to a value symbol imported from an external module, it is
@@ -80908,50 +81026,59 @@ var ts;
80908
81026
  function checkIfStatement(node) {
80909
81027
  // Grammar checking
80910
81028
  checkGrammarStatementInAmbientContext(node);
80911
- var type = checkTruthinessExpression(node.expression);
80912
- checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement);
81029
+ checkTruthinessExpression(node.expression);
81030
+ checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
80913
81031
  checkSourceElement(node.thenStatement);
80914
81032
  if (node.thenStatement.kind === 235 /* EmptyStatement */) {
80915
81033
  error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
80916
81034
  }
80917
81035
  checkSourceElement(node.elseStatement);
80918
81036
  }
80919
- function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) {
81037
+ function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
80920
81038
  if (!strictNullChecks)
80921
81039
  return;
80922
- if (getFalsyFlags(type))
80923
- return;
80924
- var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr;
80925
- if (ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) {
80926
- return;
80927
- }
80928
- var testedNode = ts.isIdentifier(location) ? location
80929
- : ts.isPropertyAccessExpression(location) ? location.name
80930
- : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
80931
- : undefined;
80932
- // While it technically should be invalid for any known-truthy value
80933
- // to be tested, we de-scope to functions and Promises unreferenced in
80934
- // the block as a heuristic to identify the most common bugs. There
80935
- // are too many false positives for values sourced from type
80936
- // definitions without strictNullChecks otherwise.
80937
- var callSignatures = getSignaturesOfType(type, 0 /* Call */);
80938
- var isPromise = !!getAwaitedTypeOfPromise(type);
80939
- if (callSignatures.length === 0 && !isPromise) {
80940
- return;
80941
- }
80942
- var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
80943
- if (!testedSymbol && !isPromise) {
80944
- return;
80945
- }
80946
- var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
80947
- || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
80948
- if (!isUsed) {
80949
- if (isPromise) {
80950
- errorAndMaybeSuggestAwait(location,
80951
- /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81040
+ helper(condExpr, body);
81041
+ while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
81042
+ condExpr = condExpr.left;
81043
+ helper(condExpr, body);
81044
+ }
81045
+ function helper(condExpr, body) {
81046
+ var location = ts.isBinaryExpression(condExpr) &&
81047
+ (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
81048
+ ? condExpr.right
81049
+ : condExpr;
81050
+ var type = checkTruthinessExpression(location);
81051
+ var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
81052
+ if (getFalsyFlags(type) || isPropertyExpressionCast)
81053
+ return;
81054
+ // While it technically should be invalid for any known-truthy value
81055
+ // to be tested, we de-scope to functions and Promises unreferenced in
81056
+ // the block as a heuristic to identify the most common bugs. There
81057
+ // are too many false positives for values sourced from type
81058
+ // definitions without strictNullChecks otherwise.
81059
+ var callSignatures = getSignaturesOfType(type, 0 /* Call */);
81060
+ var isPromise = !!getAwaitedTypeOfPromise(type);
81061
+ if (callSignatures.length === 0 && !isPromise) {
81062
+ return;
80952
81063
  }
80953
- else {
80954
- error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81064
+ var testedNode = ts.isIdentifier(location) ? location
81065
+ : ts.isPropertyAccessExpression(location) ? location.name
81066
+ : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
81067
+ : undefined;
81068
+ var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
81069
+ if (!testedSymbol && !isPromise) {
81070
+ return;
81071
+ }
81072
+ var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
81073
+ || testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
81074
+ if (!isUsed) {
81075
+ if (isPromise) {
81076
+ errorAndMaybeSuggestAwait(location,
81077
+ /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
81078
+ }
81079
+ else {
81080
+ error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
81081
+ }
80955
81082
  }
80956
81083
  }
80957
81084
  }
@@ -82040,8 +82167,8 @@ var ts;
82040
82167
  }
82041
82168
  }
82042
82169
  if (indexInfos.length > 1) {
82043
- for (var _d = 0, indexInfos_6 = indexInfos; _d < indexInfos_6.length; _d++) {
82044
- var info = indexInfos_6[_d];
82170
+ for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
82171
+ var info = indexInfos_8[_d];
82045
82172
  checkIndexConstraintForIndexSignature(type, info);
82046
82173
  }
82047
82174
  }
@@ -82067,8 +82194,8 @@ var ts;
82067
82194
  error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
82068
82195
  }
82069
82196
  };
82070
- for (var _i = 0, indexInfos_7 = indexInfos; _i < indexInfos_7.length; _i++) {
82071
- var info = indexInfos_7[_i];
82197
+ for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
82198
+ var info = indexInfos_9[_i];
82072
82199
  _loop_27(info);
82073
82200
  }
82074
82201
  }
@@ -82090,8 +82217,8 @@ var ts;
82090
82217
  error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type));
82091
82218
  }
82092
82219
  };
82093
- for (var _i = 0, indexInfos_8 = indexInfos; _i < indexInfos_8.length; _i++) {
82094
- var info = indexInfos_8[_i];
82220
+ for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
82221
+ var info = indexInfos_10[_i];
82095
82222
  _loop_28(info);
82096
82223
  }
82097
82224
  }
@@ -82140,9 +82267,9 @@ var ts;
82140
82267
  var containsArguments = containsArgumentsReference(node);
82141
82268
  if (containsArguments) {
82142
82269
  var lastJSDocParam = ts.lastOrUndefined(jsdocParameters);
82143
- if (lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82270
+ if (isJs && lastJSDocParam && ts.isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
82144
82271
  lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
82145
- 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));
82272
+ error(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));
82146
82273
  }
82147
82274
  }
82148
82275
  else {
@@ -82152,7 +82279,9 @@ var ts;
82152
82279
  return;
82153
82280
  }
82154
82281
  if (ts.isQualifiedName(name)) {
82155
- errorOrSuggestion(isJs, name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82282
+ if (isJs) {
82283
+ error(name, ts.Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, ts.entityNameToString(name), ts.entityNameToString(name.left));
82284
+ }
82156
82285
  }
82157
82286
  else {
82158
82287
  errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
@@ -83745,10 +83874,10 @@ var ts;
83745
83874
  }
83746
83875
  // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
83747
83876
  // (TS Exceptions: namespaces, function overloads, enums, and interfaces)
83748
- if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) {
83877
+ if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
83749
83878
  return;
83750
83879
  }
83751
- var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
83880
+ var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
83752
83881
  if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
83753
83882
  // it is legal to merge type alias with other values
83754
83883
  // so count should be either 1 (just type alias) or 2 (type alias + merged value)
@@ -85415,7 +85544,7 @@ var ts;
85415
85544
  if (resolvedTypeReferenceDirectives) {
85416
85545
  // populate reverse mapping: file path -> type reference directive that was resolved to this file
85417
85546
  fileToDirective = new ts.Map();
85418
- resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
85547
+ resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key, mode) {
85419
85548
  if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
85420
85549
  return;
85421
85550
  }
@@ -85423,7 +85552,7 @@ var ts;
85423
85552
  if (file) {
85424
85553
  // Add the transitive closure of path references loaded by this file (as long as they are not)
85425
85554
  // part of an existing type reference.
85426
- addReferencedFilesToTypeDirective(file, key);
85555
+ addReferencedFilesToTypeDirective(file, key, mode);
85427
85556
  }
85428
85557
  });
85429
85558
  }
@@ -85617,16 +85746,16 @@ var ts;
85617
85746
  }
85618
85747
  return false;
85619
85748
  }
85620
- function addReferencedFilesToTypeDirective(file, key) {
85749
+ function addReferencedFilesToTypeDirective(file, key, mode) {
85621
85750
  if (fileToDirective.has(file.path))
85622
85751
  return;
85623
- fileToDirective.set(file.path, key);
85752
+ fileToDirective.set(file.path, [key, mode]);
85624
85753
  for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
85625
- var fileName = _a[_i].fileName;
85754
+ var _b = _a[_i], fileName = _b.fileName, resolutionMode = _b.resolutionMode;
85626
85755
  var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
85627
85756
  var referencedFile = host.getSourceFile(resolvedFile);
85628
85757
  if (referencedFile) {
85629
- addReferencedFilesToTypeDirective(referencedFile, key);
85758
+ addReferencedFilesToTypeDirective(referencedFile, key, resolutionMode || file.impliedNodeFormat);
85630
85759
  }
85631
85760
  }
85632
85761
  }
@@ -87331,28 +87460,27 @@ var ts;
87331
87460
  }
87332
87461
  function findMostOverlappyType(source, unionTarget) {
87333
87462
  var bestMatch;
87334
- var matchingCount = 0;
87335
- for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87336
- var target = _a[_i];
87337
- var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87338
- if (overlap.flags & 4194304 /* Index */) {
87339
- // perfect overlap of keys
87340
- bestMatch = target;
87341
- matchingCount = Infinity;
87342
- }
87343
- else if (overlap.flags & 1048576 /* Union */) {
87344
- // We only want to account for literal types otherwise.
87345
- // If we have a union of index types, it seems likely that we
87346
- // needed to elaborate between two generic mapped types anyway.
87347
- var len = ts.length(ts.filter(overlap.types, isUnitType));
87348
- if (len >= matchingCount) {
87349
- bestMatch = target;
87350
- matchingCount = len;
87351
- }
87352
- }
87353
- else if (isUnitType(overlap) && 1 >= matchingCount) {
87354
- bestMatch = target;
87355
- matchingCount = 1;
87463
+ if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87464
+ var matchingCount = 0;
87465
+ for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
87466
+ var target = _a[_i];
87467
+ if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) {
87468
+ var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
87469
+ if (overlap.flags & 4194304 /* Index */) {
87470
+ // perfect overlap of keys
87471
+ return target;
87472
+ }
87473
+ else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) {
87474
+ // We only want to account for literal types otherwise.
87475
+ // If we have a union of index types, it seems likely that we
87476
+ // needed to elaborate between two generic mapped types anyway.
87477
+ var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1;
87478
+ if (len >= matchingCount) {
87479
+ bestMatch = target;
87480
+ matchingCount = len;
87481
+ }
87482
+ }
87483
+ }
87356
87484
  }
87357
87485
  }
87358
87486
  return bestMatch;
@@ -87725,7 +87853,7 @@ var ts;
87725
87853
  return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
87726
87854
  case 180 /* TypeQuery */:
87727
87855
  ts.Debug.type(node);
87728
- return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
87856
+ return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
87729
87857
  case 181 /* TypeLiteral */:
87730
87858
  ts.Debug.type(node);
87731
87859
  return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
@@ -90617,8 +90745,8 @@ var ts;
90617
90745
  function generateClassElementDecorationExpressions(node, isStatic) {
90618
90746
  var members = getDecoratedClassElements(node, isStatic);
90619
90747
  var expressions;
90620
- for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
90621
- var member = members_6[_i];
90748
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
90749
+ var member = members_8[_i];
90622
90750
  var expression = generateClassElementDecorationExpression(node, member);
90623
90751
  if (expression) {
90624
90752
  if (!expressions) {
@@ -95963,8 +96091,8 @@ var ts;
95963
96091
  function convertJsxChildrenToChildrenPropAssignment(children) {
95964
96092
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95965
96093
  if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
95966
- var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95967
- return result_12 && factory.createPropertyAssignment("children", result_12);
96094
+ var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
96095
+ return result_13 && factory.createPropertyAssignment("children", result_13);
95968
96096
  }
95969
96097
  var result = ts.mapDefined(children, transformJsxChildToExpression);
95970
96098
  return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
@@ -106395,7 +106523,7 @@ var ts;
106395
106523
  var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
106396
106524
  hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
106397
106525
  collectReferences(sourceFile, refs);
106398
- recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
106526
+ recordTypeReferenceDirectivesIfNecessary(ts.map(sourceFile.typeReferenceDirectives, function (ref) { return [ref.fileName, ref.resolutionMode]; }));
106399
106527
  collectLibs(sourceFile, libs);
106400
106528
  return sourceFile;
106401
106529
  }
@@ -106450,9 +106578,10 @@ var ts;
106450
106578
  return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
106451
106579
  }
106452
106580
  function getFileReferencesForUsedTypeReferences() {
106453
- return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
106581
+ return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForSpecifierModeTuple) : [];
106454
106582
  }
106455
- function getFileReferenceForTypeName(typeName) {
106583
+ function getFileReferenceForSpecifierModeTuple(_a) {
106584
+ var typeName = _a[0], mode = _a[1];
106456
106585
  // Elide type references for which we have imports
106457
106586
  if (emittedImports) {
106458
106587
  for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
@@ -106468,7 +106597,7 @@ var ts;
106468
106597
  }
106469
106598
  }
106470
106599
  }
106471
- return { fileName: typeName, pos: -1, end: -1 };
106600
+ return __assign({ fileName: typeName, pos: -1, end: -1 }, (mode ? { resolutionMode: mode } : undefined));
106472
106601
  }
106473
106602
  function mapReferencesIntoArray(references, outputFilePath) {
106474
106603
  return function (file) {
@@ -106488,7 +106617,7 @@ var ts;
106488
106617
  // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration
106489
106618
  // via a non-relative name, emit a type reference directive to that non-relative name, rather than
106490
106619
  // a relative path to the declaration file
106491
- recordTypeReferenceDirectivesIfNecessary([specifier]);
106620
+ recordTypeReferenceDirectivesIfNecessary([[specifier, /*mode*/ undefined]]);
106492
106621
  return;
106493
106622
  }
106494
106623
  var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName,
@@ -109601,6 +109730,8 @@ var ts;
109601
109730
  return emitAsExpression(node);
109602
109731
  case 229 /* NonNullExpression */:
109603
109732
  return emitNonNullExpression(node);
109733
+ case 227 /* ExpressionWithTypeArguments */:
109734
+ return emitExpressionWithTypeArguments(node);
109604
109735
  case 230 /* MetaProperty */:
109605
109736
  return emitMetaProperty(node);
109606
109737
  case 231 /* SyntheticExpression */:
@@ -110045,6 +110176,7 @@ var ts;
110045
110176
  writeKeyword("typeof");
110046
110177
  writeSpace();
110047
110178
  emit(node.exprName);
110179
+ emitTypeArguments(node, node.typeArguments);
110048
110180
  }
110049
110181
  function emitTypeLiteral(node) {
110050
110182
  writePunctuation("{");
@@ -111600,9 +111732,12 @@ var ts;
111600
111732
  for (var _d = 0, types_24 = types; _d < types_24.length; _d++) {
111601
111733
  var directive = types_24[_d];
111602
111734
  var pos = writer.getTextPos();
111603
- writeComment("/// <reference types=\"" + directive.fileName + "\" />");
111735
+ var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat)
111736
+ ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\""
111737
+ : "";
111738
+ writeComment("/// <reference types=\"" + directive.fileName + "\" " + resolutionMode + "/>");
111604
111739
  if (bundleFileInfo)
111605
- bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type" /* Type */, data: directive.fileName });
111740
+ bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName });
111606
111741
  writeLine();
111607
111742
  }
111608
111743
  for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
@@ -114209,7 +114344,7 @@ var ts;
114209
114344
  }
114210
114345
  ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
114211
114346
  /* @internal */
114212
- function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
114347
+ function loadWithTypeDirectiveCache(names, containingFile, redirectedReference, containingFileMode, loader) {
114213
114348
  if (names.length === 0) {
114214
114349
  return [];
114215
114350
  }
@@ -114218,19 +114353,28 @@ var ts;
114218
114353
  for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
114219
114354
  var name = names_2[_i];
114220
114355
  var result = void 0;
114221
- if (cache.has(name)) {
114222
- result = cache.get(name);
114356
+ var mode = getModeForFileReference(name, containingFileMode);
114357
+ // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
114358
+ var strName = ts.isString(name) ? name : name.fileName.toLowerCase();
114359
+ var cacheKey = mode !== undefined ? mode + "|" + strName : strName;
114360
+ if (cache.has(cacheKey)) {
114361
+ result = cache.get(cacheKey);
114223
114362
  }
114224
114363
  else {
114225
- cache.set(name, result = loader(name, containingFile, redirectedReference));
114364
+ cache.set(cacheKey, result = loader(strName, containingFile, redirectedReference, mode));
114226
114365
  }
114227
114366
  resolutions.push(result);
114228
114367
  }
114229
114368
  return resolutions;
114230
114369
  }
114231
- ts.loadWithLocalCache = loadWithLocalCache;
114370
+ ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
114232
114371
  ;
114233
114372
  /* @internal */
114373
+ function getModeForFileReference(ref, containingFileMode) {
114374
+ return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
114375
+ }
114376
+ ts.getModeForFileReference = getModeForFileReference;
114377
+ /* @internal */
114234
114378
  function getModeForResolutionAtIndex(file, index) {
114235
114379
  if (file.impliedNodeFormat === undefined)
114236
114380
  return undefined;
@@ -114333,7 +114477,7 @@ var ts;
114333
114477
  var _d, _e, _f, _g;
114334
114478
  var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
114335
114479
  var kind = ref.kind, index = ref.index;
114336
- var pos, end, packageId;
114480
+ var pos, end, packageId, resolutionMode;
114337
114481
  switch (kind) {
114338
114482
  case ts.FileIncludeKind.Import:
114339
114483
  var importLiteral = getModuleNameStringLiteralAt(file, index);
@@ -114347,8 +114491,8 @@ var ts;
114347
114491
  (_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
114348
114492
  break;
114349
114493
  case ts.FileIncludeKind.TypeReferenceDirective:
114350
- (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
114351
- 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;
114494
+ (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end, resolutionMode = _b.resolutionMode);
114495
+ 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;
114352
114496
  break;
114353
114497
  case ts.FileIncludeKind.LibReferenceDirective:
114354
114498
  (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
@@ -114592,7 +114736,7 @@ var ts;
114592
114736
  var fileReasons = ts.createMultiMap();
114593
114737
  var cachedBindAndCheckDiagnosticsForFile = {};
114594
114738
  var cachedDeclarationDiagnosticsForFile = {};
114595
- var resolvedTypeReferenceDirectives = new ts.Map();
114739
+ var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
114596
114740
  var fileProcessingDiagnostics;
114597
114741
  // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
114598
114742
  // This works as imported modules are discovered recursively in a depth first manner, specifically:
@@ -114645,12 +114789,12 @@ var ts;
114645
114789
  }
114646
114790
  var actualResolveTypeReferenceDirectiveNamesWorker;
114647
114791
  if (host.resolveTypeReferenceDirectives) {
114648
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
114792
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference, containingFileMode) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode); };
114649
114793
  }
114650
114794
  else {
114651
114795
  typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache());
114652
- var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217
114653
- actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
114796
+ var loader_2 = function (typesRef, containingFile, redirectedReference, resolutionMode) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode).resolvedTypeReferenceDirective; }; // TODO: GH#18217
114797
+ actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) { return loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_2); };
114654
114798
  }
114655
114799
  // Map from a stringified PackageId to the source file with that id.
114656
114800
  // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
@@ -114747,7 +114891,8 @@ var ts;
114747
114891
  var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
114748
114892
  var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
114749
114893
  for (var i = 0; i < typeReferences.length; i++) {
114750
- processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
114894
+ // under node12/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode
114895
+ processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
114751
114896
  }
114752
114897
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
114753
114898
  }
@@ -114907,9 +115052,10 @@ var ts;
114907
115052
  return [];
114908
115053
  var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
114909
115054
  var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
115055
+ var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
114910
115056
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
114911
115057
  ts.performance.mark("beforeResolveTypeReference");
114912
- var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
115058
+ var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode);
114913
115059
  ts.performance.mark("afterResolveTypeReference");
114914
115060
  ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
114915
115061
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
@@ -115004,15 +115150,15 @@ var ts;
115004
115150
  // which per above occurred during the current program creation.
115005
115151
  // Since we assume the filesystem does not change during program creation,
115006
115152
  // it is safe to reuse resolutions from the earlier call.
115007
- var result_13 = [];
115153
+ var result_14 = [];
115008
115154
  var i = 0;
115009
115155
  for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
115010
115156
  var moduleName = moduleNames_1[_i];
115011
115157
  var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
115012
115158
  i++;
115013
- result_13.push(resolvedModule);
115159
+ result_14.push(resolvedModule);
115014
115160
  }
115015
- return result_13;
115161
+ return result_14;
115016
115162
  }
115017
115163
  // At this point, we know at least one of the following hold:
115018
115164
  // - file has local declarations for ambient modules
@@ -115301,8 +115447,7 @@ var ts;
115301
115447
  else {
115302
115448
  newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
115303
115449
  }
115304
- // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
115305
- var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
115450
+ var typesReferenceDirectives = newSourceFile.typeReferenceDirectives;
115306
115451
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
115307
115452
  // ensure that types resolutions are still correct
115308
115453
  var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
@@ -116381,8 +116526,7 @@ var ts;
116381
116526
  });
116382
116527
  }
116383
116528
  function processTypeReferenceDirectives(file) {
116384
- // We lower-case all type references because npm automatically lowercases all packages. See GH#9824.
116385
- var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
116529
+ var typeDirectives = file.typeReferenceDirectives;
116386
116530
  if (!typeDirectives) {
116387
116531
  return;
116388
116532
  }
@@ -116393,17 +116537,21 @@ var ts;
116393
116537
  // store resolved type directive on the file
116394
116538
  var fileName = ts.toFileNameLowerCase(ref.fileName);
116395
116539
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
116396
- processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
116540
+ var mode = ref.resolutionMode || file.impliedNodeFormat;
116541
+ if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
116542
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node12_or_nodenext));
116543
+ }
116544
+ processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
116397
116545
  }
116398
116546
  }
116399
- function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
116547
+ function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
116400
116548
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
116401
- processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
116549
+ processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
116402
116550
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116403
116551
  }
116404
- function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
116552
+ function processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
116405
116553
  // If we already found this library as a primary reference - nothing to do
116406
- var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
116554
+ var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode);
116407
116555
  if (previousResolution && previousResolution.primary) {
116408
116556
  return;
116409
116557
  }
@@ -116442,7 +116590,7 @@ var ts;
116442
116590
  addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
116443
116591
  }
116444
116592
  if (saveResolution) {
116445
- resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
116593
+ resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective);
116446
116594
  }
116447
116595
  }
116448
116596
  function pathForLibFile(libFileName) {
@@ -119260,9 +119408,9 @@ var ts;
119260
119408
  });
119261
119409
  hasChangedAutomaticTypeDirectiveNames = false;
119262
119410
  }
119263
- function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
119411
+ function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference, _containingSourceFile, mode) {
119264
119412
  var _a;
119265
- var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
119413
+ var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
119266
119414
  // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts
119267
119415
  if (!resolutionHost.getGlobalCache) {
119268
119416
  return primaryResult;
@@ -119283,12 +119431,12 @@ var ts;
119283
119431
  // Default return the result from the first pass
119284
119432
  return primaryResult;
119285
119433
  }
119286
- function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
119287
- return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache);
119434
+ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, _containingSourceFile, resolutionMode) {
119435
+ return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
119288
119436
  }
119289
119437
  function resolveNamesWithLocalCache(_a) {
119290
119438
  var _b, _c, _d;
119291
- 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;
119439
+ 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;
119292
119440
  var path = resolutionHost.toPath(containingFile);
119293
119441
  var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
119294
119442
  var dirPath = ts.getDirectoryPath(path);
@@ -119310,8 +119458,15 @@ var ts;
119310
119458
  var seenNamesInFile = ts.createModeAwareCache();
119311
119459
  var i = 0;
119312
119460
  for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
119313
- var name = names_4[_i];
119314
- var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
119461
+ var entry = names_4[_i];
119462
+ var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
119463
+ // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
119464
+ // they require calculating the mode for a given import from it's position in the resolution table, since a given
119465
+ // import's syntax may override the file's default mode.
119466
+ // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
119467
+ // a default file mode override if applicable.
119468
+ var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
119469
+ containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
119315
119470
  i++;
119316
119471
  var resolution = resolutionsInFile.get(name, mode);
119317
119472
  // Resolution is valid if it is present and not invalidated
@@ -119340,7 +119495,7 @@ var ts;
119340
119495
  }
119341
119496
  }
119342
119497
  else {
119343
- resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
119498
+ resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
119344
119499
  perDirectoryResolution.set(name, mode, resolution);
119345
119500
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
119346
119501
  resolutionHost.onDiscoveredSymlink();
@@ -119404,7 +119559,7 @@ var ts;
119404
119559
  return oldResult.resolvedFileName === newResult.resolvedFileName;
119405
119560
  }
119406
119561
  }
119407
- function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
119562
+ function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode) {
119408
119563
  return resolveNamesWithLocalCache({
119409
119564
  names: typeDirectiveNames,
119410
119565
  containingFile: containingFile,
@@ -119414,6 +119569,7 @@ var ts;
119414
119569
  loader: resolveTypeReferenceDirective,
119415
119570
  getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
119416
119571
  shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
119572
+ containingSourceFileMode: containingFileMode
119417
119573
  });
119418
119574
  }
119419
119575
  function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
@@ -120120,9 +120276,9 @@ var ts;
120120
120276
  if (!preferSymlinks) {
120121
120277
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
120122
120278
  // so we only need to remove them from the realpath filenames.
120123
- var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
120124
- if (result_14)
120125
- return result_14;
120279
+ var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
120280
+ if (result_15)
120281
+ return result_15;
120126
120282
  }
120127
120283
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
120128
120284
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -120142,10 +120298,10 @@ var ts;
120142
120298
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
120143
120299
  var symlinkDirectory = symlinkDirectories_1[_i];
120144
120300
  var option = ts.resolvePath(symlinkDirectory, relative);
120145
- var result_15 = cb(option, target === referenceRedirect);
120301
+ var result_16 = cb(option, target === referenceRedirect);
120146
120302
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
120147
- if (result_15)
120148
- return result_15;
120303
+ if (result_16)
120304
+ return result_16;
120149
120305
  }
120150
120306
  });
120151
120307
  });
@@ -121322,7 +121478,7 @@ var ts;
121322
121478
  }
121323
121479
  return host.resolveTypeReferenceDirectives.apply(host, args);
121324
121480
  }) :
121325
- (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
121481
+ (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); });
121326
121482
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
121327
121483
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
121328
121484
  synchronizeProgram();
@@ -122058,9 +122214,9 @@ var ts;
122058
122214
  compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
122059
122215
  }
122060
122216
  if (!compilerHost.resolveTypeReferenceDirectives) {
122061
- var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
122062
- compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) {
122063
- return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4);
122217
+ var loader_4 = function (moduleName, containingFile, redirectedReference, containingFileMode) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective; };
122218
+ compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) {
122219
+ return ts.loadWithTypeDirectiveCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader_4);
122064
122220
  };
122065
122221
  }
122066
122222
  var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;