typescript 4.5.0-dev.20210928 → 4.5.0-dev.20211002

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20210928";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20211002";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5154,6 +5154,7 @@ var ts;
5154
5154
  // module kind).
5155
5155
  ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
5156
5156
  ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
5157
+ ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022";
5157
5158
  ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
5158
5159
  // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
5159
5160
  ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
@@ -8071,7 +8072,7 @@ var ts;
8071
8072
  Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
8072
8073
  Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
8073
8074
  Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
8074
- Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
8075
+ Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
8075
8076
  Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."),
8076
8077
  Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
8077
8078
  Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
@@ -8089,7 +8090,7 @@ var ts;
8089
8090
  Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
8090
8091
  Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"),
8091
8092
  Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
8092
- The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'."),
8093
+ The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."),
8093
8094
  A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
8094
8095
  An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."),
8095
8096
  This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
@@ -8120,7 +8121,7 @@ var ts;
8120
8121
  await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
8121
8122
  _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
8122
8123
  _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
8123
- Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_noden_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
8124
+ Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
8124
8125
  An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
8125
8126
  An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
8126
8127
  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 `}`?"),
@@ -8172,7 +8173,7 @@ var ts;
8172
8173
  File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
8173
8174
  The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
8174
8175
  for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
8175
- Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenex_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
8176
+ Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
8176
8177
  Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."),
8177
8178
  Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
8178
8179
  Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
@@ -19625,6 +19626,7 @@ var ts;
19625
19626
  case ts.ModuleKind.AMD:
19626
19627
  case ts.ModuleKind.ES2015:
19627
19628
  case ts.ModuleKind.ES2020:
19629
+ case ts.ModuleKind.ES2022:
19628
19630
  case ts.ModuleKind.ESNext:
19629
19631
  return true;
19630
19632
  default:
@@ -20729,6 +20731,10 @@ var ts;
20729
20731
  return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
20730
20732
  }
20731
20733
  ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
20734
+ function isFunctionExpressionOrArrowFunction(node) {
20735
+ return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
20736
+ }
20737
+ ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
20732
20738
  })(ts || (ts = {}));
20733
20739
  /* @internal */
20734
20740
  var ts;
@@ -31353,7 +31359,6 @@ var ts;
31353
31359
  case 88 /* DefaultKeyword */:
31354
31360
  return nextTokenCanFollowDefaultKeyword();
31355
31361
  case 124 /* StaticKeyword */:
31356
- return nextTokenIsOnSameLineAndCanFollowModifier();
31357
31362
  case 136 /* GetKeyword */:
31358
31363
  case 148 /* SetKeyword */:
31359
31364
  nextToken();
@@ -35596,7 +35601,7 @@ var ts;
35596
35601
  }
35597
35602
  return list && createNodeArray(list, pos);
35598
35603
  }
35599
- function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
35604
+ function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
35600
35605
  var pos = getNodePos();
35601
35606
  var kind = token();
35602
35607
  if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
@@ -35609,6 +35614,9 @@ var ts;
35609
35614
  else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
35610
35615
  return undefined;
35611
35616
  }
35617
+ else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
35618
+ return undefined;
35619
+ }
35612
35620
  else {
35613
35621
  if (!parseAnyContextualModifier()) {
35614
35622
  return undefined;
@@ -35625,8 +35633,10 @@ var ts;
35625
35633
  */
35626
35634
  function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
35627
35635
  var pos = getNodePos();
35628
- var list, modifier;
35629
- while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
35636
+ var list, modifier, hasSeenStatic = false;
35637
+ while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
35638
+ if (modifier.kind === 124 /* StaticKeyword */)
35639
+ hasSeenStatic = true;
35630
35640
  list = ts.append(list, modifier);
35631
35641
  }
35632
35642
  return list && createNodeArray(list, pos);
@@ -38331,6 +38341,7 @@ var ts;
38331
38341
  es6: ts.ModuleKind.ES2015,
38332
38342
  es2015: ts.ModuleKind.ES2015,
38333
38343
  es2020: ts.ModuleKind.ES2020,
38344
+ es2022: ts.ModuleKind.ES2022,
38334
38345
  esnext: ts.ModuleKind.ESNext,
38335
38346
  node12: ts.ModuleKind.Node12,
38336
38347
  nodenext: ts.ModuleKind.NodeNext,
@@ -40038,6 +40049,44 @@ var ts;
40038
40049
  }
40039
40050
  return result;
40040
40051
  }
40052
+ /**
40053
+ * Generate a list of the compiler options whose value is not the default.
40054
+ * @param options compilerOptions to be evaluated.
40055
+ /** @internal */
40056
+ function getCompilerOptionsDiffValue(options, newLine) {
40057
+ var compilerOptionsMap = getSerializedCompilerOption(options);
40058
+ return getOverwrittenDefaultOptions();
40059
+ function makePadding(paddingLength) {
40060
+ return Array(paddingLength + 1).join(" ");
40061
+ }
40062
+ function getOverwrittenDefaultOptions() {
40063
+ var result = [];
40064
+ var tab = makePadding(2);
40065
+ commandOptionsWithoutBuild.forEach(function (cmd) {
40066
+ if (!compilerOptionsMap.has(cmd.name)) {
40067
+ return;
40068
+ }
40069
+ var newValue = compilerOptionsMap.get(cmd.name);
40070
+ var defaultValue = getDefaultValueForOption(cmd);
40071
+ if (newValue !== defaultValue) {
40072
+ result.push("" + tab + cmd.name + ": " + newValue);
40073
+ }
40074
+ else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
40075
+ result.push("" + tab + cmd.name + ": " + defaultValue);
40076
+ }
40077
+ });
40078
+ return result.join(newLine) + newLine;
40079
+ }
40080
+ }
40081
+ ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
40082
+ /**
40083
+ * Get the compiler options to be written into the tsconfig.json.
40084
+ * @param options commandlineOptions to be included in the compileOptions.
40085
+ */
40086
+ function getSerializedCompilerOption(options) {
40087
+ var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
40088
+ return serializeCompilerOptions(compilerOptions);
40089
+ }
40041
40090
  /**
40042
40091
  * Generate tsconfig configuration when running command line "--init"
40043
40092
  * @param options commandlineOptions to be generated into tsconfig.json
@@ -40045,28 +40094,8 @@ var ts;
40045
40094
  */
40046
40095
  /* @internal */
40047
40096
  function generateTSConfig(options, fileNames, newLine) {
40048
- var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
40049
- var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
40097
+ var compilerOptionsMap = getSerializedCompilerOption(options);
40050
40098
  return writeConfigurations();
40051
- function getDefaultValueForOption(option) {
40052
- switch (option.type) {
40053
- case "number":
40054
- return 1;
40055
- case "boolean":
40056
- return true;
40057
- case "string":
40058
- return option.isFilePath ? "./" : "";
40059
- case "list":
40060
- return [];
40061
- case "object":
40062
- return {};
40063
- default:
40064
- var iterResult = option.type.keys().next();
40065
- if (!iterResult.done)
40066
- return iterResult.value;
40067
- return ts.Debug.fail("Expected 'option.type' to have entries.");
40068
- }
40069
- }
40070
40099
  function makePadding(paddingLength) {
40071
40100
  return Array(paddingLength + 1).join(" ");
40072
40101
  }
@@ -41053,6 +41082,25 @@ var ts;
41053
41082
  }); // TODO: GH#18217
41054
41083
  }
41055
41084
  }
