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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20210928";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211002";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5348,6 +5348,7 @@ var ts;
5348
5348
  // module kind).
5349
5349
  ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
5350
5350
  ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
5351
+ ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022";
5351
5352
  ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
5352
5353
  // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
5353
5354
  ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
@@ -8265,7 +8266,7 @@ var ts;
8265
8266
  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."),
8266
8267
  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."),
8267
8268
  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."),
8268
- 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'."),
8269
+ 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'."),
8269
8270
  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'."),
8270
8271
  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."),
8271
8272
  Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
@@ -8283,7 +8284,7 @@ var ts;
8283
8284
  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."),
8284
8285
  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}')'?"),
8285
8286
  Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
8286
- 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'."),
8287
+ 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'."),
8287
8288
  A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
8288
8289
  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."),
8289
8290
  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."),
@@ -8314,7 +8315,7 @@ var ts;
8314
8315
  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."),
8315
8316
  _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
8316
8317
  _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
8317
- 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."),
8318
+ 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."),
8318
8319
  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'."),
8319
8320
  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'."),
8320
8321
  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 `}`?"),
@@ -8366,7 +8367,7 @@ var ts;
8366
8367
  File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
8367
8368
  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:"),
8368
8369
  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."),
8369
- 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."),
8370
+ 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."),
8370
8371
  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."),
8371
8372
  Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
8372
8373
  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}'?"),
@@ -19819,6 +19820,7 @@ var ts;
19819
19820
  case ts.ModuleKind.AMD:
19820
19821
  case ts.ModuleKind.ES2015:
19821
19822
  case ts.ModuleKind.ES2020:
19823
+ case ts.ModuleKind.ES2022:
19822
19824
  case ts.ModuleKind.ESNext:
19823
19825
  return true;
19824
19826
  default:
@@ -20923,6 +20925,10 @@ var ts;
20923
20925
  return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
20924
20926
  }
20925
20927
  ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
20928
+ function isFunctionExpressionOrArrowFunction(node) {
20929
+ return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
20930
+ }
20931
+ ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
20926
20932
  })(ts || (ts = {}));
20927
20933
  /* @internal */
20928
20934
  var ts;
@@ -31547,7 +31553,6 @@ var ts;
31547
31553
  case 88 /* DefaultKeyword */:
31548
31554
  return nextTokenCanFollowDefaultKeyword();
31549
31555
  case 124 /* StaticKeyword */:
31550
- return nextTokenIsOnSameLineAndCanFollowModifier();
31551
31556
  case 136 /* GetKeyword */:
31552
31557
  case 148 /* SetKeyword */:
31553
31558
  nextToken();
@@ -35790,7 +35795,7 @@ var ts;
35790
35795
  }
35791
35796
  return list && createNodeArray(list, pos);
35792
35797
  }
35793
- function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
35798
+ function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
35794
35799
  var pos = getNodePos();
35795
35800
  var kind = token();
35796
35801
  if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
@@ -35803,6 +35808,9 @@ var ts;
35803
35808
  else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
35804
35809
  return undefined;
35805
35810
  }
35811
+ else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
35812
+ return undefined;
35813
+ }
35806
35814
  else {
35807
35815
  if (!parseAnyContextualModifier()) {
35808
35816
  return undefined;
@@ -35819,8 +35827,10 @@ var ts;
35819
35827
  */
35820
35828
  function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
35821
35829
  var pos = getNodePos();
35822
- var list, modifier;
35823
- while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
35830
+ var list, modifier, hasSeenStatic = false;
35831
+ while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
35832
+ if (modifier.kind === 124 /* StaticKeyword */)
35833
+ hasSeenStatic = true;
35824
35834
  list = ts.append(list, modifier);
35825
35835
  }
35826
35836
  return list && createNodeArray(list, pos);
@@ -38525,6 +38535,7 @@ var ts;
38525
38535
  es6: ts.ModuleKind.ES2015,
38526
38536
  es2015: ts.ModuleKind.ES2015,
38527
38537
  es2020: ts.ModuleKind.ES2020,
38538
+ es2022: ts.ModuleKind.ES2022,
38528
38539
  esnext: ts.ModuleKind.ESNext,
38529
38540
  node12: ts.ModuleKind.Node12,
38530
38541
  nodenext: ts.ModuleKind.NodeNext,
@@ -40232,6 +40243,44 @@ var ts;
40232
40243
  }
40233
40244
  return result;
40234
40245
  }
40246
+ /**
40247
+ * Generate a list of the compiler options whose value is not the default.
40248
+ * @param options compilerOptions to be evaluated.
40249
+ /** @internal */
40250
+ function getCompilerOptionsDiffValue(options, newLine) {
40251
+ var compilerOptionsMap = getSerializedCompilerOption(options);
40252
+ return getOverwrittenDefaultOptions();
40253
+ function makePadding(paddingLength) {
40254
+ return Array(paddingLength + 1).join(" ");
40255
+ }
40256
+ function getOverwrittenDefaultOptions() {
40257
+ var result = [];
40258
+ var tab = makePadding(2);
40259
+ commandOptionsWithoutBuild.forEach(function (cmd) {
40260
+ if (!compilerOptionsMap.has(cmd.name)) {
40261
+ return;
40262
+ }
40263
+ var newValue = compilerOptionsMap.get(cmd.name);
40264
+ var defaultValue = getDefaultValueForOption(cmd);
40265
+ if (newValue !== defaultValue) {
40266
+ result.push("" + tab + cmd.name + ": " + newValue);
40267
+ }
40268
+ else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
40269
+ result.push("" + tab + cmd.name + ": " + defaultValue);
40270
+ }
40271
+ });
40272
+ return result.join(newLine) + newLine;
40273
+ }
40274
+ }
40275
+ ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
40276
+ /**
40277
+ * Get the compiler options to be written into the tsconfig.json.
40278
+ * @param options commandlineOptions to be included in the compileOptions.
40279
+ */
40280
+ function getSerializedCompilerOption(options) {
40281
+ var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
40282
+ return serializeCompilerOptions(compilerOptions);
40283
+ }
40235
40284
  /**
40236
40285
  * Generate tsconfig configuration when running command line "--init"
40237
40286
  * @param options commandlineOptions to be generated into tsconfig.json
@@ -40239,28 +40288,8 @@ var ts;
40239
40288
  */
40240
40289
  /* @internal */
40241
40290
  function generateTSConfig(options, fileNames, newLine) {
40242
- var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
40243
- var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
40291
+ var compilerOptionsMap = getSerializedCompilerOption(options);
40244
40292
  return writeConfigurations();
40245
- function getDefaultValueForOption(option) {
40246
- switch (option.type) {
40247
- case "number":
40248
- return 1;
40249
- case "boolean":
40250
- return true;
40251
- case "string":
40252
- return option.isFilePath ? "./" : "";
40253
- case "list":
40254
- return [];
40255
- case "object":
40256
- return {};
40257
- default:
40258
- var iterResult = option.type.keys().next();
40259
- if (!iterResult.done)
40260
- return iterResult.value;
40261
- return ts.Debug.fail("Expected 'option.type' to have entries.");
40262
- }
40263
- }
40264
40293
  function makePadding(paddingLength) {
40265
40294
  return Array(paddingLength + 1).join(" ");
40266
40295
  }
@@ -41247,6 +41276,25 @@ var ts;
41247
41276
  }); // TODO: GH#18217
41248
41277
  }
41249
41278
  }
