typescript 4.5.1-rc → 4.6.0-dev.20211105

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.
@@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
22
22
  ar[i] = from[i];
23
23
  }
24
24
  }
25
- return to.concat(ar || Array.prototype.slice.call(from));
25
+ return to.concat(ar || from);
26
26
  };
27
27
  var __assign = (this && this.__assign) || function () {
28
28
  __assign = Object.assign || function(t) {
@@ -85,11 +85,11 @@ var ts;
85
85
  (function (ts) {
86
86
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
87
87
  // If changing the text in this section, be sure to test `configurePrerelease` too.
88
- ts.versionMajorMinor = "4.5";
88
+ ts.versionMajorMinor = "4.6";
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".1-rc";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20211105";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -4789,6 +4789,7 @@ var ts;
4789
4789
  NodeCheckFlags[NodeCheckFlags["ConstructorReferenceInClass"] = 33554432] = "ConstructorReferenceInClass";
4790
4790
  NodeCheckFlags[NodeCheckFlags["ContainsClassWithPrivateIdentifiers"] = 67108864] = "ContainsClassWithPrivateIdentifiers";
4791
4791
  NodeCheckFlags[NodeCheckFlags["ContainsSuperPropertyInStaticInitializer"] = 134217728] = "ContainsSuperPropertyInStaticInitializer";
4792
+ NodeCheckFlags[NodeCheckFlags["InCheckIdentifier"] = 268435456] = "InCheckIdentifier";
4792
4793
  })(NodeCheckFlags = ts.NodeCheckFlags || (ts.NodeCheckFlags = {}));
4793
4794
  var TypeFlags;
4794
4795
  (function (TypeFlags) {
@@ -4862,8 +4863,6 @@ var ts;
4862
4863
  // 'Narrowable' types are types where narrowing actually narrows.
4863
4864
  // This *should* be every type other than null, undefined, void, and never
4864
4865
  TypeFlags[TypeFlags["Narrowable"] = 536624127] = "Narrowable";
4865
- /* @internal */
4866
- TypeFlags[TypeFlags["NotPrimitiveUnion"] = 468598819] = "NotPrimitiveUnion";
4867
4866
  // The following flags are aggregated during union and intersection type construction
4868
4867
  /* @internal */
4869
4868
  TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
@@ -4876,6 +4875,10 @@ var ts;
4876
4875
  TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard";
4877
4876
  /* @internal */
4878
4877
  TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject";
4878
+ /* @internal */
4879
+ TypeFlags[TypeFlags["IncludesInstantiable"] = 33554432] = "IncludesInstantiable";
4880
+ /* @internal */
4881
+ TypeFlags[TypeFlags["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion";
4879
4882
  })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {}));
4880
4883
  // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags
4881
4884
  // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check
@@ -5209,6 +5212,7 @@ var ts;
5209
5212
  ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019";
5210
5213
  ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020";
5211
5214
  ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021";
5215
+ ScriptTarget[ScriptTarget["ES2022"] = 9] = "ES2022";
5212
5216
  ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext";
5213
5217
  ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON";
5214
5218
  ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest";
@@ -5377,15 +5381,16 @@ var ts;
5377
5381
  TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript";
5378
5382
  TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx";
5379
5383
  TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext";
5380
- TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021";
5381
- TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020";
5382
- TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019";
5383
- TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018";
5384
- TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017";
5385
- TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016";
5386
- TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015";
5387
- TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator";
5388
- TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment";
5384
+ TransformFlags[TransformFlags["ContainsES2022"] = 8] = "ContainsES2022";
5385
+ TransformFlags[TransformFlags["ContainsES2021"] = 16] = "ContainsES2021";
5386
+ TransformFlags[TransformFlags["ContainsES2020"] = 32] = "ContainsES2020";
5387
+ TransformFlags[TransformFlags["ContainsES2019"] = 64] = "ContainsES2019";
5388
+ TransformFlags[TransformFlags["ContainsES2018"] = 128] = "ContainsES2018";
5389
+ TransformFlags[TransformFlags["ContainsES2017"] = 256] = "ContainsES2017";
5390
+ TransformFlags[TransformFlags["ContainsES2016"] = 512] = "ContainsES2016";
5391
+ TransformFlags[TransformFlags["ContainsES2015"] = 1024] = "ContainsES2015";
5392
+ TransformFlags[TransformFlags["ContainsGenerator"] = 2048] = "ContainsGenerator";
5393
+ TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5389
5394
  // Markers
5390
5395
  // - Flags used to indicate that a subtree contains a specific transformation.
5391
5396
  TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
@@ -5412,15 +5417,16 @@ var ts;
5412
5417
  TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript";
5413
5418
  TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx";
5414
5419
  TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext";
5415
- TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021";
5416
- TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020";
5417
- TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019";
5418
- TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018";
5419
- TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017";
5420
- TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016";
5421
- TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015";
5422
- TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator";
5423
- TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment";
5420
+ TransformFlags[TransformFlags["AssertES2022"] = 8] = "AssertES2022";
5421
+ TransformFlags[TransformFlags["AssertES2021"] = 16] = "AssertES2021";
5422
+ TransformFlags[TransformFlags["AssertES2020"] = 32] = "AssertES2020";
5423
+ TransformFlags[TransformFlags["AssertES2019"] = 64] = "AssertES2019";
5424
+ TransformFlags[TransformFlags["AssertES2018"] = 128] = "AssertES2018";
5425
+ TransformFlags[TransformFlags["AssertES2017"] = 256] = "AssertES2017";
5426
+ TransformFlags[TransformFlags["AssertES2016"] = 512] = "AssertES2016";
5427
+ TransformFlags[TransformFlags["AssertES2015"] = 1024] = "AssertES2015";
5428
+ TransformFlags[TransformFlags["AssertGenerator"] = 2048] = "AssertGenerator";
5429
+ TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 4096] = "AssertDestructuringAssignment";
5424
5430
  // Scope Exclusions
5425
5431
  // - Bitmasks that exclude flags from propagating out of a specific context
5426
5432
  // into the subtree flags of their container.
@@ -8090,7 +8096,7 @@ var ts;
8090
8096
  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."),
8091
8097
  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."),
8092
8098
  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'."),
8093
- 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'."),
8099
+ Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'."),
8094
8100
  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."),
8095
8101
  Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
8096
8102
  String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
@@ -8690,11 +8696,12 @@ var ts;
8690
8696
  Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."),
8691
8697
  Namespace_name_cannot_be_0: diag(2819, ts.DiagnosticCategory.Error, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
8692
8698
  Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"),
8693
- Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext'."),
8699
+ Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'."),
8694
8700
  Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
8695
8701
  Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
8696
8702
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
8697
8703
  Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8704
+ Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
8698
8705
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8699
8706
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8700
8707
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -11721,6 +11728,7 @@ var ts;
11721
11728
  tokenValue = tokenValue.slice(0, -1);
11722
11729
  pos--;
11723
11730
  }
11731
+ return getIdentifierToken();
11724
11732
  }
11725
11733
  return token;
11726
11734
  }
@@ -11966,6 +11974,8 @@ var ts;
11966
11974
  switch (ts.getEmitScriptTarget(options)) {
11967
11975
  case 99 /* ESNext */:
11968
11976
  return "lib.esnext.full.d.ts";
11977
+ case 9 /* ES2022 */:
11978
+ return "lib.es2022.full.d.ts";
11969
11979
  case 8 /* ES2021 */:
11970
11980
  return "lib.es2021.full.d.ts";
11971
11981
  case 7 /* ES2020 */:
@@ -14432,6 +14442,7 @@ var ts;
14432
14442
  AsyncIterableIterator: ts.emptyArray,
14433
14443
  AsyncGenerator: ts.emptyArray,
14434
14444
  AsyncGeneratorFunction: ts.emptyArray,
14445
+ NumberFormat: ["formatToParts"]
14435
14446
  },