41085
+ function getDefaultValueForOption(option) {
41086
+ switch (option.type) {
41087
+ case "number":
41088
+ return 1;
41089
+ case "boolean":
41090
+ return true;
41091
+ case "string":
41092
+ return option.isFilePath ? "./" : "";
41093
+ case "list":
41094
+ return [];
41095
+ case "object":
41096
+ return {};
41097
+ default:
41098
+ var iterResult = option.type.keys().next();
41099
+ if (!iterResult.done)
41100
+ return iterResult.value;
41101
+ return ts.Debug.fail("Expected 'option.type' to have entries.");
41102
+ }
41103
+ }
41056
41104
  })(ts || (ts = {}));
41057
41105
  var ts;
41058
41106
  (function (ts) {
@@ -42429,9 +42477,11 @@ var ts;
42429
42477
  return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
42430
42478
  }
42431
42479
  ts.parsePackageName = parsePackageName;
42480
+ /* @internal */
42432
42481
  function allKeysStartWithDot(obj) {
42433
42482
  return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42434
42483
  }
42484
+ ts.allKeysStartWithDot = allKeysStartWithDot;
42435
42485
  function noKeyStartsWithDot(obj) {
42436
42486
  return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42437
42487
  }
@@ -42638,17 +42688,19 @@ var ts;
42638
42688
  }
42639
42689
  return toSearchResult(/*value*/ undefined);
42640
42690
  }
42641
- function isApplicableVersionedTypesKey(conditions, key) {
42642
- if (conditions.indexOf("types") === -1)
42643
- return false; // only apply versioned types conditions if the types condition is applied
42644
- if (!ts.startsWith(key, "types@"))
42645
- return false;
42646
- var range = ts.VersionRange.tryParse(key.substring("types@".length));
42647
- if (!range)
42648
- return false;
42649
- return range.test(ts.version);
42650
- }
42651
42691
  }
42692
+ /* @internal */
42693
+ function isApplicableVersionedTypesKey(conditions, key) {
42694
+ if (conditions.indexOf("types") === -1)
42695
+ return false; // only apply versioned types conditions if the types condition is applied
42696
+ if (!ts.startsWith(key, "types@"))
42697
+ return false;
42698
+ var range = ts.VersionRange.tryParse(key.substring("types@".length));
42699
+ if (!range)
42700
+ return false;
42701
+ return range.test(ts.version);
42702
+ }
42703
+ ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
42652
42704
  function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
42653
42705
  return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
42654
42706
  }
@@ -46464,6 +46516,13 @@ var ts;
46464
46516
  IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
46465
46517
  IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
46466
46518
  })(IntersectionState || (IntersectionState = {}));
46519
+ var RecursionFlags;
46520
+ (function (RecursionFlags) {
46521
+ RecursionFlags[RecursionFlags["None"] = 0] = "None";
46522
+ RecursionFlags[RecursionFlags["Source"] = 1] = "Source";
46523
+ RecursionFlags[RecursionFlags["Target"] = 2] = "Target";
46524
+ RecursionFlags[RecursionFlags["Both"] = 3] = "Both";
46525
+ })(RecursionFlags || (RecursionFlags = {}));
46467
46526
  var MappedTypeModifiers;
46468
46527
  (function (MappedTypeModifiers) {
46469
46528
  MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly";
@@ -47226,17 +47285,9 @@ var ts;
47226
47285
  }
47227
47286
  }
47228
47287
  else {
47229
- if (file.localJsxNamespace) {
47230
- return file.localJsxNamespace;
47231
- }
47232
- var jsxPragma = file.pragmas.get("jsx");
47233
- if (jsxPragma) {
47234
- var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
47235
- file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
47236
- ts.visitNode(file.localJsxFactory, markAsSynthetic);
47237
- if (file.localJsxFactory) {
47238
- return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
47239
- }
47288
+ var localJsxNamespace = getLocalJsxNamespace(file);
47289
+ if (localJsxNamespace) {
47290
+ return file.localJsxNamespace = localJsxNamespace;
47240
47291
  }
47241
47292
  }
47242
47293
  }
@@ -47258,11 +47309,25 @@ var ts;
47258
47309
  _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
47259
47310
  }
47260
47311
  return _jsxNamespace;
47261
- function markAsSynthetic(node) {
47262
- ts.setTextRangePosEnd(node, -1, -1);
47263
- return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
47312
+ }
47313
+ function getLocalJsxNamespace(file) {
47314
+ if (file.localJsxNamespace) {
47315
+ return file.localJsxNamespace;
47316
+ }
47317
+ var jsxPragma = file.pragmas.get("jsx");
47318
+ if (jsxPragma) {
47319
+ var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
47320
+ file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
47321
+ ts.visitNode(file.localJsxFactory, markAsSynthetic);
47322
+ if (file.localJsxFactory) {
47323
+ return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
47324
+ }
47264
47325
  }
47265
47326
  }
47327
+ function markAsSynthetic(node) {
47328
+ ts.setTextRangePosEnd(node, -1, -1);
47329
+ return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
47330
+ }
47266
47331
  function getEmitResolver(sourceFile, cancellationToken) {
47267
47332
  // Ensure we have all the type information in place for this file so that all the
47268
47333
  // emitter questions of this resolver will return the right information.
@@ -48689,7 +48754,21 @@ var ts;
48689
48754
  function isSyntacticDefault(node) {
48690
48755
  return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
48691
48756
  }
48692
- function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
48757
+ function getUsageModeForExpression(usage) {
48758
+ return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
48759
+ }
48760
+ function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
48761
+ return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
48762
+ }
48763
+ function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
48764
+ var usageMode = file && getUsageModeForExpression(usage);
48765
+ if (file && usageMode !== undefined) {
48766
+ var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
48767
+ if (usageMode === ts.ModuleKind.ESNext || result) {
48768
+ return result;
48769
+ }
48770
+ // fallthrough on cjs usages so we imply defaults for interop'd imports, too
48771
+ }
48693
48772
  if (!allowSyntheticDefaultImports) {
48694
48773
  return false;
48695
48774
  }
@@ -48731,7 +48810,7 @@ var ts;
48731
48810
  exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
48732
48811
  }
48733
48812
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
48734
- var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
48813
+ var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
48735
48814
  if (!exportDefaultSymbol && !hasSyntheticDefault) {
48736
48815
  if (hasExportAssignmentSymbol(moduleSymbol)) {
48737
48816
  var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
@@ -48871,7 +48950,7 @@ var ts;
48871
48950
  var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
48872
48951
  if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
48873
48952
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
48874
- if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
48953
+ if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
48875
48954
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
48876
48955
  }
48877
48956
  }
@@ -49562,7 +49641,7 @@ var ts;
49562
49641
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
49563
49642
  }
49564
49643
  if (sigs && sigs.length) {
49565
- var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
49644
+ var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
49566
49645
  // Create a new symbol which has the module's type less the call and construct signatures
49567
49646
  var result = createSymbol(symbol.flags, symbol.escapedName);
49568
49647
  result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
@@ -57258,7 +57337,7 @@ var ts;
57258
57337
  else if (type !== firstType) {
57259
57338
  checkFlags |= 64 /* HasNonUniformType */;
57260
57339
  }
57261
- if (isLiteralType(type)) {
57340
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
57262
57341
  checkFlags |= 128 /* HasLiteralType */;
57263
57342
  }
57264
57343
  if (type.flags & 131072 /* Never */) {
@@ -61652,7 +61731,7 @@ var ts;
61652
61731
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body);
61653
61732
  }