41279
+ function getDefaultValueForOption(option) {
41280
+ switch (option.type) {
41281
+ case "number":
41282
+ return 1;
41283
+ case "boolean":
41284
+ return true;
41285
+ case "string":
41286
+ return option.isFilePath ? "./" : "";
41287
+ case "list":
41288
+ return [];
41289
+ case "object":
41290
+ return {};
41291
+ default:
41292
+ var iterResult = option.type.keys().next();
41293
+ if (!iterResult.done)
41294
+ return iterResult.value;
41295
+ return ts.Debug.fail("Expected 'option.type' to have entries.");
41296
+ }
41297
+ }
41250
41298
  })(ts || (ts = {}));
41251
41299
  var ts;
41252
41300
  (function (ts) {
@@ -42623,9 +42671,11 @@ var ts;
42623
42671
  return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
42624
42672
  }
42625
42673
  ts.parsePackageName = parsePackageName;
42674
+ /* @internal */
42626
42675
  function allKeysStartWithDot(obj) {
42627
42676
  return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42628
42677
  }
42678
+ ts.allKeysStartWithDot = allKeysStartWithDot;
42629
42679
  function noKeyStartsWithDot(obj) {
42630
42680
  return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
42631
42681
  }
@@ -42832,17 +42882,19 @@ var ts;
42832
42882
  }
42833
42883
  return toSearchResult(/*value*/ undefined);
42834
42884
  }
42835
- function isApplicableVersionedTypesKey(conditions, key) {
42836
- if (conditions.indexOf("types") === -1)
42837
- return false; // only apply versioned types conditions if the types condition is applied
42838
- if (!ts.startsWith(key, "types@"))
42839
- return false;
42840
- var range = ts.VersionRange.tryParse(key.substring("types@".length));
42841
- if (!range)
42842
- return false;
42843
- return range.test(ts.version);
42844
- }
42845
42885
  }
42886
+ /* @internal */
42887
+ function isApplicableVersionedTypesKey(conditions, key) {
42888
+ if (conditions.indexOf("types") === -1)
42889
+ return false; // only apply versioned types conditions if the types condition is applied
42890
+ if (!ts.startsWith(key, "types@"))
42891
+ return false;
42892
+ var range = ts.VersionRange.tryParse(key.substring("types@".length));
42893
+ if (!range)
42894
+ return false;
42895
+ return range.test(ts.version);
42896
+ }
42897
+ ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey;
42846
42898
  function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
42847
42899
  return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
42848
42900
  }
@@ -46658,6 +46710,13 @@ var ts;
46658
46710
  IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
46659
46711
  IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
46660
46712
  })(IntersectionState || (IntersectionState = {}));
46713
+ var RecursionFlags;
46714
+ (function (RecursionFlags) {
46715
+ RecursionFlags[RecursionFlags["None"] = 0] = "None";
46716
+ RecursionFlags[RecursionFlags["Source"] = 1] = "Source";
46717
+ RecursionFlags[RecursionFlags["Target"] = 2] = "Target";
46718
+ RecursionFlags[RecursionFlags["Both"] = 3] = "Both";
46719
+ })(RecursionFlags || (RecursionFlags = {}));
46661
46720
  var MappedTypeModifiers;
46662
46721
  (function (MappedTypeModifiers) {
46663
46722
  MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly";
@@ -47420,17 +47479,9 @@ var ts;
47420
47479
  }
47421
47480
  }
47422
47481
  else {
47423
- if (file.localJsxNamespace) {
47424
- return file.localJsxNamespace;
47425
- }
47426
- var jsxPragma = file.pragmas.get("jsx");
47427
- if (jsxPragma) {
47428
- var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
47429
- file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
47430
- ts.visitNode(file.localJsxFactory, markAsSynthetic);
47431
- if (file.localJsxFactory) {
47432
- return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
47433
- }
47482
+ var localJsxNamespace = getLocalJsxNamespace(file);
47483
+ if (localJsxNamespace) {
47484
+ return file.localJsxNamespace = localJsxNamespace;
47434
47485
  }
47435
47486
  }
47436
47487
  }
@@ -47452,11 +47503,25 @@ var ts;
47452
47503
  _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
47453
47504
  }
47454
47505
  return _jsxNamespace;
47455
- function markAsSynthetic(node) {
47456
- ts.setTextRangePosEnd(node, -1, -1);
47457
- return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
47506
+ }
47507
+ function getLocalJsxNamespace(file) {
47508
+ if (file.localJsxNamespace) {
47509
+ return file.localJsxNamespace;
47510
+ }
47511
+ var jsxPragma = file.pragmas.get("jsx");
47512
+ if (jsxPragma) {
47513
+ var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
47514
+ file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
47515
+ ts.visitNode(file.localJsxFactory, markAsSynthetic);
47516
+ if (file.localJsxFactory) {
47517
+ return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
47518
+ }
47458
47519
  }
47459
47520
  }
47521
+ function markAsSynthetic(node) {
47522
+ ts.setTextRangePosEnd(node, -1, -1);
47523
+ return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
47524
+ }
47460
47525
  function getEmitResolver(sourceFile, cancellationToken) {
47461
47526
  // Ensure we have all the type information in place for this file so that all the
47462
47527
  // emitter questions of this resolver will return the right information.
@@ -48883,7 +48948,21 @@ var ts;
48883
48948
  function isSyntacticDefault(node) {
48884
48949
  return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
48885
48950
  }
48886
- function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
48951
+ function getUsageModeForExpression(usage) {
48952
+ return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
48953
+ }
48954
+ function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
48955
+ return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
48956
+ }
48957
+ function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
48958
+ var usageMode = file && getUsageModeForExpression(usage);
48959
+ if (file && usageMode !== undefined) {
48960
+ var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
48961
+ if (usageMode === ts.ModuleKind.ESNext || result) {
48962
+ return result;
48963
+ }
48964
+ // fallthrough on cjs usages so we imply defaults for interop'd imports, too
48965
+ }
48887
48966
  if (!allowSyntheticDefaultImports) {
48888
48967
  return false;
48889
48968
  }
@@ -48925,7 +49004,7 @@ var ts;
48925
49004
  exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
48926
49005
  }
48927
49006
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
48928
- var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
49007
+ var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
48929
49008
  if (!exportDefaultSymbol && !hasSyntheticDefault) {
48930
49009
  if (hasExportAssignmentSymbol(moduleSymbol)) {
48931
49010
  var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
@@ -49065,7 +49144,7 @@ var ts;
49065
49144
  var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
49066
49145
  if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
49067
49146
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
49068
- if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
49147
+ if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
49069
49148
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
49070
49149
  }
49071
49150
  }
@@ -49756,7 +49835,7 @@ var ts;
49756
49835
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
49757
49836
  }
49758
49837
  if (sigs && sigs.length) {
49759
- var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
49838
+ var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
49760
49839
  // Create a new symbol which has the module's type less the call and construct signatures
49761
49840
  var result = createSymbol(symbol.flags, symbol.escapedName);
49762
49841
  result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
@@ -57452,7 +57531,7 @@ var ts;
57452
57531
  else if (type !== firstType) {
57453
57532
  checkFlags |= 64 /* HasNonUniformType */;
57454
57533
  }
57455
- if (isLiteralType(type)) {
57534
+ if (isLiteralType(type) || isPatternLiteralType(type)) {
57456
57535
  checkFlags |= 128 /* HasLiteralType */;
57457
57536
  }
57458
57537
  if (type.flags & 131072 /* Never */) {
@@ -61846,7 +61925,7 @@ var ts;
61846
61925
  return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body);
61847
61926
  }
61848
61927
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
61849
- return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
61928
+ return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
61850
61929
  isContextSensitiveFunctionLikeDeclaration(func);
61851
61930
  }