14436
14447
  es2019: {
14437
14448
  Array: ["flat", "flatMap"],
@@ -14453,8 +14464,21 @@ var ts;
14453
14464
  PromiseConstructor: ["any"],
14454
14465
  String: ["replaceAll"]
14455
14466
  },
14456
- esnext: {
14457
- NumberFormat: ["formatToParts"]
14467
+ es2022: {
14468
+ Array: ["at"],
14469
+ String: ["at"],
14470
+ Int8Array: ["at"],
14471
+ Uint8Array: ["at"],
14472
+ Uint8ClampedArray: ["at"],
14473
+ Int16Array: ["at"],
14474
+ Uint16Array: ["at"],
14475
+ Int32Array: ["at"],
14476
+ Uint32Array: ["at"],
14477
+ Float32Array: ["at"],
14478
+ Float64Array: ["at"],
14479
+ BigInt64Array: ["at"],
14480
+ BigUint64Array: ["at"],
14481
+ ObjectConstructor: ["hasOwn"]
14458
14482
  }
14459
14483
  };
14460
14484
  }
@@ -21994,7 +22018,7 @@ var ts;
21994
22018
  var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value);
21995
22019
  node.numericLiteralFlags = numericLiteralFlags;
21996
22020
  if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */)
21997
- node.transformFlags |= 512 /* ContainsES2015 */;
22021
+ node.transformFlags |= 1024 /* ContainsES2015 */;
21998
22022
  return node;
21999
22023
  }
22000
22024
  // @api
@@ -22013,7 +22037,7 @@ var ts;
22013
22037
  var node = createBaseStringLiteral(text, isSingleQuote);
22014
22038
  node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
22015
22039
  if (hasExtendedUnicodeEscape)
22016
- node.transformFlags |= 512 /* ContainsES2015 */;
22040
+ node.transformFlags |= 1024 /* ContainsES2015 */;
22017
22041
  return node;
22018
22042
  }
22019
22043
  // @api
@@ -22141,8 +22165,8 @@ var ts;
22141
22165
  case 131 /* AsyncKeyword */:
22142
22166
  // 'async' modifier is ES2017 (async functions) or ES2018 (async generators)
22143
22167
  transformFlags =
22144
- 128 /* ContainsES2017 */ |
22145
- 64 /* ContainsES2018 */;
22168
+ 256 /* ContainsES2017 */ |
22169
+ 128 /* ContainsES2018 */;
22146
22170
  break;
22147
22171
  case 123 /* PublicKeyword */:
22148
22172
  case 121 /* PrivateKeyword */:
@@ -22166,10 +22190,10 @@ var ts;
22166
22190
  transformFlags = 1 /* ContainsTypeScript */;
22167
22191
  break;
22168
22192
  case 106 /* SuperKeyword */:
22169
- transformFlags = 512 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
22193
+ transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
22170
22194
  break;
22171
22195
  case 124 /* StaticKeyword */:
22172
- transformFlags = 512 /* ContainsES2015 */;
22196
+ transformFlags = 1024 /* ContainsES2015 */;
22173
22197
  break;
22174
22198
  case 108 /* ThisKeyword */:
22175
22199
  // 'this' indicates a lexical 'this'
@@ -22266,7 +22290,7 @@ var ts;
22266
22290
  node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression);
22267
22291
  node.transformFlags |=
22268
22292
  propagateChildFlags(node.expression) |
22269
- 512 /* ContainsES2015 */ |
22293
+ 1024 /* ContainsES2015 */ |
22270
22294
  65536 /* ContainsComputedPropertyName */;
22271
22295
  return node;
22272
22296
  }
@@ -22314,7 +22338,7 @@ var ts;
22314
22338
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
22315
22339
  node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
22316
22340
  if (initializer || dotDotDotToken)
22317
- node.transformFlags |= 512 /* ContainsES2015 */;
22341
+ node.transformFlags |= 1024 /* ContainsES2015 */;
22318
22342
  }
22319
22343
  return node;
22320
22344
  }
@@ -22423,20 +22447,20 @@ var ts;
22423
22447
  node.transformFlags |=
22424
22448
  propagateChildFlags(node.asteriskToken) |
22425
22449
  propagateChildFlags(node.questionToken) |
22426
- 512 /* ContainsES2015 */;
22450
+ 1024 /* ContainsES2015 */;
22427
22451
  if (questionToken) {
22428
22452
  node.transformFlags |= 1 /* ContainsTypeScript */;
22429
22453
  }
22430
22454
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
22431
22455
  if (asteriskToken) {
22432
- node.transformFlags |= 64 /* ContainsES2018 */;
22456
+ node.transformFlags |= 128 /* ContainsES2018 */;
22433
22457
  }
22434
22458
  else {
22435
- node.transformFlags |= 128 /* ContainsES2017 */;
22459
+ node.transformFlags |= 256 /* ContainsES2017 */;
22436
22460
  }
22437
22461
  }
22438
22462
  else if (asteriskToken) {
22439
- node.transformFlags |= 1024 /* ContainsGenerator */;
22463
+ node.transformFlags |= 2048 /* ContainsGenerator */;
22440
22464
  }
22441
22465
  return node;
22442
22466
  }
@@ -22477,7 +22501,7 @@ var ts;
22477
22501
  /*name*/ undefined,
22478
22502
  /*typeParameters*/ undefined, parameters,
22479
22503
  /*type*/ undefined, body);
22480
- node.transformFlags |= 512 /* ContainsES2015 */;
22504
+ node.transformFlags |= 1024 /* ContainsES2015 */;
22481
22505
  return node;
22482
22506
  }
22483
22507
  // @api
@@ -22971,11 +22995,11 @@ var ts;
22971
22995
  node.elements = createNodeArray(elements);
22972
22996
  node.transformFlags |=
22973
22997
  propagateChildrenFlags(node.elements) |
22974
- 512 /* ContainsES2015 */ |
22998
+ 1024 /* ContainsES2015 */ |
22975
22999
  262144 /* ContainsBindingPattern */;
22976
23000
  if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
22977
23001
  node.transformFlags |=
22978
- 64 /* ContainsES2018 */ |
23002
+ 128 /* ContainsES2018 */ |
22979
23003
  32768 /* ContainsObjectRestOrSpread */;
22980
23004
  }
22981
23005
  return node;
@@ -22992,7 +23016,7 @@ var ts;
22992
23016
  node.elements = createNodeArray(elements);
22993
23017
  node.transformFlags |=
22994
23018
  propagateChildrenFlags(node.elements) |
22995
- 512 /* ContainsES2015 */ |
23019
+ 1024 /* ContainsES2015 */ |
22996
23020
  262144 /* ContainsBindingPattern */;
22997
23021
  return node;
22998
23022
  }
@@ -23011,7 +23035,7 @@ var ts;
23011
23035
  node.dotDotDotToken = dotDotDotToken;
23012
23036
  node.transformFlags |=
23013
23037
  propagateChildFlags(node.dotDotDotToken) |
23014
- 512 /* ContainsES2015 */;
23038
+ 1024 /* ContainsES2015 */;
23015
23039
  if (node.propertyName) {
23016
23040
  node.transformFlags |= ts.isIdentifier(node.propertyName) ?
23017
23041
  propagateIdentifierNameFlags(node.propertyName) :
@@ -23085,8 +23109,8 @@ var ts;
23085
23109
  // super method calls require a lexical 'this'
23086
23110
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
23087
23111
  node.transformFlags |=
23088
- 128 /* ContainsES2017 */ |
23089
- 64 /* ContainsES2018 */;
23112
+ 256 /* ContainsES2017 */ |
23113
+ 128 /* ContainsES2018 */;
23090
23114
  }