61654
61733
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
61655
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
61734
+ return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
61656
61735
  isContextSensitiveFunctionLikeDeclaration(func);
61657
61736
  }
61658
61737
  function getTypeWithoutSignatures(type) {
@@ -62524,7 +62603,8 @@ var ts;
62524
62603
  var sourceStack;
62525
62604
  var targetStack;
62526
62605
  var maybeCount = 0;
62527
- var depth = 0;
62606
+ var sourceDepth = 0;
62607
+ var targetDepth = 0;
62528
62608
  var expandingFlags = 0 /* None */;
62529
62609
  var overflow = false;
62530
62610
  var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
@@ -62532,12 +62612,12 @@ var ts;
62532
62612
  var incompatibleStack = [];
62533
62613
  var inPropertyCheck = false;
62534
62614
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
62535
- var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
62615
+ var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
62536
62616
  if (incompatibleStack.length) {
62537
62617
  reportIncompatibleStack();
62538
62618
  }
62539
62619
  if (overflow) {
62540
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
62620
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth });
62541
62621
  var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
62542
62622
  if (errorOutputContainer) {
62543
62623
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -62817,13 +62897,17 @@ var ts;
62817
62897
  }
62818
62898
  return true;
62819
62899
  }
62900
+ function isRelatedToWorker(source, target, reportErrors) {
62901
+ return isRelatedTo(source, target, 3 /* Both */, reportErrors);
62902
+ }
62820
62903
  /**
62821
62904
  * Compare two types and return
62822
62905
  * * Ternary.True if they are related with no assumptions,
62823
62906
  * * Ternary.Maybe if they are related with assumptions of other relationships, or
62824
62907
  * * Ternary.False if they are not related.
62825
62908
  */
62826
- function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
62909
+ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) {
62910
+ if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; }
62827
62911
  if (reportErrors === void 0) { reportErrors = false; }
62828
62912
  if (intersectionState === void 0) { intersectionState = 0 /* None */; }
62829
62913
  // Before normalization: if `source` is type an object type, and `target` is primitive,
@@ -62844,7 +62928,7 @@ var ts;
62844
62928
  if (source === target)
62845
62929
  return -1 /* True */;
62846
62930
  if (relation === identityRelation) {
62847
- return isIdenticalTo(source, target);
62931
+ return isIdenticalTo(source, target, recursionFlags);
62848
62932
  }
62849
62933
  // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
62850
62934
  // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
@@ -62895,8 +62979,8 @@ var ts;
62895
62979
  var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
62896
62980
  var calls = getSignaturesOfType(source, 0 /* Call */);
62897
62981
  var constructs = getSignaturesOfType(source, 1 /* Construct */);
62898
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
62899
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
62982
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
62983
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
62900
62984
  reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
62901
62985
  }
62902
62986
  else {
@@ -62913,11 +62997,11 @@ var ts;
62913
62997
  // and we need to handle "each" relations before "some" relations for the same kind of type.
62914
62998
  if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
62915
62999
  result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
62916
- recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */) :
63000
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
62917
63001
  structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
62918
63002
  }
62919
63003
  if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
62920
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
63004
+ if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
62921
63005
  resetErrorInfo(saveErrorInfo);
62922
63006
  }
62923
63007
  }
@@ -62939,7 +63023,7 @@ var ts;
62939
63023
  if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
62940
63024
  if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
62941
63025
  // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
62942
- if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63026
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
62943
63027
  resetErrorInfo(saveErrorInfo);
62944
63028
  }
62945
63029
  }
@@ -62963,7 +63047,7 @@ var ts;
62963
63047
  if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
62964
63048
  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 */); }))) {
62965
63049
  inPropertyCheck = true;
62966
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */);
63050
+ result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
62967
63051
  inPropertyCheck = false;
62968
63052
  }
62969
63053
  reportErrorResults(source, target, result, isComparingJsxAttributes);
@@ -63038,7 +63122,7 @@ var ts;
63038
63122
  }
63039
63123
  }
63040
63124
  }
63041
- function isIdenticalTo(source, target) {
63125
+ function isIdenticalTo(source, target, recursionFlags) {
63042
63126
  if (source.flags !== target.flags)
63043
63127
  return 0 /* False */;
63044
63128
  if (source.flags & 67358815 /* Singleton */)
@@ -63051,7 +63135,7 @@ var ts;
63051
63135
  }
63052
63136
  return result_7;
63053
63137
  }
63054
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */);
63138
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63055
63139
  }
63056
63140
  function getTypeOfPropertyInTypes(types, name) {
63057
63141
  var appendPropType = function (propTypes, type) {
@@ -63132,7 +63216,7 @@ var ts;
63132
63216
  }
63133
63217
  return { value: true };
63134
63218
  }
63135
- if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
63219
+ if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) {
63136
63220
  if (reportErrors) {
63137
63221
  reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
63138
63222
  }
@@ -63172,7 +63256,7 @@ var ts;
63172
63256
  }
63173
63257
  var match = getMatchingUnionConstituentForType(target, source);
63174
63258
  if (match) {
63175
- var related = isRelatedTo(source, match, /*reportErrors*/ false);
63259
+ var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false);
63176
63260
  if (related) {
63177
63261
  return related;
63178
63262
  }
@@ -63180,14 +63264,14 @@ var ts;
63180
63264
  }
63181
63265
  for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
63182
63266
  var type = targetTypes_1[_i];
63183
- var related = isRelatedTo(source, type, /*reportErrors*/ false);
63267
+ var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false);
63184
63268
  if (related) {
63185
63269
  return related;
63186
63270
  }
63187
63271
  }
63188
63272
  if (reportErrors) {
63189
63273
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
63190
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
63274
+ isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
63191
63275
  }
63192
63276
  return 0 /* False */;
63193
63277
  }
@@ -63196,7 +63280,7 @@ var ts;
63196
63280
  var targetTypes = target.types;
63197
63281
  for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
63198
63282
  var targetType = targetTypes_2[_i];
63199
- var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, intersectionState);
63283
+ var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
63200
63284
  if (!related) {
63201
63285
  return 0 /* False */;
63202
63286
  }
@@ -63211,7 +63295,7 @@ var ts;
63211
63295
  }
63212
63296
  var len = sourceTypes.length;
63213
63297
  for (var i = 0; i < len; i++) {
63214
- var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
63298
+ var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
63215
63299
  if (related) {
63216
63300
  return related;
63217
63301
  }
@@ -63241,13 +63325,13 @@ var ts;
63241
63325
  // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`,
63242
63326
  // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}`
63243
63327
  // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union
63244
- var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
63328
+ var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
63245
63329
  if (related_1) {
63246
63330
  result &= related_1;
63247
63331
  continue;
63248
63332
  }
63249
63333
  }
63250
- var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState);
63334
+ var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
63251
63335
  if (!related) {
63252
63336
  return 0 /* False */;
63253
63337
  }
@@ -63279,31 +63363,31 @@ var ts;
63279
63363
  // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_.
63280
63364
  // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by
63281
63365
  // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be)
63282
- related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t);
63366
+ related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
63283
63367
  }
63284
63368
  else if (variance === 1 /* Covariant */) {
63285
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63369
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63286
63370
  }
63287
63371
  else if (variance === 2 /* Contravariant */) {
63288
- related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
63372
+ related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63289
63373
  }