61852
61931
  function getTypeWithoutSignatures(type) {
@@ -62718,7 +62797,8 @@ var ts;
62718
62797
  var sourceStack;
62719
62798
  var targetStack;
62720
62799
  var maybeCount = 0;
62721
- var depth = 0;
62800
+ var sourceDepth = 0;
62801
+ var targetDepth = 0;
62722
62802
  var expandingFlags = 0 /* None */;
62723
62803
  var overflow = false;
62724
62804
  var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
@@ -62726,12 +62806,12 @@ var ts;
62726
62806
  var incompatibleStack = [];
62727
62807
  var inPropertyCheck = false;
62728
62808
  ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
62729
- var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
62809
+ var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
62730
62810
  if (incompatibleStack.length) {
62731
62811
  reportIncompatibleStack();
62732
62812
  }
62733
62813
  if (overflow) {
62734
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
62814
+ 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 });
62735
62815
  var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
62736
62816
  if (errorOutputContainer) {
62737
62817
  (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -63011,13 +63091,17 @@ var ts;
63011
63091
  }
63012
63092
  return true;
63013
63093
  }
63094
+ function isRelatedToWorker(source, target, reportErrors) {
63095
+ return isRelatedTo(source, target, 3 /* Both */, reportErrors);
63096
+ }
63014
63097
  /**
63015
63098
  * Compare two types and return
63016
63099
  * * Ternary.True if they are related with no assumptions,
63017
63100
  * * Ternary.Maybe if they are related with assumptions of other relationships, or
63018
63101
  * * Ternary.False if they are not related.
63019
63102
  */
63020
- function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
63103
+ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) {
63104
+ if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; }
63021
63105
  if (reportErrors === void 0) { reportErrors = false; }
63022
63106
  if (intersectionState === void 0) { intersectionState = 0 /* None */; }
63023
63107
  // Before normalization: if `source` is type an object type, and `target` is primitive,
@@ -63038,7 +63122,7 @@ var ts;
63038
63122
  if (source === target)
63039
63123
  return -1 /* True */;
63040
63124
  if (relation === identityRelation) {
63041
- return isIdenticalTo(source, target);
63125
+ return isIdenticalTo(source, target, recursionFlags);
63042
63126
  }
63043
63127
  // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
63044
63128
  // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
@@ -63089,8 +63173,8 @@ var ts;
63089
63173
  var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
63090
63174
  var calls = getSignaturesOfType(source, 0 /* Call */);
63091
63175
  var constructs = getSignaturesOfType(source, 1 /* Construct */);
63092
- if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
63093
- constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
63176
+ if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
63177
+ constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
63094
63178
  reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
63095
63179
  }
63096
63180
  else {
@@ -63107,11 +63191,11 @@ var ts;
63107
63191
  // and we need to handle "each" relations before "some" relations for the same kind of type.
63108
63192
  if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63109
63193
  result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
63110
- recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */) :
63194
+ recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
63111
63195
  structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63112
63196
  }
63113
63197
  if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63114
- if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
63198
+ if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
63115
63199
  resetErrorInfo(saveErrorInfo);
63116
63200
  }
63117
63201
  }
@@ -63133,7 +63217,7 @@ var ts;
63133
63217
  if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
63134
63218
  if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
63135
63219
  // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
63136
- if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63220
+ if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63137
63221
  resetErrorInfo(saveErrorInfo);
63138
63222
  }
63139
63223
  }
@@ -63157,7 +63241,7 @@ var ts;
63157
63241
  if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
63158
63242
  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 */); }))) {
63159
63243
  inPropertyCheck = true;
63160
- result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */);
63244
+ result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
63161
63245
  inPropertyCheck = false;
63162
63246
  }
63163
63247
  reportErrorResults(source, target, result, isComparingJsxAttributes);
@@ -63232,7 +63316,7 @@ var ts;
63232
63316
  }
63233
63317
  }
63234
63318
  }
63235
- function isIdenticalTo(source, target) {
63319
+ function isIdenticalTo(source, target, recursionFlags) {
63236
63320
  if (source.flags !== target.flags)
63237
63321
  return 0 /* False */;
63238
63322
  if (source.flags & 67358815 /* Singleton */)
@@ -63245,7 +63329,7 @@ var ts;
63245
63329
  }
63246
63330
  return result_7;
63247
63331
  }
63248
- return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */);
63332
+ return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
63249
63333
  }
63250
63334
  function getTypeOfPropertyInTypes(types, name) {
63251
63335
  var appendPropType = function (propTypes, type) {
@@ -63326,7 +63410,7 @@ var ts;
63326
63410
  }
63327
63411
  return { value: true };
63328
63412
  }
63329
- if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
63413
+ if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) {
63330
63414
  if (reportErrors) {
63331
63415
  reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
63332
63416
  }
@@ -63366,7 +63450,7 @@ var ts;
63366
63450
  }
63367
63451
  var match = getMatchingUnionConstituentForType(target, source);
63368
63452
  if (match) {
63369
- var related = isRelatedTo(source, match, /*reportErrors*/ false);
63453
+ var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false);
63370
63454
  if (related) {
63371
63455
  return related;
63372
63456
  }
@@ -63374,14 +63458,14 @@ var ts;
63374
63458
  }
63375
63459
  for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
63376
63460
  var type = targetTypes_1[_i];
63377
- var related = isRelatedTo(source, type, /*reportErrors*/ false);
63461
+ var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false);
63378
63462
  if (related) {
63379
63463
  return related;
63380
63464
  }
63381
63465
  }
63382
63466
  if (reportErrors) {
63383
63467
  var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
63384
- isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
63468
+ isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
63385
63469
  }
63386
63470
  return 0 /* False */;
63387
63471
  }
@@ -63390,7 +63474,7 @@ var ts;
63390
63474
  var targetTypes = target.types;
63391
63475
  for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
63392
63476
  var targetType = targetTypes_2[_i];
63393
- var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, intersectionState);
63477
+ var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
63394
63478
  if (!related) {
63395
63479
  return 0 /* False */;
63396
63480
  }
@@ -63405,7 +63489,7 @@ var ts;
63405
63489
  }
63406
63490
  var len = sourceTypes.length;
63407
63491
  for (var i = 0; i < len; i++) {
63408
- var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
63492
+ var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
63409
63493
  if (related) {
63410
63494
  return related;
63411
63495
  }
@@ -63435,13 +63519,13 @@ var ts;
63435
63519
  // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`,
63436
63520
  // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}`
63437
63521
  // - 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
63438
- var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
63522
+ var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
63439
63523
  if (related_1) {
63440
63524
  result &= related_1;
63441
63525
  continue;
63442
63526
  }
63443
63527
  }
63444
- var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState);
63528
+ var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
63445
63529
  if (!related) {
63446
63530
  return 0 /* False */;
63447
63531
  }
@@ -63473,31 +63557,31 @@ var ts;
63473
63557
  // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_.
63474
63558
  // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by
63475
63559
  // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be)
63476
- related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t);
63560
+ related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
63477
63561
  }
63478
63562
  else if (variance === 1 /* Covariant */) {
63479
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63563
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63480
63564
  }