23091
23115
  return node;
23092
23116
  }
@@ -23108,7 +23132,7 @@ var ts;
23108
23132
  node.questionDotToken = questionDotToken;
23109
23133
  node.name = asName(name);
23110
23134
  node.transformFlags |=
23111
- 16 /* ContainsES2020 */ |
23135
+ 32 /* ContainsES2020 */ |
23112
23136
  propagateChildFlags(node.expression) |
23113
23137
  propagateChildFlags(node.questionDotToken) |
23114
23138
  (ts.isIdentifier(node.name) ?
@@ -23139,8 +23163,8 @@ var ts;
23139
23163
  // super method calls require a lexical 'this'
23140
23164
  // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators
23141
23165
  node.transformFlags |=
23142
- 128 /* ContainsES2017 */ |
23143
- 64 /* ContainsES2018 */;
23166
+ 256 /* ContainsES2017 */ |
23167
+ 128 /* ContainsES2018 */;
23144
23168
  }
23145
23169
  return node;
23146
23170
  }
@@ -23165,7 +23189,7 @@ var ts;
23165
23189
  propagateChildFlags(node.expression) |
23166
23190
  propagateChildFlags(node.questionDotToken) |
23167
23191
  propagateChildFlags(node.argumentExpression) |
23168
- 16 /* ContainsES2020 */;
23192
+ 32 /* ContainsES2020 */;
23169
23193
  return node;
23170
23194
  }
23171
23195
  // @api
@@ -23224,7 +23248,7 @@ var ts;
23224
23248
  propagateChildFlags(node.questionDotToken) |
23225
23249
  propagateChildrenFlags(node.typeArguments) |
23226
23250
  propagateChildrenFlags(node.arguments) |
23227
- 16 /* ContainsES2020 */;
23251
+ 32 /* ContainsES2020 */;
23228
23252
  if (node.typeArguments) {
23229
23253
  node.transformFlags |= 1 /* ContainsTypeScript */;
23230
23254
  }
@@ -23253,7 +23277,7 @@ var ts;
23253
23277
  propagateChildFlags(node.expression) |
23254
23278
  propagateChildrenFlags(node.typeArguments) |
23255
23279
  propagateChildrenFlags(node.arguments) |
23256
- 16 /* ContainsES2020 */;
23280
+ 32 /* ContainsES2020 */;
23257
23281
  if (node.typeArguments) {
23258
23282
  node.transformFlags |= 1 /* ContainsTypeScript */;
23259
23283
  }
@@ -23277,12 +23301,12 @@ var ts;
23277
23301
  propagateChildFlags(node.tag) |
23278
23302
  propagateChildrenFlags(node.typeArguments) |
23279
23303
  propagateChildFlags(node.template) |
23280
- 512 /* ContainsES2015 */;
23304
+ 1024 /* ContainsES2015 */;
23281
23305
  if (node.typeArguments) {
23282
23306
  node.transformFlags |= 1 /* ContainsTypeScript */;
23283
23307
  }
23284
23308
  if (ts.hasInvalidEscape(node.template)) {
23285
- node.transformFlags |= 64 /* ContainsES2018 */;
23309
+ node.transformFlags |= 128 /* ContainsES2018 */;
23286
23310
  }
23287
23311
  return node;
23288
23312
  }
@@ -23336,14 +23360,14 @@ var ts;
23336
23360
  }
23337
23361
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
23338
23362
  if (node.asteriskToken) {
23339
- node.transformFlags |= 64 /* ContainsES2018 */;
23363
+ node.transformFlags |= 128 /* ContainsES2018 */;
23340
23364
  }
23341
23365
  else {
23342
- node.transformFlags |= 128 /* ContainsES2017 */;
23366
+ node.transformFlags |= 256 /* ContainsES2017 */;
23343
23367
  }
23344
23368
  }
23345
23369
  else if (node.asteriskToken) {
23346
- node.transformFlags |= 1024 /* ContainsGenerator */;
23370
+ node.transformFlags |= 2048 /* ContainsGenerator */;
23347
23371
  }
23348
23372
  return node;
23349
23373
  }
@@ -23367,9 +23391,9 @@ var ts;
23367
23391
  node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */);
23368
23392
  node.transformFlags |=
23369
23393
  propagateChildFlags(node.equalsGreaterThanToken) |
23370
- 512 /* ContainsES2015 */;
23394
+ 1024 /* ContainsES2015 */;
23371
23395
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
23372
- node.transformFlags |= 128 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
23396
+ node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
23373
23397
  }
23374
23398
  return node;
23375
23399
  }
@@ -23429,8 +23453,8 @@ var ts;
23429
23453
  node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
23430
23454
  node.transformFlags |=
23431
23455
  propagateChildFlags(node.expression) |
23432
- 128 /* ContainsES2017 */ |
23433
- 64 /* ContainsES2018 */ |
23456
+ 256 /* ContainsES2017 */ |
23457
+ 128 /* ContainsES2018 */ |
23434
23458
  1048576 /* ContainsAwait */;
23435
23459
  return node;
23436
23460
  }
@@ -23496,35 +23520,35 @@ var ts;
23496
23520
  propagateChildFlags(node.operatorToken) |
23497
23521
  propagateChildFlags(node.right);
23498
23522
  if (operatorKind === 60 /* QuestionQuestionToken */) {
23499
- node.transformFlags |= 16 /* ContainsES2020 */;
23523
+ node.transformFlags |= 32 /* ContainsES2020 */;
23500
23524
  }
23501
23525
  else if (operatorKind === 63 /* EqualsToken */) {
23502
23526
  if (ts.isObjectLiteralExpression(node.left)) {
23503
23527
  node.transformFlags |=
23504
- 512 /* ContainsES2015 */ |
23505
- 64 /* ContainsES2018 */ |
23506
- 2048 /* ContainsDestructuringAssignment */ |
23528
+ 1024 /* ContainsES2015 */ |
23529
+ 128 /* ContainsES2018 */ |
23530
+ 4096 /* ContainsDestructuringAssignment */ |
23507
23531
  propagateAssignmentPatternFlags(node.left);
23508
23532
  }
23509
23533
  else if (ts.isArrayLiteralExpression(node.left)) {
23510
23534
  node.transformFlags |=
23511
- 512 /* ContainsES2015 */ |
23512
- 2048 /* ContainsDestructuringAssignment */ |
23535
+ 1024 /* ContainsES2015 */ |
23536
+ 4096 /* ContainsDestructuringAssignment */ |
23513
23537
  propagateAssignmentPatternFlags(node.left);
23514
23538
  }
23515
23539
  }
23516
23540
  else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) {
23517
- node.transformFlags |= 256 /* ContainsES2016 */;
23541
+ node.transformFlags |= 512 /* ContainsES2016 */;
23518
23542
  }
23519
23543
  else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
23520
- node.transformFlags |= 8 /* ContainsES2021 */;
23544
+ node.transformFlags |= 16 /* ContainsES2021 */;
23521
23545
  }
23522
23546
  return node;
23523
23547
  }