63290
63374
  else if (variance === 3 /* Bivariant */) {
63291
63375
  // In the bivariant case we first compare contravariantly without reporting
63292
63376
  // errors. Then, if that doesn't succeed, we compare covariantly with error
63293
63377
  // reporting. Thus, error elaboration will be based on the the covariant check,
63294
63378
  // which is generally easier to reason about.
63295
- related = isRelatedTo(t, s, /*reportErrors*/ false);
63379
+ related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false);
63296
63380
  if (!related) {
63297
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63381
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63298
63382
  }
63299
63383
  }
63300
63384
  else {
63301
63385
  // In the invariant case we first compare covariantly, and only when that
63302
63386
  // succeeds do we proceed to compare contravariantly. Thus, error elaboration
63303
63387
  // will typically be based on the covariant check.
63304
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63388
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63305
63389
  if (related) {
63306
- related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
63390
+ related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63307
63391
  }
63308
63392
  }
63309
63393
  if (!related) {
@@ -63319,7 +63403,7 @@ var ts;
63319
63403
  // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
63320
63404
  // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
63321
63405
  // and issue an error. Otherwise, actually compare the structure of the two types.
63322
- function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
63406
+ function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) {
63323
63407
  if (overflow) {
63324
63408
  return 0 /* False */;
63325
63409
  }
@@ -63363,7 +63447,7 @@ var ts;
63363
63447
  return 3 /* Maybe */;
63364
63448
  }
63365
63449
  }
63366
- if (depth === 100) {
63450
+ if (sourceDepth === 100 || targetDepth === 100) {
63367
63451
  overflow = true;
63368
63452
  return 0 /* False */;
63369
63453
  }
@@ -63371,13 +63455,18 @@ var ts;
63371
63455
  var maybeStart = maybeCount;
63372
63456
  maybeKeys[maybeCount] = id;
63373
63457
  maybeCount++;
63374
- sourceStack[depth] = source;
63375
- targetStack[depth] = target;
63376
- depth++;
63458
+ if (recursionFlags & 1 /* Source */) {
63459
+ sourceStack[sourceDepth] = source;
63460
+ sourceDepth++;
63461
+ }
63462
+ if (recursionFlags & 2 /* Target */) {
63463
+ targetStack[targetDepth] = target;
63464
+ targetDepth++;
63465
+ }
63377
63466
  var saveExpandingFlags = expandingFlags;
63378
- if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, depth))
63467
+ if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63379
63468
  expandingFlags |= 1 /* Source */;
63380
- if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth))
63469
+ if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63381
63470
  expandingFlags |= 2 /* Target */;
63382
63471
  var originalHandler;
63383
63472
  var propagatingVarianceFlags = 0;
@@ -63394,7 +63483,8 @@ var ts;
63394
63483
  sourceIdStack: sourceStack.map(function (t) { return t.id; }),
63395
63484
  targetId: target.id,
63396
63485
  targetIdStack: targetStack.map(function (t) { return t.id; }),
63397
- depth: depth,
63486
+ depth: sourceDepth,
63487
+ targetDepth: targetDepth
63398
63488
  });
63399
63489
  }
63400
63490
  var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
@@ -63402,9 +63492,14 @@ var ts;
63402
63492
  outofbandVarianceMarkerHandler = originalHandler;
63403
63493
  }
63404
63494
  expandingFlags = saveExpandingFlags;
63405
- depth--;
63495
+ if (recursionFlags & 1 /* Source */) {
63496
+ sourceDepth--;
63497
+ }
63498
+ if (recursionFlags & 2 /* Target */) {
63499
+ targetDepth--;
63500
+ }
63406
63501
  if (result) {
63407
- if (result === -1 /* True */ || depth === 0) {
63502
+ if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
63408
63503
  if (result === -1 /* True */ || result === 3 /* Maybe */) {
63409
63504
  // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
63410
63505
  // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
@@ -63458,7 +63553,7 @@ var ts;
63458
63553
  if (constraints !== source.types) {
63459
63554
  source = getIntersectionType(constraints);
63460
63555
  if (!(source.flags & 2097152 /* Intersection */)) {
63461
- return isRelatedTo(source, target, /*reportErrors*/ false);
63556
+ return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
63462
63557
  }
63463
63558
  }
63464
63559
  }
@@ -63480,22 +63575,22 @@ var ts;
63480
63575
  var flags = source.flags & target.flags;
63481
63576
  if (relation === identityRelation && !(flags & 524288 /* Object */)) {
63482
63577
  if (flags & 4194304 /* Index */) {
63483
- return isRelatedTo(source.type, target.type, /*reportErrors*/ false);
63578
+ return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
63484
63579
  }
63485
63580
  var result_8 = 0 /* False */;
63486
63581
  if (flags & 8388608 /* IndexedAccess */) {
63487
- if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) {
63488
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) {
63582
+ if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
63583
+ if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
63489
63584
  return result_8;
63490
63585
  }
63491
63586
  }
63492
63587
  }
63493
63588
  if (flags & 16777216 /* Conditional */) {
63494
63589
  if (source.root.isDistributive === target.root.isDistributive) {
63495
- if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) {
63496
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) {
63497
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) {
63498
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) {
63590
+ if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
63591
+ if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
63592
+ if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
63593
+ if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
63499
63594
  return result_8;
63500
63595
  }
63501
63596
  }
@@ -63504,7 +63599,7 @@ var ts;
63504
63599
  }
63505
63600
  }
63506
63601
  if (flags & 33554432 /* Substitution */) {
63507
- return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false);
63602
+ return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
63508
63603
  }
63509
63604
  return 0 /* False */;
63510
63605
  }
@@ -63529,17 +63624,17 @@ var ts;
63529
63624
  }
63530
63625
  // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T],
63531
63626
  // and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
63532
- if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
63533
- isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
63627
+ if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) ||
63628
+ isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
63534
63629
  return result;
63535
63630
  }
63536
63631
  if (target.flags & 262144 /* TypeParameter */) {
63537
63632
  // 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].
63538
- if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
63633
+ if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
63539
63634
  if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
63540
63635
  var templateType = getTemplateTypeFromMappedType(source);
63541
63636
  var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
63542
- if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
63637
+ if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) {
63543
63638
  return result;
63544
63639
  }
63545
63640
  }
@@ -63549,14 +63644,14 @@ var ts;
63549
63644
  var targetType_1 = target.type;
63550
63645
  // A keyof S is related to a keyof T if T is related to S.
63551
63646
  if (source.flags & 4194304 /* Index */) {
63552
- if (result = isRelatedTo(targetType_1, source.type, /*reportErrors*/ false)) {
63647
+ if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
63553
63648
  return result;
63554
63649
  }
63555
63650
  }
63556
63651
  if (isTupleType(targetType_1)) {
63557
63652
  // An index type can have a tuple type target when the tuple type contains variadic elements.
63558
63653
  // Check if the source is related to the known keys of the tuple type.
63559
- if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), reportErrors)) {
63654
+ if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) {
63560
63655
  return result;
63561
63656
  }
63562
63657
  }
@@ -63569,7 +63664,7 @@ var ts;
63569
63664
  // false positives. For example, given 'T extends { [K in keyof T]: string }',
63570
63665
  // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
63571
63666
  // related to other types.
63572
- if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1 /* True */) {
63667
+ if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) {
63573
63668
  return -1 /* True */;
63574
63669
  }
63575
63670
  }
@@ -63593,7 +63688,7 @@ var ts;
63593
63688
  else {
63594
63689
  targetKeys = nameType_1 || constraintType;
63595
63690
  }