63481
63565
  else if (variance === 2 /* Contravariant */) {
63482
- related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
63566
+ related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63483
63567
  }
63484
63568
  else if (variance === 3 /* Bivariant */) {
63485
63569
  // In the bivariant case we first compare contravariantly without reporting
63486
63570
  // errors. Then, if that doesn't succeed, we compare covariantly with error
63487
63571
  // reporting. Thus, error elaboration will be based on the the covariant check,
63488
63572
  // which is generally easier to reason about.
63489
- related = isRelatedTo(t, s, /*reportErrors*/ false);
63573
+ related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false);
63490
63574
  if (!related) {
63491
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63575
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63492
63576
  }
63493
63577
  }
63494
63578
  else {
63495
63579
  // In the invariant case we first compare covariantly, and only when that
63496
63580
  // succeeds do we proceed to compare contravariantly. Thus, error elaboration
63497
63581
  // will typically be based on the covariant check.
63498
- related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
63582
+ related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63499
63583
  if (related) {
63500
- related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
63584
+ related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
63501
63585
  }
63502
63586
  }
63503
63587
  if (!related) {
@@ -63513,7 +63597,7 @@ var ts;
63513
63597
  // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
63514
63598
  // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
63515
63599
  // and issue an error. Otherwise, actually compare the structure of the two types.
63516
- function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
63600
+ function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) {
63517
63601
  if (overflow) {
63518
63602
  return 0 /* False */;
63519
63603
  }
@@ -63557,7 +63641,7 @@ var ts;
63557
63641
  return 3 /* Maybe */;
63558
63642
  }
63559
63643
  }
63560
- if (depth === 100) {
63644
+ if (sourceDepth === 100 || targetDepth === 100) {
63561
63645
  overflow = true;
63562
63646
  return 0 /* False */;
63563
63647
  }
@@ -63565,13 +63649,18 @@ var ts;
63565
63649
  var maybeStart = maybeCount;
63566
63650
  maybeKeys[maybeCount] = id;
63567
63651
  maybeCount++;
63568
- sourceStack[depth] = source;
63569
- targetStack[depth] = target;
63570
- depth++;
63652
+ if (recursionFlags & 1 /* Source */) {
63653
+ sourceStack[sourceDepth] = source;
63654
+ sourceDepth++;
63655
+ }
63656
+ if (recursionFlags & 2 /* Target */) {
63657
+ targetStack[targetDepth] = target;
63658
+ targetDepth++;
63659
+ }
63571
63660
  var saveExpandingFlags = expandingFlags;
63572
- if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, depth))
63661
+ if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63573
63662
  expandingFlags |= 1 /* Source */;
63574
- if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth))
63663
+ if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63575
63664
  expandingFlags |= 2 /* Target */;
63576
63665
  var originalHandler;
63577
63666
  var propagatingVarianceFlags = 0;
@@ -63588,7 +63677,8 @@ var ts;
63588
63677
  sourceIdStack: sourceStack.map(function (t) { return t.id; }),
63589
63678
  targetId: target.id,
63590
63679
  targetIdStack: targetStack.map(function (t) { return t.id; }),
63591
- depth: depth,
63680
+ depth: sourceDepth,
63681
+ targetDepth: targetDepth
63592
63682
  });
63593
63683
  }
63594
63684
  var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
@@ -63596,9 +63686,14 @@ var ts;
63596
63686
  outofbandVarianceMarkerHandler = originalHandler;
63597
63687
  }
63598
63688
  expandingFlags = saveExpandingFlags;
63599
- depth--;
63689
+ if (recursionFlags & 1 /* Source */) {
63690
+ sourceDepth--;
63691
+ }
63692
+ if (recursionFlags & 2 /* Target */) {
63693
+ targetDepth--;
63694
+ }
63600
63695
  if (result) {
63601
- if (result === -1 /* True */ || depth === 0) {
63696
+ if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
63602
63697
  if (result === -1 /* True */ || result === 3 /* Maybe */) {
63603
63698
  // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
63604
63699
  // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
@@ -63652,7 +63747,7 @@ var ts;
63652
63747
  if (constraints !== source.types) {
63653
63748
  source = getIntersectionType(constraints);
63654
63749
  if (!(source.flags & 2097152 /* Intersection */)) {
63655
- return isRelatedTo(source, target, /*reportErrors*/ false);
63750
+ return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
63656
63751
  }
63657
63752
  }
63658
63753
  }
@@ -63674,22 +63769,22 @@ var ts;
63674
63769
  var flags = source.flags & target.flags;
63675
63770
  if (relation === identityRelation && !(flags & 524288 /* Object */)) {
63676
63771
  if (flags & 4194304 /* Index */) {
63677
- return isRelatedTo(source.type, target.type, /*reportErrors*/ false);
63772
+ return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
63678
63773
  }
63679
63774
  var result_8 = 0 /* False */;
63680
63775
  if (flags & 8388608 /* IndexedAccess */) {
63681
- if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) {
63682
- if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) {
63776
+ if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
63777
+ if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
63683
63778
  return result_8;
63684
63779
  }
63685
63780
  }
63686
63781
  }
63687
63782
  if (flags & 16777216 /* Conditional */) {
63688
63783
  if (source.root.isDistributive === target.root.isDistributive) {
63689
- if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) {
63690
- if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) {
63691
- if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) {
63692
- if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) {
63784
+ if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
63785
+ if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
63786
+ if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
63787
+ if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
63693
63788
  return result_8;
63694
63789
  }
63695
63790
  }
@@ -63698,7 +63793,7 @@ var ts;
63698
63793
  }
63699
63794
  }
63700
63795
  if (flags & 33554432 /* Substitution */) {
63701
- return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false);
63796
+ return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
63702
63797
  }
63703
63798
  return 0 /* False */;
63704
63799
  }
@@ -63723,17 +63818,17 @@ var ts;
63723
63818
  }
63724
63819
  // 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],
63725
63820
  // and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
63726
- if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
63727
- isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
63821
+ if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) ||
63822
+ isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
63728
63823
  return result;
63729
63824
  }
63730
63825
  if (target.flags & 262144 /* TypeParameter */) {
63731
63826
  // 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].
63732
- if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
63827
+ if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
63733
63828
  if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
63734
63829
  var templateType = getTemplateTypeFromMappedType(source);
63735
63830
  var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
63736
- if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
63831
+ if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) {
63737
63832
  return result;
63738
63833
  }
63739
63834
  }
@@ -63743,14 +63838,14 @@ var ts;
63743
63838
  var targetType_1 = target.type;
63744
63839
  // A keyof S is related to a keyof T if T is related to S.
63745
63840
  if (source.flags & 4194304 /* Index */) {
63746
- if (result = isRelatedTo(targetType_1, source.type, /*reportErrors*/ false)) {
63841
+ if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
63747
63842
  return result;
63748
63843
  }
63749
63844
  }
63750
63845
  if (isTupleType(targetType_1)) {
63751
63846
  // An index type can have a tuple type target when the tuple type contains variadic elements.
63752
63847
  // Check if the source is related to the known keys of the tuple type.
63753
- if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), reportErrors)) {
63848
+ if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) {
63754
63849
  return result;
63755
63850
  }
63756
63851
  }
@@ -63763,7 +63858,7 @@ var ts;
63763
63858
  // false positives. For example, given 'T extends { [K in keyof T]: string }',
63764
63859
  // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
63765
63860
  // related to other types.