23524
23548
  function propagateAssignmentPatternFlags(node) {
23525
23549
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
23526
23550
  return 32768 /* ContainsObjectRestOrSpread */;
23527
- if (node.transformFlags & 64 /* ContainsES2018 */) {
23551
+ if (node.transformFlags & 128 /* ContainsES2018 */) {
23528
23552
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
23529
23553
  // will not be correctly interpreted by the ES2018 transformer
23530
23554
  for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) {
@@ -23534,7 +23558,7 @@ var ts;
23534
23558
  if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
23535
23559
  return 32768 /* ContainsObjectRestOrSpread */;
23536
23560
  }
23537
- if (target.transformFlags & 64 /* ContainsES2018 */) {
23561
+ if (target.transformFlags & 128 /* ContainsES2018 */) {
23538
23562
  var flags_1 = propagateAssignmentPatternFlags(target);
23539
23563
  if (flags_1)
23540
23564
  return flags_1;
@@ -23586,7 +23610,7 @@ var ts;
23586
23610
  node.transformFlags |=
23587
23611
  propagateChildFlags(node.head) |
23588
23612
  propagateChildrenFlags(node.templateSpans) |
23589
- 512 /* ContainsES2015 */;
23613
+ 1024 /* ContainsES2015 */;
23590
23614
  return node;
23591
23615
  }
23592
23616
  // @api
@@ -23625,9 +23649,9 @@ var ts;
23625
23649
  node.text = text;
23626
23650
  node.rawText = rawText;
23627
23651
  node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */;
23628
- node.transformFlags |= 512 /* ContainsES2015 */;
23652
+ node.transformFlags |= 1024 /* ContainsES2015 */;
23629
23653
  if (node.templateFlags) {
23630
- node.transformFlags |= 64 /* ContainsES2018 */;
23654
+ node.transformFlags |= 128 /* ContainsES2018 */;
23631
23655
  }
23632
23656
  return node;
23633
23657
  }
@@ -23656,8 +23680,8 @@ var ts;
23656
23680
  node.transformFlags |=
23657
23681
  propagateChildFlags(node.expression) |
23658
23682
  propagateChildFlags(node.asteriskToken) |
23659
- 512 /* ContainsES2015 */ |
23660
- 64 /* ContainsES2018 */ |
23683
+ 1024 /* ContainsES2015 */ |
23684
+ 128 /* ContainsES2018 */ |
23661
23685
  524288 /* ContainsYield */;
23662
23686
  return node;
23663
23687
  }
@@ -23674,7 +23698,7 @@ var ts;
23674
23698
  node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
23675
23699
  node.transformFlags |=
23676
23700
  propagateChildFlags(node.expression) |
23677
- 512 /* ContainsES2015 */ |
23701
+ 1024 /* ContainsES2015 */ |
23678
23702
  16384 /* ContainsRestOrSpread */;
23679
23703
  return node;
23680
23704
  }
@@ -23687,7 +23711,7 @@ var ts;
23687
23711
  // @api
23688
23712
  function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) {
23689
23713
  var node = createBaseClassLikeDeclaration(225 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members);
23690
- node.transformFlags |= 512 /* ContainsES2015 */;
23714
+ node.transformFlags |= 1024 /* ContainsES2015 */;
23691
23715
  return node;
23692
23716
  }
23693
23717
  // @api
@@ -23713,7 +23737,7 @@ var ts;
23713
23737
  node.transformFlags |=
23714
23738
  propagateChildFlags(node.expression) |
23715
23739
  propagateChildrenFlags(node.typeArguments) |
23716
- 512 /* ContainsES2015 */;
23740
+ 1024 /* ContainsES2015 */;
23717
23741
  return node;
23718
23742
  }
23719
23743
  // @api
@@ -23784,7 +23808,7 @@ var ts;
23784
23808
  node.transformFlags |= propagateChildFlags(node.name);
23785
23809
  switch (keywordToken) {
23786
23810
  case 103 /* NewKeyword */:
23787
- node.transformFlags |= 512 /* ContainsES2015 */;
23811
+ node.transformFlags |= 1024 /* ContainsES2015 */;
23788
23812
  break;
23789
23813
  case 100 /* ImportKeyword */:
23790
23814
  node.transformFlags |= 4 /* ContainsESNext */;
@@ -23811,7 +23835,7 @@ var ts;
23811
23835
  node.transformFlags |=
23812
23836
  propagateChildFlags(node.expression) |
23813
23837
  propagateChildFlags(node.literal) |
23814
- 512 /* ContainsES2015 */;
23838
+ 1024 /* ContainsES2015 */;
23815
23839
  return node;
23816
23840
  }
23817
23841
  // @api
@@ -23824,7 +23848,7 @@ var ts;
23824
23848
  // @api
23825
23849
  function createSemicolonClassElement() {
23826
23850
  var node = createBaseNode(233 /* SemicolonClassElement */);
23827
- node.transformFlags |= 512 /* ContainsES2015 */;
23851
+ node.transformFlags |= 1024 /* ContainsES2015 */;
23828
23852
  return node;
23829
23853
  }
23830
23854
  //
@@ -23988,9 +24012,9 @@ var ts;
23988
24012
  propagateChildFlags(node.initializer) |
23989
24013
  propagateChildFlags(node.expression) |
23990
24014
  propagateChildFlags(node.statement) |
23991
- 512 /* ContainsES2015 */;
24015
+ 1024 /* ContainsES2015 */;
23992
24016
  if (awaitModifier)
23993
- node.transformFlags |= 64 /* ContainsES2018 */;
24017
+ node.transformFlags |= 128 /* ContainsES2018 */;
23994
24018
  return node;
23995
24019
  }
23996
24020
  // @api
@@ -24039,7 +24063,7 @@ var ts;
24039
24063
  // return in an ES2018 async generator must be awaited
24040
24064
  node.transformFlags |=
24041
24065
  propagateChildFlags(node.expression) |
24042
- 64 /* ContainsES2018 */ |
24066
+ 128 /* ContainsES2018 */ |
24043
24067
  2097152 /* ContainsHoistedDeclarationOrCompletion */;
24044
24068
  return node;
24045
24069
  }
@@ -24169,7 +24193,7 @@ var ts;
24169
24193
  2097152 /* ContainsHoistedDeclarationOrCompletion */;
24170
24194
  if (flags & 3 /* BlockScoped */) {
24171
24195
  node.transformFlags |=
24172
- 512 /* ContainsES2015 */ |
24196
+ 1024 /* ContainsES2015 */ |
24173
24197
  131072 /* ContainsBlockScopedBinding */;
24174
24198
  }
24175
24199
  return node;
@@ -24193,14 +24217,14 @@ var ts;
24193
24217
  2097152 /* ContainsHoistedDeclarationOrCompletion */;
24194
24218
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24195
24219
  if (node.asteriskToken) {
24196
- node.transformFlags |= 64 /* ContainsES2018 */;
24220
+ node.transformFlags |= 128 /* ContainsES2018 */;
24197
24221
  }
24198
24222
  else {
24199
- node.transformFlags |= 128 /* ContainsES2017 */;
24223
+ node.transformFlags |= 256 /* ContainsES2017 */;
24200
24224
  }
24201
24225
  }
24202
24226
  else if (node.asteriskToken) {
24203
- node.transformFlags |= 1024 /* ContainsGenerator */;
24227
+ node.transformFlags |= 2048 /* ContainsGenerator */;
24204
24228
  }
24205
24229
  }
24206
24230
  return node;
@@ -24225,7 +24249,7 @@ var ts;
24225
24249
  node.transformFlags = 1 /* ContainsTypeScript */;
24226
24250
  }
24227
24251
  else {
24228
- node.transformFlags |= 512 /* ContainsES2015 */;
24252
+ node.transformFlags |= 1024 /* ContainsES2015 */;
24229
24253
  if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
24230
24254
  node.transformFlags |= 1 /* ContainsTypeScript */;
24231
24255
  }
@@ -25265,7 +25289,7 @@ var ts;
25265
25289
  node.transformFlags |= propagateChildrenFlags(node.types);