63596
- if (isRelatedTo(source, targetKeys, reportErrors) === -1 /* True */) {
63691
+ if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) {
63597
63692
  return -1 /* True */;
63598
63693
  }
63599
63694
  }
@@ -63603,8 +63698,8 @@ var ts;
63603
63698
  if (source.flags & 8388608 /* IndexedAccess */) {
63604
63699
  // Relate components directly before falling back to constraint relationships
63605
63700
  // A type S[K] is related to a type T[J] if S is related to T and K is related to J.
63606
- if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
63607
- result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
63701
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
63702
+ result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
63608
63703
  }
63609
63704
  if (result) {
63610
63705
  resetErrorInfo(saveErrorInfo);
@@ -63629,7 +63724,7 @@ var ts;
63629
63724
  // create a new chain for the constraint error
63630
63725
  resetErrorInfo(saveErrorInfo);
63631
63726
  }
63632
- if (result = isRelatedTo(source, constraint, reportErrors)) {
63727
+ if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
63633
63728
  return result;
63634
63729
  }
63635
63730
  // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -63669,13 +63764,14 @@ var ts;
63669
63764
  // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`.
63670
63765
  if (includeOptional
63671
63766
  ? !(filteredByApplicability.flags & 131072 /* Never */)
63672
- : isRelatedTo(targetKeys, sourceKeys)) {
63767
+ : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
63768
+ var templateType_1 = getTemplateTypeFromMappedType(target);
63673
63769
  var typeParameter = getTypeParameterFromMappedType(target);
63674
63770
  // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj`
63675
63771
  // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`.
63676
- var nonNullComponent = extractTypesOfKind(templateType, ~98304 /* Nullable */);
63772
+ var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */);
63677
63773
  if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
63678
- if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
63774
+ if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) {
63679
63775
  return result;
63680
63776
  }
63681
63777
  }
@@ -63695,7 +63791,7 @@ var ts;
63695
63791
  : typeParameter;
63696
63792
  var indexedAccessType = getIndexedAccessType(source, indexingType);
63697
63793
  // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type.
63698
- if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
63794
+ if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) {
63699
63795
  return result;
63700
63796
  }
63701
63797
  }
@@ -63722,10 +63818,11 @@ var ts;
63722
63818
  newParam.mapper = distributionMapper;
63723
63819
  }
63724
63820
  // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
63725
- var localResult = void 0;
63726
- if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) {
63727
- if (!skipFalse) {
63728
- localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false);
63821
+ var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
63822
+ var localResult = expanding ? 3 /* Maybe */ : undefined;
63823
+ if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
63824
+ if (!skipFalse && !expanding) {
63825
+ localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
63729
63826
  }
63730
63827
  }
63731
63828
  if (localResult) {
@@ -63735,6 +63832,9 @@ var ts;
63735
63832
  }
63736
63833
  else if (target.flags & 134217728 /* TemplateLiteral */) {
63737
63834
  if (source.flags & 134217728 /* TemplateLiteral */) {
63835
+ if (relation === comparableRelation) {
63836
+ return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
63837
+ }
63738
63838
  // Report unreliable variance for type variables referenced in template literal type placeholders.
63739
63839
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
63740
63840
  instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
@@ -63750,34 +63850,33 @@ var ts;
63750
63850
  var constraint = getConstraintOfType(source);
63751
63851
  if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
63752
63852
  // A type variable with no constraint is not related to the non-primitive object type.
63753
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
63853
+ if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
63754
63854
  resetErrorInfo(saveErrorInfo);
63755
63855
  return result;
63756
63856
  }
63757
63857
  }
63758
63858
  // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
63759
- else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63859
+ else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63760
63860
  resetErrorInfo(saveErrorInfo);
63761
63861
  return result;
63762
63862
  }
63763
63863
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
63764
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
63864
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
63765
63865
  resetErrorInfo(saveErrorInfo);
63766
63866
  return result;
63767
63867
  }
63768
63868
  }
63769
63869
  }
63770
63870
  else if (source.flags & 4194304 /* Index */) {
63771
- if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
63871
+ if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
63772
63872
  resetErrorInfo(saveErrorInfo);
63773
63873
  return result;
63774
63874
  }
63775
63875
  }
63776
- else if (source.flags & 134217728 /* TemplateLiteral */) {
63876
+ else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
63777
63877
  if (!(target.flags & 134217728 /* TemplateLiteral */)) {
63778
- var baseConstraint = getBaseConstraintOfType(source);
63779
- var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType;
63780
- if (result = isRelatedTo(constraint, target, reportErrors)) {
63878
+ var constraint = getBaseConstraintOfType(source);
63879
+ if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
63781
63880
  resetErrorInfo(saveErrorInfo);
63782
63881
  return result;
63783
63882
  }
@@ -63785,14 +63884,14 @@ var ts;
63785
63884
  }
63786
63885
  else if (source.flags & 268435456 /* StringMapping */) {
63787
63886
  if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
63788
- if (result = isRelatedTo(source.type, target.type, reportErrors)) {
63887
+ if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
63789
63888
  resetErrorInfo(saveErrorInfo);
63790
63889
  return result;
63791
63890
  }
63792
63891
  }
63793
63892
  else {
63794
63893
  var constraint = getBaseConstraintOfType(source);
63795
- if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
63894
+ if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
63796
63895
  resetErrorInfo(saveErrorInfo);
63797
63896
  return result;
63798
63897
  }
@@ -63800,27 +63899,32 @@ var ts;
63800
63899
  }
63801
63900
  else if (source.flags & 16777216 /* Conditional */) {
63802
63901
  if (target.flags & 16777216 /* Conditional */) {
63803
- // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
63804
- // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
63805
- // and Y1 is related to Y2.
63806
- var sourceParams = source.root.inferTypeParameters;
63807
- var sourceExtends = source.extendsType;
63808
- var mapper = void 0;
63809
- if (sourceParams) {
63810
- // If the source has infer type parameters, we instantiate them in the context of the target
63811
- var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo);
63812
- inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
63813
- sourceExtends = instantiateType(sourceExtends, ctx.mapper);
63814
- mapper = ctx.mapper;
63815
- }
63816
- if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
63817
- (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
63818
- if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
63819
- result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
63820
- }
63821
- if (result) {
63822
- resetErrorInfo(saveErrorInfo);
63823
- return result;
63902
+ // If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
63903
+ // the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
63904
+ // types, which might expand forever.
63905
+ if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
63906
+ // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
63907
+ // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
63908
+ // and Y1 is related to Y2.
63909
+ var sourceParams = source.root.inferTypeParameters;
63910
+ var sourceExtends = source.extendsType;
63911
+ var mapper = void 0;
63912
+ if (sourceParams) {
63913
+ // If the source has infer type parameters, we instantiate them in the context of the target
63914
+ var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
63915
+ inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
63916
+ sourceExtends = instantiateType(sourceExtends, ctx.mapper);
63917
+ mapper = ctx.mapper;
63918
+ }
63919
+ if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
63920
+ (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
63921
+ if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
63922
+ result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
63923
+ }
63924
+ if (result) {
63925
+ resetErrorInfo(saveErrorInfo);
63926
+ return result;
63927
+ }
63824
63928
  }
63825
63929
  }
63826
63930
  }
@@ -63829,19 +63933,23 @@ var ts;
63829
63933
  // more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
63830
63934
  var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