63766
- if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1 /* True */) {
63861
+ if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) {
63767
63862
  return -1 /* True */;
63768
63863
  }
63769
63864
  }
@@ -63787,7 +63882,7 @@ var ts;
63787
63882
  else {
63788
63883
  targetKeys = nameType_1 || constraintType;
63789
63884
  }
63790
- if (isRelatedTo(source, targetKeys, reportErrors) === -1 /* True */) {
63885
+ if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) {
63791
63886
  return -1 /* True */;
63792
63887
  }
63793
63888
  }
@@ -63797,8 +63892,8 @@ var ts;
63797
63892
  if (source.flags & 8388608 /* IndexedAccess */) {
63798
63893
  // Relate components directly before falling back to constraint relationships
63799
63894
  // A type S[K] is related to a type T[J] if S is related to T and K is related to J.
63800
- if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
63801
- result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
63895
+ if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
63896
+ result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
63802
63897
  }
63803
63898
  if (result) {
63804
63899
  resetErrorInfo(saveErrorInfo);
@@ -63823,7 +63918,7 @@ var ts;
63823
63918
  // create a new chain for the constraint error
63824
63919
  resetErrorInfo(saveErrorInfo);
63825
63920
  }
63826
- if (result = isRelatedTo(source, constraint, reportErrors)) {
63921
+ if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
63827
63922
  return result;
63828
63923
  }
63829
63924
  // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
@@ -63863,13 +63958,14 @@ var ts;
63863
63958
  // 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`.
63864
63959
  if (includeOptional
63865
63960
  ? !(filteredByApplicability.flags & 131072 /* Never */)
63866
- : isRelatedTo(targetKeys, sourceKeys)) {
63961
+ : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
63962
+ var templateType_1 = getTemplateTypeFromMappedType(target);
63867
63963
  var typeParameter = getTypeParameterFromMappedType(target);
63868
63964
  // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj`
63869
63965
  // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`.
63870
- var nonNullComponent = extractTypesOfKind(templateType, ~98304 /* Nullable */);
63966
+ var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */);
63871
63967
  if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
63872
- if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
63968
+ if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) {
63873
63969
  return result;
63874
63970
  }
63875
63971
  }
@@ -63889,7 +63985,7 @@ var ts;
63889
63985
  : typeParameter;
63890
63986
  var indexedAccessType = getIndexedAccessType(source, indexingType);
63891
63987
  // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type.
63892
- if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
63988
+ if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) {
63893
63989
  return result;
63894
63990
  }
63895
63991
  }
@@ -63916,10 +64012,11 @@ var ts;
63916
64012
  newParam.mapper = distributionMapper;
63917
64013
  }
63918
64014
  // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
63919
- var localResult = void 0;
63920
- if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) {
63921
- if (!skipFalse) {
63922
- localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false);
64015
+ var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
64016
+ var localResult = expanding ? 3 /* Maybe */ : undefined;
64017
+ if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
64018
+ if (!skipFalse && !expanding) {
64019
+ localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
63923
64020
  }
63924
64021
  }
63925
64022
  if (localResult) {
@@ -63929,6 +64026,9 @@ var ts;
63929
64026
  }
63930
64027
  else if (target.flags & 134217728 /* TemplateLiteral */) {
63931
64028
  if (source.flags & 134217728 /* TemplateLiteral */) {
64029
+ if (relation === comparableRelation) {
64030
+ return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
64031
+ }
63932
64032
  // Report unreliable variance for type variables referenced in template literal type placeholders.
63933
64033
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
63934
64034
  instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
@@ -63944,34 +64044,33 @@ var ts;
63944
64044
  var constraint = getConstraintOfType(source);
63945
64045
  if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
63946
64046
  // A type variable with no constraint is not related to the non-primitive object type.
63947
- if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
64047
+ if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
63948
64048
  resetErrorInfo(saveErrorInfo);
63949
64049
  return result;
63950
64050
  }
63951
64051
  }
63952
64052
  // 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
63953
- else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
64053
+ else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
63954
64054
  resetErrorInfo(saveErrorInfo);
63955
64055
  return result;
63956
64056
  }
63957
64057
  // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
63958
- else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
64058
+ else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
63959
64059
  resetErrorInfo(saveErrorInfo);
63960
64060
  return result;
63961
64061
  }
63962
64062
  }
63963
64063
  }
63964
64064
  else if (source.flags & 4194304 /* Index */) {
63965
- if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
64065
+ if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
63966
64066
  resetErrorInfo(saveErrorInfo);
63967
64067
  return result;
63968
64068
  }
63969
64069
  }
63970
- else if (source.flags & 134217728 /* TemplateLiteral */) {
64070
+ else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
63971
64071
  if (!(target.flags & 134217728 /* TemplateLiteral */)) {
63972
- var baseConstraint = getBaseConstraintOfType(source);
63973
- var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType;
63974
- if (result = isRelatedTo(constraint, target, reportErrors)) {
64072
+ var constraint = getBaseConstraintOfType(source);
64073
+ if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
63975
64074
  resetErrorInfo(saveErrorInfo);
63976
64075
  return result;
63977
64076
  }
@@ -63979,14 +64078,14 @@ var ts;
63979
64078
  }
63980
64079
  else if (source.flags & 268435456 /* StringMapping */) {
63981
64080
  if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
63982
- if (result = isRelatedTo(source.type, target.type, reportErrors)) {
64081
+ if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
63983
64082
  resetErrorInfo(saveErrorInfo);
63984
64083
  return result;
63985
64084
  }
63986
64085
  }
63987
64086
  else {
63988
64087
  var constraint = getBaseConstraintOfType(source);
63989
- if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
64088
+ if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
63990
64089
  resetErrorInfo(saveErrorInfo);
63991
64090
  return result;
63992
64091
  }
@@ -63994,27 +64093,32 @@ var ts;
63994
64093
  }
63995
64094
  else if (source.flags & 16777216 /* Conditional */) {
63996
64095
  if (target.flags & 16777216 /* Conditional */) {
63997
- // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
63998
- // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
63999
- // and Y1 is related to Y2.
64000
- var sourceParams = source.root.inferTypeParameters;
64001
- var sourceExtends = source.extendsType;
64002
- var mapper = void 0;
64003
- if (sourceParams) {
64004
- // If the source has infer type parameters, we instantiate them in the context of the target
64005
- var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo);
64006
- inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
64007
- sourceExtends = instantiateType(sourceExtends, ctx.mapper);
64008
- mapper = ctx.mapper;
64009
- }
64010
- if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
64011
- (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
64012
- if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
64013
- result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
64014
- }
64015
- if (result) {
64016
- resetErrorInfo(saveErrorInfo);
64017
- return result;
64096
+ // If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
64097
+ // the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
64098
+ // types, which might expand forever.
64099
+ if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
64100
+ // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
64101
+ // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
64102
+ // and Y1 is related to Y2.
64103
+ var sourceParams = source.root.inferTypeParameters;
64104
+ var sourceExtends = source.extendsType;
64105
+ var mapper = void 0;
64106
+ if (sourceParams) {
64107
+ // If the source has infer type parameters, we instantiate them in the context of the target
64108
+ var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
64109
+ inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
64110
+ sourceExtends = instantiateType(sourceExtends, ctx.mapper);
64111
+ mapper = ctx.mapper;
64112
+ }
64113
+ if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
64114
+ (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
64115
+ if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
64116
+ result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
64117
+ }
64118
+ if (result) {
64119
+ resetErrorInfo(saveErrorInfo);
64120
+ return result;
64121
+ }
64018
64122
  }
64019
64123
  }