25266
25290
  switch (token) {
25267
25291
  case 94 /* ExtendsKeyword */:
25268
- node.transformFlags |= 512 /* ContainsES2015 */;
25292
+ node.transformFlags |= 1024 /* ContainsES2015 */;
25269
25293
  break;
25270
25294
  case 117 /* ImplementsKeyword */:
25271
25295
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -25296,7 +25320,7 @@ var ts;
25296
25320
  propagateChildFlags(node.variableDeclaration) |
25297
25321
  propagateChildFlags(node.block);
25298
25322
  if (!variableDeclaration)
25299
- node.transformFlags |= 32 /* ContainsES2019 */;
25323
+ node.transformFlags |= 64 /* ContainsES2019 */;
25300
25324
  return node;
25301
25325
  }
25302
25326
  // @api
@@ -25347,7 +25371,7 @@ var ts;
25347
25371
  node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer);
25348
25372
  node.transformFlags |=
25349
25373
  propagateChildFlags(node.objectAssignmentInitializer) |
25350
- 512 /* ContainsES2015 */;
25374
+ 1024 /* ContainsES2015 */;
25351
25375
  return node;
25352
25376
  }
25353
25377
  function finishUpdateShorthandPropertyAssignment(updated, original) {
@@ -25377,7 +25401,7 @@ var ts;
25377
25401
  node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
25378
25402
  node.transformFlags |=
25379
25403
  propagateChildFlags(node.expression) |
25380
- 64 /* ContainsES2018 */ |
25404
+ 128 /* ContainsES2018 */ |
25381
25405
  32768 /* ContainsObjectRestOrSpread */;
25382
25406
  return node;
25383
25407
  }
@@ -38050,6 +38074,7 @@ var ts;
38050
38074
  ["es2019", "lib.es2019.d.ts"],
38051
38075
  ["es2020", "lib.es2020.d.ts"],
38052
38076
  ["es2021", "lib.es2021.d.ts"],
38077
+ ["es2022", "lib.es2022.d.ts"],
38053
38078
  ["esnext", "lib.esnext.d.ts"],
38054
38079
  // Host only
38055
38080
  ["dom", "lib.dom.d.ts"],
@@ -38093,12 +38118,16 @@ var ts;
38093
38118
  ["es2021.string", "lib.es2021.string.d.ts"],
38094
38119
  ["es2021.weakref", "lib.es2021.weakref.d.ts"],
38095
38120
  ["es2021.intl", "lib.es2021.intl.d.ts"],
38096
- ["esnext.array", "lib.es2019.array.d.ts"],
38121
+ ["es2022.array", "lib.es2022.array.d.ts"],
38122
+ ["es2022.error", "lib.es2022.error.d.ts"],
38123
+ ["es2022.object", "lib.es2022.object.d.ts"],
38124
+ ["es2022.string", "lib.es2022.string.d.ts"],
38125
+ ["esnext.array", "lib.es2022.array.d.ts"],
38097
38126
  ["esnext.symbol", "lib.es2019.symbol.d.ts"],
38098
38127
  ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
38099
38128
  ["esnext.intl", "lib.esnext.intl.d.ts"],
38100
38129
  ["esnext.bigint", "lib.es2020.bigint.d.ts"],
38101
- ["esnext.string", "lib.es2021.string.d.ts"],
38130
+ ["esnext.string", "lib.es2022.string.d.ts"],
38102
38131
  ["esnext.promise", "lib.es2021.promise.d.ts"],
38103
38132
  ["esnext.weakref", "lib.es2021.weakref.d.ts"]
38104
38133
  ];
@@ -38330,6 +38359,7 @@ var ts;
38330
38359
  es2019: 6 /* ES2019 */,
38331
38360
  es2020: 7 /* ES2020 */,
38332
38361
  es2021: 8 /* ES2021 */,
38362
+ es2022: 9 /* ES2022 */,
38333
38363
  esnext: 99 /* ESNext */,
38334
38364
  })),
38335
38365
  affectsSourceFile: true,
@@ -54107,12 +54137,15 @@ var ts;
54107
54137
  }
54108
54138
  /** Return the inferred type for a binding element */
54109
54139
  function getTypeForBindingElement(declaration) {
54110
- var pattern = declaration.parent;
54111
- var parentType = getTypeForBindingElementParent(pattern.parent);
54112
- // If no type or an any type was inferred for parent, infer that for the binding element
54113
- if (!parentType || isTypeAny(parentType)) {
54140
+ var parentType = getTypeForBindingElementParent(declaration.parent.parent);
54141
+ return parentType && getBindingElementTypeFromParentType(declaration, parentType);
54142
+ }
54143
+ function getBindingElementTypeFromParentType(declaration, parentType) {
54144
+ // If an any type was inferred for parent, infer that for the binding element
54145
+ if (isTypeAny(parentType)) {
54114
54146
  return parentType;
54115
54147
  }
54148
+ var pattern = declaration.parent;
54116
54149
  // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
54117
54150
  if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
54118
54151
  parentType = getNonNullableType(parentType);
@@ -59324,6 +59357,8 @@ var ts;
59324
59357
  // We ignore 'never' types in unions
59325
59358
  if (!(flags & 131072 /* Never */)) {
59326
59359
  includes |= flags & 205258751 /* IncludesMask */;
59360
+ if (flags & 465829888 /* Instantiable */)
59361
+ includes |= 33554432 /* IncludesInstantiable */;
59327
59362
  if (type === wildcardType)
59328
59363
  includes |= 8388608 /* IncludesWildcard */;
59329
59364
  if (!strictNullChecks && flags & 98304 /* Nullable */) {
@@ -59537,7 +59572,7 @@ var ts;
59537
59572
  origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes);
59538
59573
  }
59539
59574
  }
59540
- var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
59575
+ var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) |
59541
59576
  (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0);
59542
59577
  return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
59543
59578
  }
@@ -62732,7 +62767,7 @@ var ts;
62732
62767
  return true;
62733
62768
  }
62734
62769
  if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) {
62735
- var related = relation.get(getRelationKey(source, target, 0 /* None */, relation));
62770
+ var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false));
62736
62771
  if (related !== undefined) {
62737
62772
  return !!(related & 1 /* Succeeded */);
62738
62773
  }
@@ -63581,7 +63616,8 @@ var ts;
63581
63616
  if (overflow) {
63582
63617
  return 0 /* False */;
63583
63618
  }
63584
- var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0), relation);
63619
+ var keyIntersectionState = intersectionState | (inPropertyCheck ? 16 /* InPropertyCheck */ : 0);
63620
+ var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
63585
63621
  var entry = relation.get(id);
63586
63622
  if (entry !== undefined) {
63587
63623
  if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) {
@@ -63608,16 +63644,13 @@ var ts;
63608
63644
  targetStack = [];
63609
63645
  }
63610
63646
  else {
63611
- // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids
63612
- // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus
63613
- // prevent finding matches- but it should hit up the common cases
63614
- var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) {
63615
- var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined);
63616
- return "=" + index;
63617
- }); }).join(",");
63647
+ // A key that starts with "*" is an indication that we have type references that reference constrained
63648
+ // type parameters. For such keys we also check against the key we would have gotten if all type parameters
63649
+ // were unconstrained.
63650
+ var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, keyIntersectionState, relation, /*ignoreConstraints*/ true) : undefined;
63618
63651
  for (var i = 0; i < maybeCount; i++) {
63619
63652
  // If source and target are already being compared, consider them related with assumptions
63620
- if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) {
63653
+ if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
63621
63654
  return 3 /* Maybe */;
63622
63655
  }
63623
63656
  }