63831
63935
  if (distributiveConstraint) {
63832
- if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
63936
+ if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
63833
63937
  resetErrorInfo(saveErrorInfo);
63834
63938
  return result;
63835
63939
  }
63836
63940
  }
63837
63941
  }
63838
- // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
63839
- // when `O` is a conditional (`never` is trivially aissgnable to `O`, as is `O`!).
63840
- var defaultConstraint = getDefaultConstraintOfConditionalType(source);
63841
- if (defaultConstraint) {
63842
- if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
63843
- resetErrorInfo(saveErrorInfo);
63844
- return result;
63942
+ // We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
63943
+ // on the comparison.
63944
+ if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
63945
+ // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
63946
+ // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
63947
+ var defaultConstraint = getDefaultConstraintOfConditionalType(source);
63948
+ if (defaultConstraint) {
63949
+ if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
63950
+ resetErrorInfo(saveErrorInfo);
63951
+ return result;
63952
+ }
63845
63953
  }
63846
63954
  }
63847
63955
  }
@@ -63885,7 +63993,7 @@ var ts;
63885
63993
  }
63886
63994
  else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
63887
63995
  if (relation !== identityRelation) {
63888
- return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors);
63996
+ return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
63889
63997
  }
63890
63998
  else {
63891
63999
  // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple
@@ -64007,10 +64115,10 @@ var ts;
64007
64115
  var result_11;
64008
64116
  var targetConstraint = getConstraintTypeFromMappedType(target);
64009
64117
  var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
64010
- if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
64118
+ if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64011
64119
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
64012
64120
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
64013
- return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
64121
+ return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64014
64122
  }
64015
64123
  }
64016
64124
  }
@@ -64142,7 +64250,7 @@ var ts;
64142
64250
  var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */);
64143
64251
  var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
64144
64252
  var effectiveSource = getTypeOfSourceProperty(sourceProp);
64145
- return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState);
64253
+ return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
64146
64254
  }
64147
64255
  function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
64148
64256
  var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
@@ -64324,7 +64432,7 @@ var ts;
64324
64432
  var targetType = targetTypeArguments[i];
64325
64433
  var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) :
64326
64434
  removeMissingType(targetType, !!(targetFlags & 2 /* Optional */));
64327
- var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState);
64435
+ var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
64328
64436
  if (!related) {
64329
64437
  if (reportErrors && (targetArity > 1 || sourceArity > 1)) {
64330
64438
  if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
@@ -64518,7 +64626,7 @@ var ts;
64518
64626
  * See signatureAssignableTo, compareSignaturesIdentical
64519
64627
  */
64520
64628
  function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
64521
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
64629
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
64522
64630
  }
64523
64631
  function signaturesIdenticalTo(source, target, kind) {
64524
64632
  var sourceSignatures = getSignaturesOfType(source, kind);
@@ -64551,7 +64659,7 @@ var ts;
64551
64659
  var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */)
64552
64660
  ? propType
64553
64661
  : getTypeWithFacts(propType, 524288 /* NEUndefined */);
64554
- var related = isRelatedTo(type, targetInfo.type, reportErrors);
64662
+ var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors);
64555
64663
  if (!related) {
64556
64664
  if (reportErrors) {
64557
64665
  reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
@@ -64574,7 +64682,7 @@ var ts;
64574
64682
  return result;
64575
64683
  }
64576
64684
  function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) {
64577
- var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors);
64685
+ var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors);
64578
64686
  if (!related && reportErrors) {
64579
64687
  if (sourceInfo.keyType === targetInfo.keyType) {
64580
64688
  reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
@@ -64595,7 +64703,7 @@ var ts;
64595
64703
  for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
64596
64704
  var targetInfo = indexInfos_3[_i];
64597
64705
  var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
64598
- isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) :
64706
+ isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
64599
64707
  typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
64600
64708
  if (!related) {
64601
64709
  return 0 /* False */;
@@ -64627,7 +64735,7 @@ var ts;
64627
64735
  for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) {
64628
64736
  var targetInfo = targetInfos_1[_i];
64629
64737
  var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType);
64630
- if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
64738
+ if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
64631
64739
  return 0 /* False */;
64632
64740
  }
64633
64741
  }
@@ -66041,6 +66149,17 @@ var ts;
66041
66149
  function isFromInferenceBlockedSource(type) {
66042
66150
  return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
66043
66151
  }
66152
+ function templateLiteralTypesDefinitelyUnrelated(source, target) {
66153
+ // Two template literal types with diffences in their starting or ending text spans are definitely unrelated.
66154
+ var sourceStart = source.texts[0];
66155
+ var targetStart = target.texts[0];
66156
+ var sourceEnd = source.texts[source.texts.length - 1];
66157
+ var targetEnd = target.texts[target.texts.length - 1];
66158
+ var startLen = Math.min(sourceStart.length, targetStart.length);
66159
+ var endLen = Math.min(sourceEnd.length, targetEnd.length);
66160
+ return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
66161
+ sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
66162
+ }
66044
66163
  function isValidBigIntString(s) {
66045
66164
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
66046
66165
  var success = true;
@@ -67103,7 +67222,7 @@ var ts;
67103
67222
  if (prop.isDiscriminantProperty === undefined) {
67104
67223
  prop.isDiscriminantProperty =
67105
67224
  (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ &&
67106
- !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */ & ~134217728 /* TemplateLiteral */);
67225
+ !isGenericType(getTypeOfSymbol(prop));
67107
67226
  }
67108
67227
  return !!prop.isDiscriminantProperty;
67109
67228
  }
@@ -67622,17 +67741,19 @@ var ts;
67622
67741
  function extractTypesOfKind(type, kind) {
67623
67742
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
67624
67743
  }
67625
- // Return a new type in which occurrences of the string and number primitive types in
67626
- // typeWithPrimitives have been replaced with occurrences of string literals and numeric
67627
- // literals in typeWithLiterals, respectively.
67744
+ // Return a new type in which occurrences of the string, number and bigint primitives and placeholder template
67745
+ // literal types in typeWithPrimitives have been replaced with occurrences of compatible and more specific types
67746
+ // from typeWithLiterals. This is essentially a limited form of intersection between the two types. We avoid a
67747
+ // true intersection because it is more costly and, when applied to union types, generates a large number of
67748
+ // types we don't actually care about.
67628
67749
  function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
67629
- if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) ||
67630
- isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) ||
67631
- isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) {
67750
+ if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) &&
67751
+ maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
67632
67752
  return mapType(typeWithPrimitives, function (t) {
67633
- return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) :
67634
- t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
67635
- t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
67753
+ return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) :
67754
+ isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) :
67755
+ t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
67756
+ t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
67636
67757
  });
67637
67758
  }
67638
67759
  return typeWithPrimitives;
@@ -67713,10 +67834,10 @@ var ts;
67713
67834
  isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */);
67714
67835
  return isLengthPushOrUnshift || isElementAssignment;
67715
67836
  }
67716
- function isDeclarationWithExplicitTypeAnnotation(declaration) {
67717
- return (declaration.kind === 253 /* VariableDeclaration */ || declaration.kind === 163 /* Parameter */ ||
67718
- declaration.kind === 166 /* PropertyDeclaration */ || declaration.kind === 165 /* PropertySignature */) &&
67719
- !!ts.getEffectiveTypeAnnotationNode(declaration);
67837
+ function isDeclarationWithExplicitTypeAnnotation(node) {
67838
+ return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) &&
67839
+ !!(ts.getEffectiveTypeAnnotationNode(node) ||
67840
+ ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
67720
67841
  }
67721
67842
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
67722
67843
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) {
@@ -68433,7 +68554,7 @@ var ts;
68433
68554
  var narrowedPropType = narrowType(propType);
68434
68555
  return filterType(type, function (t) {
68435
68556
  var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
68436
- return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType);
68557
+ return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
68437
68558
  });