64020
64124
  }
@@ -64023,19 +64127,23 @@ var ts;
64023
64127
  // more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
64024
64128
  var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
64025
64129
  if (distributiveConstraint) {
64026
- if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
64130
+ if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
64027
64131
  resetErrorInfo(saveErrorInfo);
64028
64132
  return result;
64029
64133
  }
64030
64134
  }
64031
64135
  }
64032
- // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
64033
- // when `O` is a conditional (`never` is trivially aissgnable to `O`, as is `O`!).
64034
- var defaultConstraint = getDefaultConstraintOfConditionalType(source);
64035
- if (defaultConstraint) {
64036
- if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
64037
- resetErrorInfo(saveErrorInfo);
64038
- return result;
64136
+ // 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
64137
+ // on the comparison.
64138
+ if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
64139
+ // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
64140
+ // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
64141
+ var defaultConstraint = getDefaultConstraintOfConditionalType(source);
64142
+ if (defaultConstraint) {
64143
+ if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
64144
+ resetErrorInfo(saveErrorInfo);
64145
+ return result;
64146
+ }
64039
64147
  }
64040
64148
  }
64041
64149
  }
@@ -64079,7 +64187,7 @@ var ts;
64079
64187
  }
64080
64188
  else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
64081
64189
  if (relation !== identityRelation) {
64082
- return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors);
64190
+ return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
64083
64191
  }
64084
64192
  else {
64085
64193
  // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple
@@ -64201,10 +64309,10 @@ var ts;
64201
64309
  var result_11;
64202
64310
  var targetConstraint = getConstraintTypeFromMappedType(target);
64203
64311
  var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
64204
- if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
64312
+ if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64205
64313
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
64206
64314
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
64207
- return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
64315
+ return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64208
64316
  }
64209
64317
  }
64210
64318
  }
@@ -64336,7 +64444,7 @@ var ts;
64336
64444
  var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */);
64337
64445
  var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
64338
64446
  var effectiveSource = getTypeOfSourceProperty(sourceProp);
64339
- return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState);
64447
+ return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
64340
64448
  }
64341
64449
  function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
64342
64450
  var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
@@ -64518,7 +64626,7 @@ var ts;
64518
64626
  var targetType = targetTypeArguments[i];
64519
64627
  var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) :
64520
64628
  removeMissingType(targetType, !!(targetFlags & 2 /* Optional */));
64521
- var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState);
64629
+ var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
64522
64630
  if (!related) {
64523
64631
  if (reportErrors && (targetArity > 1 || sourceArity > 1)) {
64524
64632
  if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
@@ -64712,7 +64820,7 @@ var ts;
64712
64820
  * See signatureAssignableTo, compareSignaturesIdentical
64713
64821
  */
64714
64822
  function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
64715
- return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
64823
+ return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
64716
64824
  }
64717
64825
  function signaturesIdenticalTo(source, target, kind) {
64718
64826
  var sourceSignatures = getSignaturesOfType(source, kind);
@@ -64745,7 +64853,7 @@ var ts;
64745
64853
  var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */)
64746
64854
  ? propType
64747
64855
  : getTypeWithFacts(propType, 524288 /* NEUndefined */);
64748
- var related = isRelatedTo(type, targetInfo.type, reportErrors);
64856
+ var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors);
64749
64857
  if (!related) {
64750
64858
  if (reportErrors) {
64751
64859
  reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
@@ -64768,7 +64876,7 @@ var ts;
64768
64876
  return result;
64769
64877
  }
64770
64878
  function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) {
64771
- var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors);
64879
+ var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors);
64772
64880
  if (!related && reportErrors) {
64773
64881
  if (sourceInfo.keyType === targetInfo.keyType) {
64774
64882
  reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
@@ -64789,7 +64897,7 @@ var ts;
64789
64897
  for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
64790
64898
  var targetInfo = indexInfos_3[_i];
64791
64899
  var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
64792
- isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) :
64900
+ isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
64793
64901
  typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
64794
64902
  if (!related) {
64795
64903
  return 0 /* False */;
@@ -64821,7 +64929,7 @@ var ts;
64821
64929
  for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) {
64822
64930
  var targetInfo = targetInfos_1[_i];
64823
64931
  var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType);
64824
- if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
64932
+ if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
64825
64933
  return 0 /* False */;
64826
64934
  }
64827
64935
  }
@@ -66235,6 +66343,17 @@ var ts;
66235
66343
  function isFromInferenceBlockedSource(type) {
66236
66344
  return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
66237
66345
  }
66346
+ function templateLiteralTypesDefinitelyUnrelated(source, target) {
66347
+ // Two template literal types with diffences in their starting or ending text spans are definitely unrelated.
66348
+ var sourceStart = source.texts[0];
66349
+ var targetStart = target.texts[0];
66350
+ var sourceEnd = source.texts[source.texts.length - 1];
66351
+ var targetEnd = target.texts[target.texts.length - 1];
66352
+ var startLen = Math.min(sourceStart.length, targetStart.length);
66353
+ var endLen = Math.min(sourceEnd.length, targetEnd.length);
66354
+ return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
66355
+ sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
66356
+ }
66238
66357
  function isValidBigIntString(s) {
66239
66358
  var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
66240
66359
  var success = true;
@@ -67297,7 +67416,7 @@ var ts;
67297
67416
  if (prop.isDiscriminantProperty === undefined) {
67298
67417
  prop.isDiscriminantProperty =
67299
67418
  (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ &&
67300
- !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */ & ~134217728 /* TemplateLiteral */);
67419
+ !isGenericType(getTypeOfSymbol(prop));
67301
67420
  }
67302
67421
  return !!prop.isDiscriminantProperty;
67303
67422
  }
@@ -67816,17 +67935,19 @@ var ts;
67816
67935
  function extractTypesOfKind(type, kind) {
67817
67936
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
67818
67937
  }
67819
- // Return a new type in which occurrences of the string and number primitive types in
67820
- // typeWithPrimitives have been replaced with occurrences of string literals and numeric
67821
- // literals in typeWithLiterals, respectively.
67938
+ // Return a new type in which occurrences of the string, number and bigint primitives and placeholder template
67939
+ // literal types in typeWithPrimitives have been replaced with occurrences of compatible and more specific types
67940
+ // from typeWithLiterals. This is essentially a limited form of intersection between the two types. We avoid a
67941
+ // true intersection because it is more costly and, when applied to union types, generates a large number of
67942
+ // types we don't actually care about.
67822
67943
  function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
67823
- if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) ||
67824
- isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) ||
67825
- isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) {
67944
+ if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) &&
67945
+ maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
67826
67946
  return mapType(typeWithPrimitives, function (t) {
67827
- return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) :
67828
- t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
67829
- t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
67947
+ return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) :
67948
+ isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) :
67949
+ t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
67950
+ t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
67830
67951
  });
67831
67952
  }
67832
67953
  return typeWithPrimitives;
@@ -67907,10 +68028,10 @@ var ts;
67907
68028
  isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */);
67908
68029
  return isLengthPushOrUnshift || isElementAssignment;
67909
68030
  }