@@ -63912,7 +63945,7 @@ var ts;
63912
63945
  originalErrorInfo = undefined;
63913
63946
  }
63914
63947
  }
63915
- else if (isGenericMappedType(target)) {
63948
+ else if (isGenericMappedType(target) && relation !== identityRelation) {
63916
63949
  // Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`.
63917
63950
  var keysRemapped = !!target.declaration.nameType;
63918
63951
  var templateType = getTemplateTypeFromMappedType(target);
@@ -65124,48 +65157,56 @@ var ts;
65124
65157
  function isTypeReferenceWithGenericArguments(type) {
65125
65158
  return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); });
65126
65159
  }
65127
- /**
65128
- * getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65129
- * where A.id=111 and number.id=12
65130
- */
65131
- function getTypeReferenceId(type, typeParameters, depth) {
65132
- if (depth === void 0) { depth = 0; }
65133
- var result = "" + type.target.id;
65134
- for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65135
- var t = _a[_i];
65136
- if (isUnconstrainedTypeParameter(t)) {
65137
- var index = typeParameters.indexOf(t);
65138
- if (index < 0) {
65139
- index = typeParameters.length;
65140
- typeParameters.push(t);
65160
+ function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) {
65161
+ var typeParameters = [];
65162
+ var constraintMarker = "";
65163
+ var sourceId = getTypeReferenceId(source, 0);
65164
+ var targetId = getTypeReferenceId(target, 0);
65165
+ return "" + constraintMarker + sourceId + "," + targetId + postFix;
65166
+ // getTypeReferenceId(A<T, number, U>) returns "111=0-12=1"
65167
+ // where A.id=111 and number.id=12
65168
+ function getTypeReferenceId(type, depth) {
65169
+ if (depth === void 0) { depth = 0; }
65170
+ var result = "" + type.target.id;
65171
+ for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
65172
+ var t = _a[_i];
65173
+ if (t.flags & 262144 /* TypeParameter */) {
65174
+ if (ignoreConstraints || isUnconstrainedTypeParameter(t)) {
65175
+ var index = typeParameters.indexOf(t);
65176
+ if (index < 0) {
65177
+ index = typeParameters.length;
65178
+ typeParameters.push(t);
65179
+ }
65180
+ result += "=" + index;
65181
+ continue;
65182
+ }
65183
+ // We mark type references that reference constrained type parameters such that we know to obtain
65184
+ // and look for a "broadest equivalent key" in the cache.
65185
+ constraintMarker = "*";
65186
+ }
65187
+ else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65188
+ result += "<" + getTypeReferenceId(t, depth + 1) + ">";
65189
+ continue;
65141
65190
  }
65142
- result += "=" + index;
65143
- }
65144
- else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
65145
- result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
65146
- }
65147
- else {
65148
65191
  result += "-" + t.id;
65149
65192
  }
65193
+ return result;
65150
65194
  }
65151
- return result;
65152
65195
  }
65153
65196
  /**
65154
65197
  * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
65155
65198
  * For other cases, the types ids are used.
65156
65199
  */
65157
- function getRelationKey(source, target, intersectionState, relation) {
65200
+ function getRelationKey(source, target, intersectionState, relation, ignoreConstraints) {
65158
65201
  if (relation === identityRelation && source.id > target.id) {
65159
65202
  var temp = source;
65160
65203
  source = target;
65161
65204
  target = temp;
65162
65205
  }
65163
65206
  var postFix = intersectionState ? ":" + intersectionState : "";
65164
- if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
65165
- var typeParameters = [];
65166
- return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
65167
- }
65168
- return source.id + "," + target.id + postFix;
65207
+ return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ?
65208
+ getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) :
65209
+ source.id + "," + target.id + postFix;
65169
65210
  }
65170
65211
  // Invoke the callback for each underlying property symbol of the given symbol and return the first
65171
65212
  // value that isn't undefined.
@@ -65213,28 +65254,35 @@ var ts;
65213
65254
  !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
65214
65255
  }
65215
65256
  // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons
65216
- // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65257
+ // for maxDepth or more occurrences or instantiations of the type have been recorded on the given stack. It is possible,
65217
65258
  // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely
65218
- // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5
65259
+ // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least maxDepth
65219
65260
  // levels, but unequal at some level beyond that.
65220
- // In addition, this will also detect when an indexed access has been chained off of 5 or more times (which is essentially
65221
- // the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding false positives
65222
- // for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65223
- // It also detects when a recursive type reference has expanded 5 or more times, eg, if the true branch of
65261
+ // In addition, this will also detect when an indexed access has been chained off of maxDepth more times (which is
65262
+ // essentially the dual of the structural comparison), and likewise mark the type as deeply nested, potentially adding
65263
+ // false positives for finite but deeply expanding indexed accesses (eg, for `Q[P1][P2][P3][P4][P5]`).
65264
+ // It also detects when a recursive type reference has expanded maxDepth or more times, e.g. if the true branch of
65224
65265
  // `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
65225
- // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
65226
- // in such cases we need to terminate the expansion, and we do so here.
65266
+ // has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`. In such cases we need
65267
+ // to terminate the expansion, and we do so here.
65227
65268
  function isDeeplyNestedType(type, stack, depth, maxDepth) {
65228
- if (maxDepth === void 0) { maxDepth = 5; }
65269
+ if (maxDepth === void 0) { maxDepth = 3; }
65229
65270
  if (depth >= maxDepth) {
65230
65271
  var identity_1 = getRecursionIdentity(type);
65231
65272
  var count = 0;
65273
+ var lastTypeId = 0;
65232
65274
  for (var i = 0; i < depth; i++) {
65233
- if (getRecursionIdentity(stack[i]) === identity_1) {
65234
- count++;
65235
- if (count >= maxDepth) {
65236
- return true;
65275
+ var t = stack[i];
65276
+ if (getRecursionIdentity(t) === identity_1) {
65277
+ // We only count occurrences with a higher type id than the previous occurrence, since higher
65278
+ // type ids are an indicator of newer instantiations caused by recursion.
65279
+ if (t.id >= lastTypeId) {
65280
+ count++;
65281
+ if (count >= maxDepth) {
65282
+ return true;
65283
+ }
65237
65284
  }
65285
+ lastTypeId = t.id;
65238
65286
  }
65239
65287
  }
65240
65288
  }
@@ -65973,7 +66021,8 @@ var ts;
65973
66021
  (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) ||
65974
66022
  param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
65975
66023
  var newName = "arg" + param.parent.parameters.indexOf(param);
65976
- errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
66024
+ var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : "");
66025
+ errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName);
65977
66026
  return;
65978
66027
  }
65979
66028
  diagnostic = declaration.dotDotDotToken ?
@@ -67339,29 +67388,6 @@ var ts;
67339
67388
  }
67340
67389
  return false;
67341
67390
  }
67342
- function getPropertyAccess(expr) {
67343
- if (ts.isAccessExpression(expr)) {
67344
- return expr;
67345
- }
67346
- if (ts.isIdentifier(expr)) {
67347
- var symbol = getResolvedSymbol(expr);
67348
- if (isConstVariable(symbol)) {
67349
- var declaration = symbol.valueDeclaration;
67350
- // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
67351
- if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer)) {
67352
- return declaration.initializer;
67353
- }
67354
- // Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
67355
- if (ts.isBindingElement(declaration) && !declaration.initializer) {
67356
- var parent = declaration.parent.parent;
67357
- if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer))) {
67358
- return declaration;
67359
- }
67360
- }
67361
- }
67362
- }
67363
- return undefined;
67364
- }
67365
67391
  function getAccessedPropertyName(access) {
67366
67392
  var propertyName;
67367
67393
  return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
@@ -68260,20 +68286,21 @@ var ts;
68260
68286
  }