68438
68559
  }
68439
68560
  function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) {
@@ -68902,16 +69023,7 @@ var ts;
68902
69023
  }
68903
69024
  function getNarrowedType(type, candidate, assumeTrue, isRelated) {
68904
69025
  if (!assumeTrue) {
68905
- return filterType(type, function (t) {
68906
- if (!isRelated(t, candidate)) {
68907
- return true;
68908
- }
68909
- var constraint = getBaseConstraintOfType(t);
68910
- if (constraint && constraint !== t) {
68911
- return !isRelated(constraint, candidate);
68912
- }
68913
- return false;
68914
- });
69026
+ return filterType(type, function (t) { return !isRelated(t, candidate); });
68915
69027
  }
68916
69028
  // If the current type is a union type, remove all constituents that couldn't be instances of
68917
69029
  // the candidate type. If one or more constituents remain, return a union of those.
@@ -70813,12 +70925,9 @@ var ts;
70813
70925
  }
70814
70926
  return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
70815
70927
  }
70816
- function isFunctionExpressionOrArrowFunction(node) {
70817
- return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
70818
- }
70819
70928
  function getContextualSignatureForFunctionLikeDeclaration(node) {
70820
70929
  // Only function expressions, arrow functions, and object literal methods are contextually typed.
70821
- return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
70930
+ return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
70822
70931
  ? getContextualSignature(node)
70823
70932
  : undefined;
70824
70933
  }
@@ -71785,6 +71894,14 @@ var ts;
71785
71894
  markAliasSymbolAsReferenced(jsxFactorySym);
71786
71895
  }
71787
71896
  }
71897
+ // For JsxFragment, mark jsx pragma as referenced via resolveName
71898
+ if (ts.isJsxOpeningFragment(node)) {
71899
+ var file = ts.getSourceFileOfNode(node);
71900
+ var localJsxNamespace = getLocalJsxNamespace(file);
71901
+ if (localJsxNamespace) {
71902
+ resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
71903
+ }
71904
+ }
71788
71905
  }
71789
71906
  if (isNodeOpeningLikeElement) {
71790
71907
  var jsxOpeningLikeNode = node;
@@ -73457,7 +73574,7 @@ var ts;
73457
73574
  return false;
73458
73575
  var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false);
73459
73576
  var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
73460
- if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
73577
+ if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
73461
73578
  return false;
73462
73579
  }
73463
73580
  var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
@@ -74701,18 +74818,18 @@ var ts;
74701
74818
  if (moduleSymbol) {
74702
74819
  var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
74703
74820
  if (esModuleSymbol) {
74704
- return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
74821
+ return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
74705
74822
  }
74706
74823
  }
74707
74824
  return createPromiseReturnType(node, anyType);
74708
74825
  }
74709
- function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
74826
+ function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
74710
74827
  var _a;
74711
74828
  if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
74712
74829
  var synthType = type;
74713
74830
  if (!synthType.syntheticType) {
74714
74831
  var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
74715
- var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
74832
+ var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
74716
74833
  if (hasSyntheticDefault) {
74717
74834
  var memberTable = ts.createSymbolTable();
74718
74835
  var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
@@ -74874,16 +74991,14 @@ var ts;
74874
74991
  }
74875
74992
  }
74876
74993
  function checkImportMetaProperty(node) {
74877
- if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
74878
- if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
74879
- if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
74880
- error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
74881
- }
74882
- }
74883
- else {
74884
- error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
74994
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
74995
+ if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
74996
+ error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
74885
74997
  }
74886
74998
  }
74999
+ else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) {
75000
+ error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
75001
+ }
74887
75002
  var file = ts.getSourceFileOfNode(node);
74888
75003
  ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
74889
75004
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
@@ -75826,9 +75941,9 @@ var ts;
75826
75941
  var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
75827
75942
  diagnostics.add(diagnostic);
75828
75943
  }
75829
- if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
75944
+ if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
75830
75945
  span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
75831
- var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
75946
+ var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
75832
75947
  diagnostics.add(diagnostic);
75833
75948
  }
75834
75949
  }
@@ -77266,7 +77381,7 @@ var ts;
77266
77381
  }
77267
77382
  }
77268
77383
  function checkParenthesizedExpression(node, checkMode) {
77269
- if (ts.isJSDocTypeAssertion(node)) {
77384
+ if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) {
77270
77385
  var type = ts.getJSDocTypeAssertionType(node);
77271
77386
  return checkAssertionWorker(type, type, node.expression, checkMode);
77272
77387
  }
@@ -79163,6 +79278,12 @@ var ts;
79163
79278
  }
79164
79279
  }
79165
79280
  }
79281
+ function checkJSDocAccessibilityModifiers(node) {
79282
+ var host = ts.getJSDocHost(node);
79283
+ if (host && ts.isPrivateIdentifierClassElementDeclaration(host)) {
79284
+ error(node, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
79285
+ }
79286
+ }
79166
79287
  function getIdentifierFromEntityNameExpression(node) {
79167
79288
  switch (node.kind) {
79168
79289
  case 79 /* Identifier */:
@@ -82816,6 +82937,10 @@ var ts;
82816
82937
  return;
82817
82938
  case 307 /* JSDocTypeExpression */:
82818
82939
  return checkSourceElement(node.type);
82940
+ case 331 /* JSDocPublicTag */:
82941
+ case 333 /* JSDocProtectedTag */:
82942
+ case 332 /* JSDocPrivateTag */:
82943
+ return checkJSDocAccessibilityModifiers(node);
82819
82944
  case 193 /* IndexedAccessType */:
82820
82945
  return checkIndexedAccessType(node);
82821
82946
  case 194 /* MappedType */:
@@ -85511,8 +85636,8 @@ var ts;
85511
85636
  if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
85512
85637
  diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
85513
85638
  }
85514
- if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
85515
- diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
85639
+ if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
85640
+ diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
85516
85641
  }
85517
85642
  }
85518
85643
  }
@@ -86201,7 +86326,7 @@ var ts;
86201
86326
  }
86202
86327
  function checkGrammarImportCallExpression(node) {
86203
86328
  if (moduleKind === ts.ModuleKind.ES2015) {
86204
- return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext);
86329
+ return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext);
86205
86330
  }
86206
86331
  if (node.typeArguments) {
86207
86332
  return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
@@ -87315,7 +87440,7 @@ var ts;
87315
87440
  }
87316
87441
  ts.createSourceMapGenerator = createSourceMapGenerator;
87317
87442
  // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
87318
- var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
87443
+ var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
87319
87444
  var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