67910
- function isDeclarationWithExplicitTypeAnnotation(declaration) {
67911
- return (declaration.kind === 253 /* VariableDeclaration */ || declaration.kind === 163 /* Parameter */ ||
67912
- declaration.kind === 166 /* PropertyDeclaration */ || declaration.kind === 165 /* PropertySignature */) &&
67913
- !!ts.getEffectiveTypeAnnotationNode(declaration);
68031
+ function isDeclarationWithExplicitTypeAnnotation(node) {
68032
+ return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) &&
68033
+ !!(ts.getEffectiveTypeAnnotationNode(node) ||
68034
+ ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
67914
68035
  }
67915
68036
  function getExplicitTypeOfSymbol(symbol, diagnostic) {
67916
68037
  if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) {
@@ -68627,7 +68748,7 @@ var ts;
68627
68748
  var narrowedPropType = narrowType(propType);
68628
68749
  return filterType(type, function (t) {
68629
68750
  var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
68630
- return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType);
68751
+ return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
68631
68752
  });
68632
68753
  }
68633
68754
  function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) {
@@ -69096,16 +69217,7 @@ var ts;
69096
69217
  }
69097
69218
  function getNarrowedType(type, candidate, assumeTrue, isRelated) {
69098
69219
  if (!assumeTrue) {
69099
- return filterType(type, function (t) {
69100
- if (!isRelated(t, candidate)) {
69101
- return true;
69102
- }
69103
- var constraint = getBaseConstraintOfType(t);
69104
- if (constraint && constraint !== t) {
69105
- return !isRelated(constraint, candidate);
69106
- }
69107
- return false;
69108
- });
69220
+ return filterType(type, function (t) { return !isRelated(t, candidate); });
69109
69221
  }
69110
69222
  // If the current type is a union type, remove all constituents that couldn't be instances of
69111
69223
  // the candidate type. If one or more constituents remain, return a union of those.
@@ -71007,12 +71119,9 @@ var ts;
71007
71119
  }
71008
71120
  return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
71009
71121
  }
71010
- function isFunctionExpressionOrArrowFunction(node) {
71011
- return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
71012
- }
71013
71122
  function getContextualSignatureForFunctionLikeDeclaration(node) {
71014
71123
  // Only function expressions, arrow functions, and object literal methods are contextually typed.
71015
- return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
71124
+ return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
71016
71125
  ? getContextualSignature(node)
71017
71126
  : undefined;
71018
71127
  }
@@ -71979,6 +72088,14 @@ var ts;
71979
72088
  markAliasSymbolAsReferenced(jsxFactorySym);
71980
72089
  }
71981
72090
  }
72091
+ // For JsxFragment, mark jsx pragma as referenced via resolveName
72092
+ if (ts.isJsxOpeningFragment(node)) {
72093
+ var file = ts.getSourceFileOfNode(node);
72094
+ var localJsxNamespace = getLocalJsxNamespace(file);
72095
+ if (localJsxNamespace) {
72096
+ resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
72097
+ }
72098
+ }
71982
72099
  }
71983
72100
  if (isNodeOpeningLikeElement) {
71984
72101
  var jsxOpeningLikeNode = node;
@@ -73651,7 +73768,7 @@ var ts;
73651
73768
  return false;
73652
73769
  var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false);
73653
73770
  var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
73654
- if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
73771
+ if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
73655
73772
  return false;
73656
73773
  }
73657
73774
  var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
@@ -74895,18 +75012,18 @@ var ts;
74895
75012
  if (moduleSymbol) {
74896
75013
  var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
74897
75014
  if (esModuleSymbol) {
74898
- return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
75015
+ return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
74899
75016
  }
74900
75017
  }
74901
75018
  return createPromiseReturnType(node, anyType);
74902
75019
  }
74903
- function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
75020
+ function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
74904
75021
  var _a;
74905
75022
  if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
74906
75023
  var synthType = type;
74907
75024
  if (!synthType.syntheticType) {
74908
75025
  var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
74909
- var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
75026
+ var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
74910
75027
  if (hasSyntheticDefault) {
74911
75028
  var memberTable = ts.createSymbolTable();
74912
75029
  var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
@@ -75068,16 +75185,14 @@ var ts;
75068
75185
  }
75069
75186
  }
75070
75187
  function checkImportMetaProperty(node) {
75071
- if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
75072
- if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
75073
- if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
75074
- error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
75075
- }
75076
- }
75077
- else {
75078
- error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
75188
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
75189
+ if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
75190
+ error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
75079
75191
  }
75080
75192
  }
75193
+ else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) {
75194
+ error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
75195
+ }
75081
75196
  var file = ts.getSourceFileOfNode(node);
75082
75197
  ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
75083
75198
  return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
@@ -76020,9 +76135,9 @@ var ts;
76020
76135
  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);
76021
76136
  diagnostics.add(diagnostic);
76022
76137
  }
76023
- if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
76138
+ 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 */) {
76024
76139
  span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
76025
- 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);
76140
+ 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);
76026
76141
  diagnostics.add(diagnostic);
76027
76142
  }
76028
76143
  }
@@ -77460,7 +77575,7 @@ var ts;
77460
77575
  }
77461
77576
  }
77462
77577
  function checkParenthesizedExpression(node, checkMode) {
77463
- if (ts.isJSDocTypeAssertion(node)) {
77578
+ if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) {
77464
77579
  var type = ts.getJSDocTypeAssertionType(node);
77465
77580
  return checkAssertionWorker(type, type, node.expression, checkMode);
77466
77581
  }
@@ -79357,6 +79472,12 @@ var ts;
79357
79472
  }
79358
79473
  }
79359
79474
  }
79475
+ function checkJSDocAccessibilityModifiers(node) {
79476
+ var host = ts.getJSDocHost(node);
79477
+ if (host && ts.isPrivateIdentifierClassElementDeclaration(host)) {
79478
+ error(node, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
79479
+ }
79480
+ }
79360
79481
  function getIdentifierFromEntityNameExpression(node) {
79361
79482
  switch (node.kind) {
79362
79483
  case 79 /* Identifier */:
@@ -83010,6 +83131,10 @@ var ts;
83010
83131
  return;
83011
83132
  case 307 /* JSDocTypeExpression */:
83012
83133
  return checkSourceElement(node.type);
83134
+ case 331 /* JSDocPublicTag */:
83135
+ case 333 /* JSDocProtectedTag */:
83136
+ case 332 /* JSDocPrivateTag */:
83137
+ return checkJSDocAccessibilityModifiers(node);
83013
83138
  case 193 /* IndexedAccessType */:
83014
83139
  return checkIndexedAccessType(node);
83015
83140
  case 194 /* MappedType */:
@@ -85705,8 +85830,8 @@ var ts;
85705
85830
  if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
85706
85831
  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));
85707
85832
  }
85708
- if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
85709
- 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));
85833
+ 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 */) {
85834
+ 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));
85710
85835
  }
85711
85836
  }
85712
85837
  }
@@ -86395,7 +86520,7 @@ var ts;
86395
86520
  }
86396
86521
  function checkGrammarImportCallExpression(node) {
86397
86522
  if (moduleKind === ts.ModuleKind.ES2015) {
86398
- 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);
86523
+ 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);
86399
86524
  }
86400
86525
  if (node.typeArguments) {
86401
86526
  return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
@@ -87509,7 +87634,7 @@ var ts;
87509
87634
  }
87510
87635
  ts.createSourceMapGenerator = createSourceMapGenerator;
87511
87636
  // Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
87512
- var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
87637
+ var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
87513
87638
  var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