68261
68287
  return false;
68262
68288
  }
68263
- function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer) {
68289
+ function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, flowNode) {
68264
68290
  if (initialType === void 0) { initialType = declaredType; }
68291
+ if (flowNode === void 0) { flowNode = reference.flowNode; }
68265
68292
  var key;
68266
68293
  var isKeySet = false;
68267
68294
  var flowDepth = 0;
68268
68295
  if (flowAnalysisDisabled) {
68269
68296
  return errorType;
68270
68297
  }
68271
- if (!reference.flowNode) {
68298
+ if (!flowNode) {
68272
68299
  return declaredType;
68273
68300
  }
68274
68301
  flowInvocationCount++;
68275
68302
  var sharedFlowStart = sharedFlowCount;
68276
- var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
68303
+ var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(flowNode));
68277
68304
  sharedFlowCount = sharedFlowStart;
68278
68305
  // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation,
68279
68306
  // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations
@@ -68705,13 +68732,57 @@ var ts;
68705
68732
  }
68706
68733
  return result;
68707
68734
  }
68735
+ function getCandidateDiscriminantPropertyAccess(expr) {
68736
+ if (ts.isBindingPattern(reference)) {
68737
+ // When the reference is a binding pattern, we are narrowing a pesudo-reference in getNarrowedTypeOfSymbol.
68738
+ // An identifier for a destructuring variable declared in the same binding pattern is a candidate.
68739
+ if (ts.isIdentifier(expr)) {
68740
+ var symbol = getResolvedSymbol(expr);
68741
+ var declaration = symbol.valueDeclaration;
68742
+ if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && reference === declaration.parent) {
68743
+ return declaration;
68744
+ }
68745
+ }
68746
+ }
68747
+ else if (ts.isAccessExpression(expr)) {
68748
+ // An access expression is a candidate if the reference matches the left hand expression.
68749
+ if (isMatchingReference(reference, expr.expression)) {
68750
+ return expr;
68751
+ }
68752
+ }
68753
+ else if (ts.isIdentifier(expr)) {
68754
+ var symbol = getResolvedSymbol(expr);
68755
+ if (isConstVariable(symbol)) {
68756
+ var declaration = symbol.valueDeclaration;
68757
+ // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind'
68758
+ if (ts.isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && ts.isAccessExpression(declaration.initializer) &&
68759
+ isMatchingReference(reference, declaration.initializer.expression)) {
68760
+ return declaration.initializer;
68761
+ }
68762
+ // Given 'const { kind: x } = obj', allow 'x' as an alias for 'obj.kind'
68763
+ if (ts.isBindingElement(declaration) && !declaration.initializer) {
68764
+ var parent = declaration.parent.parent;
68765
+ if (ts.isVariableDeclaration(parent) && !parent.type && parent.initializer && (ts.isIdentifier(parent.initializer) || ts.isAccessExpression(parent.initializer)) &&
68766
+ isMatchingReference(reference, parent.initializer)) {
68767
+ return declaration;
68768
+ }
68769
+ }
68770
+ }
68771
+ }
68772
+ return undefined;
68773
+ }
68708
68774
  function getDiscriminantPropertyAccess(expr, computedType) {
68709
- var access, name;
68710
68775
  var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType;
68711
- return type.flags & 1048576 /* Union */ && (access = getPropertyAccess(expr)) && (name = getAccessedPropertyName(access)) &&
68712
- isMatchingReference(reference, ts.isAccessExpression(access) ? access.expression : access.parent.parent.initializer) &&
68713
- isDiscriminantProperty(type, name) ?
68714
- access : undefined;
68776
+ if (type.flags & 1048576 /* Union */) {
68777
+ var access = getCandidateDiscriminantPropertyAccess(expr);
68778
+ if (access) {
68779
+ var name = getAccessedPropertyName(access);
68780
+ if (name && isDiscriminantProperty(type, name)) {
68781
+ return access;
68782
+ }
68783
+ }
68784
+ }
68785
+ return undefined;
68715
68786
  }
68716
68787
  function narrowTypeByDiscriminant(type, access, narrowType) {
68717
68788
  var propName = getAccessedPropertyName(access);
@@ -69469,6 +69540,49 @@ var ts;
69469
69540
  }
69470
69541
  }
69471
69542
  }
69543
+ function getNarrowedTypeOfSymbol(symbol, location) {
69544
+ // If we have a non-rest binding element with no initializer declared as a const variable or a const-like
69545
+ // parameter (a parameter for which there are no assignments in the function body), and if the parent type
69546
+ // for the destructuring is a union type, one or more of the binding elements may represent discriminant
69547
+ // properties, and we want the effects of conditional checks on such discriminants to affect the types of
69548
+ // other binding elements from the same destructuring. Consider:
69549
+ //
69550
+ // type Action =
69551
+ // | { kind: 'A', payload: number }
69552
+ // | { kind: 'B', payload: string };
69553
+ //
69554
+ // function f1({ kind, payload }: Action) {
69555
+ // if (kind === 'A') {
69556
+ // payload.toFixed();
69557
+ // }
69558
+ // if (kind === 'B') {
69559
+ // payload.toUpperCase();
69560
+ // }
69561
+ // }
69562
+ //
69563
+ // Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
69564
+ // the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
69565
+ // as if it occurred in the specified location. We then recompute the narrowed binding element type by
69566
+ // destructuring from the narrowed parent type.
69567
+ var declaration = symbol.valueDeclaration;
69568
+ if (declaration && ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
69569
+ var parent = declaration.parent.parent;
69570
+ if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
69571
+ var links = getNodeLinks(location);
69572
+ if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
69573
+ links.flags |= 268435456 /* InCheckIdentifier */;
69574
+ var parentType = getTypeForBindingElementParent(parent);
69575
+ links.flags &= ~268435456 /* InCheckIdentifier */;
69576
+ if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
69577
+ var pattern = declaration.parent;
69578
+ var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
69579
+ return getBindingElementTypeFromParentType(declaration, narrowedType);
69580
+ }
69581
+ }
69582
+ }
69583
+ }
69584
+ return getTypeOfSymbol(symbol);
69585
+ }
69472
69586
  function checkIdentifier(node, checkMode) {
69473
69587
  var symbol = getResolvedSymbol(node);
69474
69588
  if (symbol === unknownSymbol) {
@@ -69542,7 +69656,7 @@ var ts;
69542
69656
  }
69543
69657
  }
69544
69658
  checkNestedBlockScopedBinding(node, symbol);
69545
- var type = getTypeOfSymbol(localOrExportSymbol);
69659
+ var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
69546
69660
  var assignmentKind = ts.getAssignmentTargetKind(node);
69547
69661
  if (assignmentKind) {
69548
69662
  if (!(localOrExportSymbol.flags & 3 /* Variable */) &&
@@ -70585,13 +70699,13 @@ var ts;
70585
70699
  function isCircularMappedProperty(symbol) {
70586
70700
  return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
70587
70701
  }
70588
- function getTypeOfPropertyOfContextualType(type, name) {
70702
+ function getTypeOfPropertyOfContextualType(type, name, nameType) {
70589
70703
  return mapType(type, function (t) {
70590
70704
  var _a;
70591
70705
  if (isGenericMappedType(t)) {
70592
70706
  var constraint = getConstraintTypeFromMappedType(t);
70593
70707
  var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
70594
- var propertyNameType = getStringLiteralType(ts.unescapeLeadingUnderscores(name));
70708
+ var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
70595
70709
  if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
70596
70710
  return substituteIndexedMappedType(t, propertyNameType);
70597
70711
  }
@@ -70607,7 +70721,7 @@ var ts;
70607
70721
  return restType;
70608
70722
  }
70609
70723
  }
70610
- return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
70724
+ return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
70611
70725
  }
70612
70726
  return undefined;
70613
70727
  }, /*noReductions*/ true);
@@ -70635,7 +70749,8 @@ var ts;
70635
70749
  // For a (non-symbol) computed property, there is no reason to look up the name
70636
70750
  // in the type. It will just be "__computed", which does not appear in any
70637
70751
  // SymbolTable.
70638
- return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName);
70752
+ var symbol = getSymbolOfNode(element);
70753
+ return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
70639
70754
  }