87320
87445
  function getLineInfo(text, lineStarts) {
87321
87446
  return {
@@ -90607,6 +90732,7 @@ var ts;
90607
90732
  || (isExternalModuleExport(node)
90608
90733
  && moduleKind !== ts.ModuleKind.ES2015
90609
90734
  && moduleKind !== ts.ModuleKind.ES2020
90735
+ && moduleKind !== ts.ModuleKind.ES2022
90610
90736
  && moduleKind !== ts.ModuleKind.ESNext
90611
90737
  && moduleKind !== ts.ModuleKind.System);
90612
90738
  }
@@ -106285,6 +106411,7 @@ var ts;
106285
106411
  function getModuleTransformer(moduleKind) {
106286
106412
  switch (moduleKind) {
106287
106413
  case ts.ModuleKind.ESNext:
106414
+ case ts.ModuleKind.ES2022:
106288
106415
  case ts.ModuleKind.ES2020:
106289
106416
  case ts.ModuleKind.ES2015:
106290
106417
  return ts.transformECMAScriptModule;
@@ -118816,6 +118943,78 @@ var ts;
118816
118943
  }
118817
118944
  }
118818
118945
  }
118946
+ var MatchingMode;
118947
+ (function (MatchingMode) {
118948
+ MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
118949
+ MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
118950
+ MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
118951
+ })(MatchingMode || (MatchingMode = {}));
118952
+ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
118953
+ if (mode === void 0) { mode = 0 /* Exact */; }
118954
+ if (typeof exports === "string") {
118955
+ var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
118956
+ var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
118957
+ switch (mode) {
118958
+ case 0 /* Exact */:
118959
+ if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
118960
+ return { moduleFileToTry: packageName };
118961
+ }
118962
+ break;
118963
+ case 1 /* Directory */:
118964
+ if (ts.containsPath(pathOrPattern, targetFilePath)) {
118965
+ var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
118966
+ return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
118967
+ }
118968
+ break;
118969
+ case 2 /* Pattern */:
118970
+ var starPos = pathOrPattern.indexOf("*");
118971
+ var leadingSlice = pathOrPattern.slice(0, starPos);
118972
+ var trailingSlice = pathOrPattern.slice(starPos + 1);
118973
+ if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
118974
+ var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
118975
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
118976
+ }
118977
+ if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
118978
+ var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
118979
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
118980
+ }
118981
+ break;
118982
+ }
118983
+ }
118984
+ else if (Array.isArray(exports)) {
118985
+ return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
118986
+ }
118987
+ else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
118988
+ if (ts.allKeysStartWithDot(exports)) {
118989
+ // sub-mappings
118990
+ // 3 cases:
118991
+ // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
118992
+ // * pattern mappings (contains a *)
118993
+ // * exact mappings (no *, does not end with /)
118994
+ return ts.forEach(ts.getOwnKeys(exports), function (k) {
118995
+ var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
118996
+ var mode = ts.endsWith(k, "/") ? 1 /* Directory */
118997
+ : ts.stringContains(k, "*") ? 2 /* Pattern */
118998
+ : 0 /* Exact */;
118999
+ return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
119000
+ });
119001
+ }
119002
+ else {
119003
+ // conditional mapping
119004
+ for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
119005
+ var key = _a[_i];
119006
+ if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
119007
+ var subTarget = exports[key];
119008
+ var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
119009
+ if (result) {
119010
+ return result;
119011
+ }
119012
+ }
119013
+ }
119014
+ }
119015
+ }
119016
+ return undefined;
119017
+ }
118819
119018
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
118820
119019
  var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
118821
119020
  if (normalizedTargetPath === undefined) {
@@ -118845,7 +119044,15 @@ var ts;
118845
119044
  var moduleFileNameForExtensionless = void 0;
118846
119045
  while (true) {
118847
119046
  // If the module could be imported by a directory name, use that directory's name
118848
- var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
119047
+ var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
119048
+ if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
119049
+ if (blockedByExports) {
119050
+ return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
119051
+ }
119052
+ if (verbatimFromExports) {
119053
+ return moduleFileToTry;
119054
+ }
119055
+ }
118849
119056
  if (packageRootPath) {
118850
119057
  moduleSpecifier = packageRootPath;
118851
119058
  isPackageRootPath = true;
@@ -118875,13 +119082,22 @@ var ts;
118875
119082
  var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
118876
119083
  var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
118877
119084
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
118878
- return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
119085
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
118879
119086
  function tryDirectoryWithPackageJson(packageRootIndex) {
118880
119087
  var packageRootPath = path.substring(0, packageRootIndex);
118881
119088
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
118882
119089
  var moduleFileToTry = path;
118883
119090
  if (host.fileExists(packageJsonPath)) {
118884
119091
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119092
+ // TODO: Inject `require` or `import` condition based on the intended import mode
119093
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119094
+ if (fromExports) {
119095
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119096
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119097
+ }
119098
+ if (packageJsonContent.exports) {
119099
+ return { moduleFileToTry: path, blockedByExports: true };
119100
+ }
118885
119101
  var versionPaths = packageJsonContent.typesVersions
118886
119102
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
118887
119103
  : undefined;
@@ -138014,6 +138230,7 @@ var ts;
138014
138230
  return false;
138015
138231
  }
138016
138232
  }
138233
+ Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
138017
138234
  })(Rename = ts.Rename || (ts.Rename = {}));
138018
138235
  })(ts || (ts = {}));
138019
138236
  /* @internal */
@@ -139135,7 +139352,7 @@ var ts;
139135
139352
  if (!typeDisplayString) {
139136
139353
  continue;
139137
139354
  }
139138
- addTypeHints(typeDisplayString, param.end);
139355
+ addTypeHints(typeDisplayString, param.name.end);
139139
139356
  }
139140
139357
  }
139141
139358
  function getParameterDeclarationTypeDisplayString(symbol) {
@@ -147947,6 +148164,7 @@ var ts;
147947
148164
  case ts.ModuleKind.System:
147948
148165
  case ts.ModuleKind.ES2015:
147949
148166
  case ts.ModuleKind.ES2020:
148167
+ case ts.ModuleKind.ES2022:
147950
148168
  case ts.ModuleKind.ESNext:
147951
148169
  case ts.ModuleKind.None:
147952
148170
  // Fall back to the `import * as ns` style import.
@@ -149714,8 +149932,8 @@ var ts;
149714
149932
  (function (codefix) {
149715
149933
  codefix.registerCodeFix({
149716
149934
  errorCodes: [
149717
- ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
149718
- ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
149935
+ ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
149936
+ ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
149719
149937
  ],
149720
149938
  getCodeActions: function (context) {
149721
149939
  var compilerOptions = context.program.getCompilerOptions();
@@ -159309,6 +159527,8 @@ var ts;
159309
159527
  synchronizeHostData();
159310
159528
  var sourceFile = getValidSourceFile(fileName);
159311
159529
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
159530
+ if (!ts.Rename.nodeIsEligibleForRename(node))
159531
+ return undefined;
159312
159532
  if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
159313
159533
  var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
159314
159534
  return [openingElement, closingElement].map(function (node) {
@@ -170407,11 +170627,13 @@ var ts;
170407
170627
  var file = server.toNormalizedPath(args.file);
170408
170628
  var position = this.getPositionInFile(args, file);
170409
170629
  var projects = this.getProjects(args);
170410
- var locations = combineProjectOutputForRenameLocations(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170411
- if (!simplifiedResult)
170412
- return locations;
170413
170630
  var defaultProject = this.getDefaultProject(args);
170414
170631
  var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
170632
+ if (!renameInfo.canRename)
170633
+ return simplifiedResult ? { info: renameInfo, locs: [] } : [];
170634
+ var locations = combineProjectOutputForRenameLocations(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
170635
+ if (!simplifiedResult)
170636
+ return locations;
170415
170637
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
170416
170638
  };
170417
170639
  Session.prototype.mapRenameInfo = function (info, scriptInfo) {