87514
87639
  function getLineInfo(text, lineStarts) {
87515
87640
  return {
@@ -90801,6 +90926,7 @@ var ts;
90801
90926
  || (isExternalModuleExport(node)
90802
90927
  && moduleKind !== ts.ModuleKind.ES2015
90803
90928
  && moduleKind !== ts.ModuleKind.ES2020
90929
+ && moduleKind !== ts.ModuleKind.ES2022
90804
90930
  && moduleKind !== ts.ModuleKind.ESNext
90805
90931
  && moduleKind !== ts.ModuleKind.System);
90806
90932
  }
@@ -106479,6 +106605,7 @@ var ts;
106479
106605
  function getModuleTransformer(moduleKind) {
106480
106606
  switch (moduleKind) {
106481
106607
  case ts.ModuleKind.ESNext:
106608
+ case ts.ModuleKind.ES2022:
106482
106609
  case ts.ModuleKind.ES2020:
106483
106610
  case ts.ModuleKind.ES2015:
106484
106611
  return ts.transformECMAScriptModule;
@@ -119010,6 +119137,78 @@ var ts;
119010
119137
  }
119011
119138
  }
119012
119139
  }
119140
+ var MatchingMode;
119141
+ (function (MatchingMode) {
119142
+ MatchingMode[MatchingMode["Exact"] = 0] = "Exact";
119143
+ MatchingMode[MatchingMode["Directory"] = 1] = "Directory";
119144
+ MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern";
119145
+ })(MatchingMode || (MatchingMode = {}));
119146
+ function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) {
119147
+ if (mode === void 0) { mode = 0 /* Exact */; }
119148
+ if (typeof exports === "string") {
119149
+ var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
119150
+ var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
119151
+ switch (mode) {
119152
+ case 0 /* Exact */:
119153
+ if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) {
119154
+ return { moduleFileToTry: packageName };
119155
+ }
119156
+ break;
119157
+ case 1 /* Directory */:
119158
+ if (ts.containsPath(pathOrPattern, targetFilePath)) {
119159
+ var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
119160
+ return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
119161
+ }
119162
+ break;
119163
+ case 2 /* Pattern */:
119164
+ var starPos = pathOrPattern.indexOf("*");
119165
+ var leadingSlice = pathOrPattern.slice(0, starPos);
119166
+ var trailingSlice = pathOrPattern.slice(starPos + 1);
119167
+ if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) {
119168
+ var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
119169
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
119170
+ }
119171
+ if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) {
119172
+ var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
119173
+ return { moduleFileToTry: packageName.replace("*", starReplacement) };
119174
+ }
119175
+ break;
119176
+ }
119177
+ }
119178
+ else if (Array.isArray(exports)) {
119179
+ return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); });
119180
+ }
119181
+ else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null
119182
+ if (ts.allKeysStartWithDot(exports)) {
119183
+ // sub-mappings
119184
+ // 3 cases:
119185
+ // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode))
119186
+ // * pattern mappings (contains a *)
119187
+ // * exact mappings (no *, does not end with /)
119188
+ return ts.forEach(ts.getOwnKeys(exports), function (k) {
119189
+ var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined);
119190
+ var mode = ts.endsWith(k, "/") ? 1 /* Directory */
119191
+ : ts.stringContains(k, "*") ? 2 /* Pattern */
119192
+ : 0 /* Exact */;
119193
+ return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode);
119194
+ });
119195
+ }
119196
+ else {
119197
+ // conditional mapping
119198
+ for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) {
119199
+ var key = _a[_i];
119200
+ if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) {
119201
+ var subTarget = exports[key];
119202
+ var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions);
119203
+ if (result) {
119204
+ return result;
119205
+ }
119206
+ }
119207
+ }
119208
+ }
119209
+ }
119210
+ return undefined;
119211
+ }
119013
119212
  function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
119014
119213
  var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
119015
119214
  if (normalizedTargetPath === undefined) {
@@ -119039,7 +119238,15 @@ var ts;
119039
119238
  var moduleFileNameForExtensionless = void 0;
119040
119239
  while (true) {
119041
119240
  // If the module could be imported by a directory name, use that directory's name
119042
- var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
119241
+ var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
119242
+ if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) {
119243
+ if (blockedByExports) {
119244
+ return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution
119245
+ }
119246
+ if (verbatimFromExports) {
119247
+ return moduleFileToTry;
119248
+ }
119249
+ }
119043
119250
  if (packageRootPath) {
119044
119251
  moduleSpecifier = packageRootPath;
119045
119252
  isPackageRootPath = true;
@@ -119069,13 +119276,22 @@ var ts;
119069
119276
  var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
119070
119277
  var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
119071
119278
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
119072
- return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
119279
+ return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
119073
119280
  function tryDirectoryWithPackageJson(packageRootIndex) {
119074
119281
  var packageRootPath = path.substring(0, packageRootIndex);
119075
119282
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
119076
119283
  var moduleFileToTry = path;
119077
119284
  if (host.fileExists(packageJsonPath)) {
119078
119285
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119286
+ // TODO: Inject `require` or `import` condition based on the intended import mode
119287
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119288
+ if (fromExports) {
119289
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119290
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119291
+ }
119292
+ if (packageJsonContent.exports) {
119293
+ return { moduleFileToTry: path, blockedByExports: true };
119294
+ }
119079
119295
  var versionPaths = packageJsonContent.typesVersions
119080
119296
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
119081
119297
  : undefined;
@@ -138596,6 +138812,7 @@ var ts;
138596
138812
  return false;
138597
138813
  }
138598
138814
  }
138815
+ Rename.nodeIsEligibleForRename = nodeIsEligibleForRename;
138599
138816
  })(Rename = ts.Rename || (ts.Rename = {}));
138600
138817
  })(ts || (ts = {}));
138601
138818
  /* @internal */
@@ -139717,7 +139934,7 @@ var ts;
139717
139934
  if (!typeDisplayString) {
139718
139935
  continue;
139719
139936
  }
139720
- addTypeHints(typeDisplayString, param.end);
139937
+ addTypeHints(typeDisplayString, param.name.end);
139721
139938
  }
139722
139939
  }
139723
139940
  function getParameterDeclarationTypeDisplayString(symbol) {
@@ -148529,6 +148746,7 @@ var ts;
148529
148746
  case ts.ModuleKind.System:
148530
148747
  case ts.ModuleKind.ES2015:
148531
148748
  case ts.ModuleKind.ES2020:
148749
+ case ts.ModuleKind.ES2022:
148532
148750
  case ts.ModuleKind.ESNext:
148533
148751
  case ts.ModuleKind.None:
148534
148752
  // Fall back to the `import * as ns` style import.
@@ -150296,8 +150514,8 @@ var ts;
150296
150514
  (function (codefix) {
150297
150515
  codefix.registerCodeFix({
150298
150516
  errorCodes: [
150299
- 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,
150300
- 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,
150517
+ 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,
150518
+ 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,
150301
150519
  ],
150302
150520
  getCodeActions: function (context) {
150303
150521
  var compilerOptions = context.program.getCompilerOptions();
@@ -159891,6 +160109,8 @@ var ts;
159891
160109
  synchronizeHostData();
159892
160110
  var sourceFile = getValidSourceFile(fileName);
159893
160111
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
160112
+ if (!ts.Rename.nodeIsEligibleForRename(node))
160113
+ return undefined;
159894
160114
  if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) {
159895
160115
  var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement;
159896
160116
  return [openingElement, closingElement].map(function (node) {