70640
70755
  if (element.name) {
70641
70756
  var nameType_2 = getLiteralTypeFromPropertyName(element.name);
@@ -78346,7 +78461,9 @@ var ts;
78346
78461
  var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
78347
78462
  if (!typeReferenceNode)
78348
78463
  return undefined;
78349
- var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217
78464
+ var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
78465
+ if (!typeParameters)
78466
+ return undefined;
78350
78467
  var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
78351
78468
  return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
78352
78469
  }
@@ -82756,8 +82873,11 @@ var ts;
82756
82873
  function checkAssertClause(declaration) {
82757
82874
  var _a;
82758
82875
  if (declaration.assertClause) {
82759
- if (moduleKind !== ts.ModuleKind.ESNext) {
82760
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext);
82876
+ var mode = (moduleKind === ts.ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
82877
+ if (mode !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.ESNext) {
82878
+ return grammarErrorOnNode(declaration.assertClause, moduleKind === ts.ModuleKind.NodeNext
82879
+ ? ts.Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls
82880
+ : ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext);
82761
82881
  }
82762
82882
  if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
82763
82883
  return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports);
@@ -86604,12 +86724,12 @@ var ts;
86604
86724
  return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
86605
86725
  }
86606
86726
  var nodeArguments = node.arguments;
86607
- if (moduleKind !== ts.ModuleKind.ESNext) {
86727
+ if (moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.NodeNext) {
86608
86728
  // We are allowed trailing comma after proposal-import-assertions.
86609
86729
  checkGrammarForDisallowedTrailingComma(nodeArguments);
86610
86730
  if (nodeArguments.length > 1) {
86611
86731
  var assertionArgument = nodeArguments[1];
86612
- return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext);
86732
+ return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext);
86613
86733
  }
86614
86734
  }
86615
86735
  if (nodeArguments.length === 0 || nodeArguments.length > 2) {
@@ -93309,7 +93429,7 @@ var ts;
93309
93429
  return ts.visitEachChild(node, visitor, context);
93310
93430
  }
93311
93431
  function visitor(node) {
93312
- if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) {
93432
+ if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) {
93313
93433
  return node;
93314
93434
  }
93315
93435
  switch (node.kind) {
@@ -93942,7 +94062,7 @@ var ts;
93942
94062
  * expression of an `ExpressionStatement`).
93943
94063
  */
93944
94064
  function visitorWorker(node, expressionResultIsUnused) {
93945
- if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) {
94065
+ if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) {
93946
94066
  return node;
93947
94067
  }
93948
94068
  switch (node.kind) {
@@ -94639,7 +94759,7 @@ var ts;
94639
94759
  return ts.visitEachChild(node, visitor, context);
94640
94760
  }
94641
94761
  function visitor(node) {
94642
- if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) {
94762
+ if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) {
94643
94763
  return node;
94644
94764
  }
94645
94765
  switch (node.kind) {
@@ -94671,7 +94791,7 @@ var ts;
94671
94791
  return ts.visitEachChild(node, visitor, context);
94672
94792
  }
94673
94793
  function visitor(node) {
94674
- if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) {
94794
+ if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) {
94675
94795
  return node;
94676
94796
  }
94677
94797
  switch (node.kind) {
@@ -94848,7 +94968,7 @@ var ts;
94848
94968
  return ts.visitEachChild(node, visitor, context);
94849
94969
  }
94850
94970
  function visitor(node) {
94851
- if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) {
94971
+ if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) {
94852
94972
  return node;
94853
94973
  }
94854
94974
  switch (node.kind) {
@@ -95612,7 +95732,7 @@ var ts;
95612
95732
  return ts.visitEachChild(node, visitor, context);
95613
95733
  }
95614
95734
  function visitor(node) {
95615
- if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) {
95735
+ if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) {
95616
95736
  return node;
95617
95737
  }
95618
95738
  switch (node.kind) {
@@ -95860,7 +95980,7 @@ var ts;
95860
95980
  || ts.isBlock(node));
95861
95981
  }
95862
95982
  function shouldVisitNode(node) {
95863
- return (node.transformFlags & 512 /* ContainsES2015 */) !== 0
95983
+ return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0
95864
95984
  || convertedLoopState !== undefined
95865
95985
  || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node))
95866
95986
  || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node))
@@ -99173,7 +99293,7 @@ var ts;
99173
99293
  var withBlockStack; // A stack containing `with` blocks.
99174
99294
  return ts.chainBundle(context, transformSourceFile);
99175
99295
  function transformSourceFile(node) {
99176
- if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) {
99296
+ if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) {
99177
99297
  return node;
99178
99298
  }
99179
99299
  var visited = ts.visitEachChild(node, visitor, context);
@@ -99196,7 +99316,7 @@ var ts;
99196
99316
  else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
99197
99317
  return visitGenerator(node);
99198
99318
  }
99199
- else if (transformFlags & 1024 /* ContainsGenerator */) {
99319
+ else if (transformFlags & 2048 /* ContainsGenerator */) {
99200
99320
  return ts.visitEachChild(node, visitor, context);
99201
99321
  }
99202
99322
  else {
@@ -99252,7 +99372,7 @@ var ts;
99252
99372
  if (node.transformFlags & 524288 /* ContainsYield */) {
99253
99373
  return visitJavaScriptContainingYield(node);
99254
99374
  }
99255
- else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
99375
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
99256
99376
  return ts.visitEachChild(node, visitor, context);
99257
99377
  }
99258
99378
  else {
@@ -101901,7 +102021,7 @@ var ts;
101901
102021
  function visitorWorker(node, valueIsDiscarded) {
101902
102022
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
101903
102023
  // as export/import statements are only transformed at the top level of a file.
101904
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 2048 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
102024
+ if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
101905
102025
  return node;
101906
102026
  }
101907
102027
  switch (node.kind) {
@@ -104117,7 +104237,7 @@ var ts;
104117
104237
  * @param node The node to visit.
104118
104238
  */
104119
104239
  function visitorWorker(node, valueIsDiscarded) {
104120
- if (!(node.transformFlags & (2048 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
104240
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
104121
104241
  return node;
104122
104242
  }
104123
104243
  switch (node.kind) {
@@ -119342,13 +119462,15 @@ var ts;
119342
119462
  if (host.fileExists(packageJsonPath)) {
119343
119463
  var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119344
119464
  // TODO: Inject `require` or `import` condition based on the intended import mode
119345
- var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119346
- if (fromExports) {
119347
- var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119348
- return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119349
- }
119350
- if (packageJsonContent.exports) {
119351
- return { moduleFileToTry: path, blockedByExports: true };
119465
+ if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119466
+ var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined;
119467
+ if (fromExports) {
119468
+ var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
119469
+ return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
119470
+ }
119471
+ if (packageJsonContent.exports) {
119472
+ return { moduleFileToTry: path, blockedByExports: true };
119473
+ }
119352
119474
  }
119353
119475
  var versionPaths = packageJsonContent.typesVersions
119354
119476
  ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)