typescript 4.8.0-dev.20220602 → 4.8.0-dev.20220605

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.20220602";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220605";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5766,21 +5766,22 @@ var ts;
5766
5766
  TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5767
5767
  // Markers
5768
5768
  // - Flags used to indicate that a subtree contains a specific transformation.
5769
- TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
5770
- TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis";
5771
- TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread";
5772
- TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread";
5773
- TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName";
5774
- TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding";
5775
- TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern";
5776
- TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield";
5777
- TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait";
5778
- TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion";
5779
- TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport";
5780
- TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields";
5781
- TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait";
5782
- TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper";
5783
- TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier";
5769
+ TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
5770
+ TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
5771
+ TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
5772
+ TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
5773
+ TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
5774
+ TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
5775
+ TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
5776
+ TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
5777
+ TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
5778
+ TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
5779
+ TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
5780
+ TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
5781
+ TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
5782
+ TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5783
+ TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5784
+ TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5784
5785
  // Please leave this as 1 << 29.
5785
5786
  // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5786
5787
  // It is a good reminder of how much room we have left
@@ -5806,24 +5807,24 @@ var ts;
5806
5807
  TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5807
5808
  TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5808
5809
  TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5809
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes";
5810
- TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes";
5811
- TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes";
5812
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes";
5813
- TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes";
5814
- TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes";
5815
- TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes";
5810
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5811
+ TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5812
+ TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5813
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5814
+ TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5815
+ TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5816
+ TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5816
5817
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5817
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes";
5818
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes";
5819
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes";
5818
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5819
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5820
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5820
5821
  TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5821
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes";
5822
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes";
5823
- TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper";
5822
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5823
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5824
+ TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5824
5825
  // Propagating flags
5825
5826
  // - Bitmasks for flags that should propagate from a child
5826
- TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags";
5827
+ TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
5827
5828
  // Masks
5828
5829
  // - Additional bitmasks
5829
5830
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
@@ -8396,6 +8397,7 @@ var ts;
8396
8397
  Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
8397
8398
  Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."),
8398
8399
  _0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module: diag(1208, ts.DiagnosticCategory.Error, "_0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_imp_1208", "'{0}' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module."),
8400
+ Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0: diag(1209, ts.DiagnosticCategory.Error, "Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0_1209", "Invalid optional chain from new expression. Did you mean to call '{0}()'?"),
8399
8401
  Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of_0_For_more_information_see_https_Colon_Slash_Slashdeveloper_mozilla_org_Slashen_US_Slashdocs_SlashWeb_SlashJavaScript_SlashReference_SlashStrict_mode: diag(1210, ts.DiagnosticCategory.Error, "Code_contained_in_a_class_is_evaluated_in_JavaScript_s_strict_mode_which_does_not_allow_this_use_of__1210", "Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode."),
8400
8402
  A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."),
8401
8403
  Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."),
@@ -8592,7 +8594,7 @@ var ts;
8592
8594
  Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."),
8593
8595
  Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
8594
8596
  Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
8595
- Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "Resolution modes are only supported when `moduleResolution` is `node16` or `nodenext`."),
8597
+ resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext: diag(1452, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext_1452", "'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`."),
8596
8598
  resolution_mode_should_be_either_require_or_import: diag(1453, ts.DiagnosticCategory.Error, "resolution_mode_should_be_either_require_or_import_1453", "`resolution-mode` should be either `require` or `import`."),
8597
8599
  resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."),
8598
8600
  resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
@@ -9100,6 +9102,7 @@ var ts;
9100
9102
  All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
9101
9103
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
9102
9104
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
9105
+ The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9103
9106
  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}'."),
9104
9107
  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}'."),
9105
9108
  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}'."),
@@ -9207,7 +9210,7 @@ var ts;
9207
9210
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
9208
9211
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
9209
9212
  Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9210
- Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9213
+ resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "'resolution-mode' assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9211
9214
  The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
9212
9215
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
9213
9216
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -16248,6 +16251,8 @@ var ts;
16248
16251
  case 218 /* AwaitExpression */:
16249
16252
  case 231 /* MetaProperty */:
16250
16253
  return true;
16254
+ case 228 /* ExpressionWithTypeArguments */:
16255
+ return !ts.isHeritageClause(node.parent);
16251
16256
  case 161 /* QualifiedName */:
16252
16257
  while (node.parent.kind === 161 /* QualifiedName */) {
16253
16258
  node = node.parent;
@@ -17191,6 +17196,12 @@ var ts;
17191
17196
  return [child, node];
17192
17197
  }
17193
17198
  ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
17199
+ function skipTypeParentheses(node) {
17200
+ while (ts.isParenthesizedTypeNode(node))
17201
+ node = node.type;
17202
+ return node;
17203
+ }
17204
+ ts.skipTypeParentheses = skipTypeParentheses;
17194
17205
  function skipParentheses(node, excludeJSDocTypeAssertions) {
17195
17206
  var flags = excludeJSDocTypeAssertions ?
17196
17207
  1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
@@ -19425,7 +19436,7 @@ var ts;
19425
19436
  * Moves the start position of a range past any decorators.
19426
19437
  */
19427
19438
  function moveRangePastDecorators(node) {
19428
- return node.decorators && node.decorators.length > 0
19439
+ return node.decorators && !positionIsSynthesized(node.decorators.end)
19429
19440
  ? moveRangePos(node, node.decorators.end)
19430
19441
  : node;
19431
19442
  }
@@ -19434,7 +19445,7 @@ var ts;
19434
19445
  * Moves the start position of a range past any decorators or modifiers.
19435
19446
  */
19436
19447
  function moveRangePastModifiers(node) {
19437
- return node.modifiers && node.modifiers.length > 0
19448
+ return node.modifiers && !positionIsSynthesized(node.modifiers.end)
19438
19449
  ? moveRangePos(node, node.modifiers.end)
19439
19450
  : moveRangePastDecorators(node);
19440
19451
  }
@@ -22864,7 +22875,7 @@ var ts;
22864
22875
  function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
22865
22876
  var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
22866
22877
  node.body = body;
22867
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
22878
+ node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
22868
22879
  if (!body)
22869
22880
  node.transformFlags |= 1 /* ContainsTypeScript */;
22870
22881
  return node;
@@ -22992,7 +23003,7 @@ var ts;
22992
23003
  node.typeArguments = createNodeArray(typeArguments);
22993
23004
  }
22994
23005
  if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
22995
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
23006
+ node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
22996
23007
  }
22997
23008
  return node;
22998
23009
  }
@@ -23044,7 +23055,7 @@ var ts;
23044
23055
  ts.Debug.fail("First character of private identifier must be #: " + text);
23045
23056
  var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
23046
23057
  node.escapedText = ts.escapeLeadingUnderscores(text);
23047
- node.transformFlags |= 8388608 /* ContainsClassFields */;
23058
+ node.transformFlags |= 16777216 /* ContainsClassFields */;
23048
23059
  return node;
23049
23060
  }
23050
23061
  //
@@ -23091,14 +23102,14 @@ var ts;
23091
23102
  transformFlags = 1 /* ContainsTypeScript */;
23092
23103
  break;
23093
23104
  case 106 /* SuperKeyword */:
23094
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
23105
+ transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
23095
23106
  break;
23096
23107
  case 124 /* StaticKeyword */:
23097
23108
  transformFlags = 1024 /* ContainsES2015 */;
23098
23109
  break;
23099
23110
  case 108 /* ThisKeyword */:
23100
23111
  // 'this' indicates a lexical 'this'
23101
- transformFlags = 8192 /* ContainsLexicalThis */;
23112
+ transformFlags = 16384 /* ContainsLexicalThis */;
23102
23113
  break;
23103
23114
  }
23104
23115
  if (transformFlags) {
@@ -23196,7 +23207,7 @@ var ts;
23196
23207
  node.transformFlags |=
23197
23208
  propagateChildFlags(node.expression) |
23198
23209
  1024 /* ContainsES2015 */ |
23199
- 65536 /* ContainsComputedPropertyName */;
23210
+ 131072 /* ContainsComputedPropertyName */;
23200
23211
  return node;
23201
23212
  }
23202
23213
  // @api
@@ -23262,7 +23273,7 @@ var ts;
23262
23273
  if (questionToken)
23263
23274
  node.transformFlags |= 1 /* ContainsTypeScript */;
23264
23275
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
23265
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23276
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23266
23277
  if (initializer || dotDotDotToken)
23267
23278
  node.transformFlags |= 1024 /* ContainsES2015 */;
23268
23279
  }
@@ -23287,7 +23298,8 @@ var ts;
23287
23298
  node.transformFlags |=
23288
23299
  propagateChildFlags(node.expression) |
23289
23300
  1 /* ContainsTypeScript */ |
23290
- 4096 /* ContainsTypeScriptClassSyntax */;
23301
+ 8192 /* ContainsTypeScriptClassSyntax */ |
23302
+ 33554432 /* ContainsDecorators */;
23291
23303
  return node;
23292
23304
  }
23293
23305
  // @api
@@ -23325,9 +23337,9 @@ var ts;
23325
23337
  node.transformFlags |=
23326
23338
  propagateChildFlags(node.questionToken) |
23327
23339
  propagateChildFlags(node.exclamationToken) |
23328
- 8388608 /* ContainsClassFields */;
23340
+ 16777216 /* ContainsClassFields */;
23329
23341
  if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
23330
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23342
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23331
23343
  }
23332
23344
  if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
23333
23345
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -23410,7 +23422,7 @@ var ts;
23410
23422
  /*name*/ undefined,
23411
23423
  /*typeParameters*/ undefined);
23412
23424
  node.body = body;
23413
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
23425
+ node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
23414
23426
  return node;
23415
23427
  }
23416
23428
  // @api
@@ -23934,11 +23946,11 @@ var ts;
23934
23946
  node.transformFlags |=
23935
23947
  propagateChildrenFlags(node.elements) |
23936
23948
  1024 /* ContainsES2015 */ |
23937
- 262144 /* ContainsBindingPattern */;
23938
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
23949
+ 524288 /* ContainsBindingPattern */;
23950
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
23939
23951
  node.transformFlags |=
23940
23952
  128 /* ContainsES2018 */ |
23941
- 32768 /* ContainsObjectRestOrSpread */;
23953
+ 65536 /* ContainsObjectRestOrSpread */;
23942
23954
  }
23943
23955
  return node;
23944
23956
  }
@@ -23955,7 +23967,7 @@ var ts;
23955
23967
  node.transformFlags |=
23956
23968
  propagateChildrenFlags(node.elements) |
23957
23969
  1024 /* ContainsES2015 */ |
23958
- 262144 /* ContainsBindingPattern */;
23970
+ 524288 /* ContainsBindingPattern */;
23959
23971
  return node;
23960
23972
  }
23961
23973
  // @api
@@ -23980,7 +23992,7 @@ var ts;
23980
23992
  propagateChildFlags(node.propertyName);
23981
23993
  }
23982
23994
  if (dotDotDotToken)
23983
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
23995
+ node.transformFlags |= 32768 /* ContainsRestOrSpread */;
23984
23996
  return node;
23985
23997
  }
23986
23998
  // @api
@@ -24155,10 +24167,10 @@ var ts;
24155
24167
  node.transformFlags |= 1 /* ContainsTypeScript */;
24156
24168
  }
24157
24169
  if (ts.isImportKeyword(node.expression)) {
24158
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
24170
+ node.transformFlags |= 8388608 /* ContainsDynamicImport */;
24159
24171
  }
24160
24172
  else if (ts.isSuperProperty(node.expression)) {
24161
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24173
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24162
24174
  }
24163
24175
  return node;
24164
24176
  }
@@ -24191,7 +24203,7 @@ var ts;
24191
24203
  node.transformFlags |= 1 /* ContainsTypeScript */;
24192
24204
  }
24193
24205
  if (ts.isSuperProperty(node.expression)) {
24194
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24206
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24195
24207
  }
24196
24208
  return node;
24197
24209
  }
@@ -24331,7 +24343,7 @@ var ts;
24331
24343
  propagateChildFlags(node.equalsGreaterThanToken) |
24332
24344
  1024 /* ContainsES2015 */;
24333
24345
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24334
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
24346
+ node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
24335
24347
  }
24336
24348
  return node;
24337
24349
  }
@@ -24393,7 +24405,7 @@ var ts;
24393
24405
  propagateChildFlags(node.expression) |
24394
24406
  256 /* ContainsES2017 */ |
24395
24407
  128 /* ContainsES2018 */ |
24396
- 1048576 /* ContainsAwait */;
24408
+ 2097152 /* ContainsAwait */;
24397
24409
  return node;
24398
24410
  }
24399
24411
  // @api
@@ -24414,7 +24426,7 @@ var ts;
24414
24426
  ts.isIdentifier(node.operand) &&
24415
24427
  !ts.isGeneratedIdentifier(node.operand) &&
24416
24428
  !ts.isLocalName(node.operand)) {
24417
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24429
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24418
24430
  }
24419
24431
  return node;
24420
24432
  }
@@ -24435,7 +24447,7 @@ var ts;
24435
24447
  if (ts.isIdentifier(node.operand) &&
24436
24448
  !ts.isGeneratedIdentifier(node.operand) &&
24437
24449
  !ts.isLocalName(node.operand)) {
24438
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24450
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24439
24451
  }
24440
24452
  return node;
24441
24453
  }
@@ -24484,8 +24496,8 @@ var ts;
24484
24496
  return node;
24485
24497
  }
24486
24498
  function propagateAssignmentPatternFlags(node) {
24487
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
24488
- return 32768 /* ContainsObjectRestOrSpread */;
24499
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
24500
+ return 65536 /* ContainsObjectRestOrSpread */;
24489
24501
  if (node.transformFlags & 128 /* ContainsES2018 */) {
24490
24502
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
24491
24503
  // will not be correctly interpreted by the ES2018 transformer
@@ -24493,8 +24505,8 @@ var ts;
24493
24505
  var element = _a[_i];
24494
24506
  var target = ts.getTargetOfBindingOrAssignmentElement(element);
24495
24507
  if (target && ts.isAssignmentPattern(target)) {
24496
- if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
24497
- return 32768 /* ContainsObjectRestOrSpread */;
24508
+ if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
24509
+ return 65536 /* ContainsObjectRestOrSpread */;
24498
24510
  }
24499
24511
  if (target.transformFlags & 128 /* ContainsES2018 */) {
24500
24512
  var flags_1 = propagateAssignmentPatternFlags(target);
@@ -24620,7 +24632,7 @@ var ts;
24620
24632
  propagateChildFlags(node.asteriskToken) |
24621
24633
  1024 /* ContainsES2015 */ |
24622
24634
  128 /* ContainsES2018 */ |
24623
- 524288 /* ContainsYield */;
24635
+ 1048576 /* ContainsYield */;
24624
24636
  return node;
24625
24637
  }
24626
24638
  // @api
@@ -24637,7 +24649,7 @@ var ts;
24637
24649
  node.transformFlags |=
24638
24650
  propagateChildFlags(node.expression) |
24639
24651
  1024 /* ContainsES2015 */ |
24640
- 16384 /* ContainsRestOrSpread */;
24652
+ 32768 /* ContainsRestOrSpread */;
24641
24653
  return node;
24642
24654
  }
24643
24655
  // @api
@@ -24970,7 +24982,7 @@ var ts;
24970
24982
  node.label = asName(label);
24971
24983
  node.transformFlags |=
24972
24984
  propagateChildFlags(node.label) |
24973
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24985
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24974
24986
  return node;
24975
24987
  }
24976
24988
  // @api
@@ -24985,7 +24997,7 @@ var ts;
24985
24997
  node.label = asName(label);
24986
24998
  node.transformFlags |=
24987
24999
  propagateChildFlags(node.label) |
24988
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25000
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24989
25001
  return node;
24990
25002
  }
24991
25003
  // @api
@@ -25002,7 +25014,7 @@ var ts;
25002
25014
  node.transformFlags |=
25003
25015
  propagateChildFlags(node.expression) |
25004
25016
  128 /* ContainsES2018 */ |
25005
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25017
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25006
25018
  return node;
25007
25019
  }
25008
25020
  // @api
@@ -25128,11 +25140,11 @@ var ts;
25128
25140
  node.declarations = createNodeArray(declarations);
25129
25141
  node.transformFlags |=
25130
25142
  propagateChildrenFlags(node.declarations) |
25131
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25143
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25132
25144
  if (flags & 3 /* BlockScoped */) {
25133
25145
  node.transformFlags |=
25134
25146
  1024 /* ContainsES2015 */ |
25135
- 131072 /* ContainsBlockScopedBinding */;
25147
+ 262144 /* ContainsBlockScopedBinding */;
25136
25148
  }
25137
25149
  return node;
25138
25150
  }
@@ -25152,7 +25164,7 @@ var ts;
25152
25164
  else {
25153
25165
  node.transformFlags |=
25154
25166
  propagateChildFlags(node.asteriskToken) |
25155
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
25167
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
25156
25168
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
25157
25169
  if (node.asteriskToken) {
25158
25170
  node.transformFlags |= 128 /* ContainsES2018 */;
@@ -25188,7 +25200,7 @@ var ts;
25188
25200
  }
25189
25201
  else {
25190
25202
  node.transformFlags |= 1024 /* ContainsES2015 */;
25191
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
25203
+ if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
25192
25204
  node.transformFlags |= 1 /* ContainsTypeScript */;
25193
25205
  }
25194
25206
  }
@@ -25247,7 +25259,7 @@ var ts;
25247
25259
  node.transformFlags |=
25248
25260
  propagateChildrenFlags(node.members) |
25249
25261
  1 /* ContainsTypeScript */;
25250
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25262
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25251
25263
  return node;
25252
25264
  }
25253
25265
  // @api
@@ -25275,7 +25287,7 @@ var ts;
25275
25287
  propagateChildFlags(node.body) |
25276
25288
  1 /* ContainsTypeScript */;
25277
25289
  }
25278
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25290
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25279
25291
  return node;
25280
25292
  }
25281
25293
  // @api
@@ -25335,7 +25347,7 @@ var ts;
25335
25347
  node.transformFlags |= propagateChildFlags(node.moduleReference);
25336
25348
  if (!ts.isExternalModuleReference(node.moduleReference))
25337
25349
  node.transformFlags |= 1 /* ContainsTypeScript */;
25338
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25350
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25339
25351
  return node;
25340
25352
  }
25341
25353
  // @api
@@ -25357,7 +25369,7 @@ var ts;
25357
25369
  node.transformFlags |=
25358
25370
  propagateChildFlags(node.importClause) |
25359
25371
  propagateChildFlags(node.moduleSpecifier);
25360
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25372
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25361
25373
  return node;
25362
25374
  }
25363
25375
  // @api
@@ -25382,7 +25394,7 @@ var ts;
25382
25394
  if (isTypeOnly) {
25383
25395
  node.transformFlags |= 1 /* ContainsTypeScript */;
25384
25396
  }
25385
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25397
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25386
25398
  return node;
25387
25399
  }
25388
25400
  // @api
@@ -25442,7 +25454,7 @@ var ts;
25442
25454
  var node = createBaseNode(268 /* NamespaceImport */);
25443
25455
  node.name = name;
25444
25456
  node.transformFlags |= propagateChildFlags(node.name);
25445
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25457
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25446
25458
  return node;
25447
25459
  }
25448
25460
  // @api
@@ -25458,7 +25470,7 @@ var ts;
25458
25470
  node.transformFlags |=
25459
25471
  propagateChildFlags(node.name) |
25460
25472
  4 /* ContainsESNext */;
25461
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25473
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25462
25474
  return node;
25463
25475
  }
25464
25476
  // @api
@@ -25472,7 +25484,7 @@ var ts;
25472
25484
  var node = createBaseNode(269 /* NamedImports */);
25473
25485
  node.elements = createNodeArray(elements);
25474
25486
  node.transformFlags |= propagateChildrenFlags(node.elements);
25475
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25487
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25476
25488
  return node;
25477
25489
  }
25478
25490
  // @api
@@ -25490,7 +25502,7 @@ var ts;
25490
25502
  node.transformFlags |=
25491
25503
  propagateChildFlags(node.propertyName) |
25492
25504
  propagateChildFlags(node.name);
25493
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25505
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25494
25506
  return node;
25495
25507
  }
25496
25508
  // @api
@@ -25509,7 +25521,7 @@ var ts;
25509
25521
  ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
25510
25522
  : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
25511
25523
  node.transformFlags |= propagateChildFlags(node.expression);
25512
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25524
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25513
25525
  return node;
25514
25526
  }
25515
25527
  // @api
@@ -25530,7 +25542,7 @@ var ts;
25530
25542
  node.transformFlags |=
25531
25543
  propagateChildFlags(node.exportClause) |
25532
25544
  propagateChildFlags(node.moduleSpecifier);
25533
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25545
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25534
25546
  return node;
25535
25547
  }
25536
25548
  // @api
@@ -25549,7 +25561,7 @@ var ts;
25549
25561
  var node = createBaseNode(273 /* NamedExports */);
25550
25562
  node.elements = createNodeArray(elements);
25551
25563
  node.transformFlags |= propagateChildrenFlags(node.elements);
25552
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25564
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25553
25565
  return node;
25554
25566
  }
25555
25567
  // @api
@@ -25567,7 +25579,7 @@ var ts;
25567
25579
  node.transformFlags |=
25568
25580
  propagateChildFlags(node.propertyName) |
25569
25581
  propagateChildFlags(node.name);
25570
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25582
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25571
25583
  return node;
25572
25584
  }
25573
25585
  // @api
@@ -25593,7 +25605,7 @@ var ts;
25593
25605
  var node = createBaseNode(277 /* ExternalModuleReference */);
25594
25606
  node.expression = expression;
25595
25607
  node.transformFlags |= propagateChildFlags(node.expression);
25596
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25608
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25597
25609
  return node;
25598
25610
  }
25599
25611
  // @api
@@ -26367,7 +26379,7 @@ var ts;
26367
26379
  node.transformFlags |=
26368
26380
  propagateChildFlags(node.expression) |
26369
26381
  128 /* ContainsES2018 */ |
26370
- 32768 /* ContainsObjectRestOrSpread */;
26382
+ 65536 /* ContainsObjectRestOrSpread */;
26371
26383
  return node;
26372
26384
  }
26373
26385
  // @api
@@ -27324,10 +27336,10 @@ var ts;
27324
27336
  }
27325
27337
  function propagateIdentifierNameFlags(node) {
27326
27338
  // An IdentifierName is allowed to be `await`
27327
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
27339
+ return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
27328
27340
  }
27329
27341
  function propagatePropertyNameFlagsOfChild(node, transformFlags) {
27330
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
27342
+ return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
27331
27343
  }
27332
27344
  function propagateChildFlags(child) {
27333
27345
  if (!child)
@@ -27358,29 +27370,29 @@ var ts;
27358
27370
  case 208 /* CallExpression */:
27359
27371
  case 209 /* NewExpression */:
27360
27372
  case 204 /* ArrayLiteralExpression */:
27361
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
27373
+ return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27362
27374
  case 261 /* ModuleDeclaration */:
27363
- return 589443072 /* ModuleExcludes */;
27375
+ return 742678528 /* ModuleExcludes */;
27364
27376
  case 164 /* Parameter */:
27365
27377
  return 536870912 /* ParameterExcludes */;
27366
27378
  case 214 /* ArrowFunction */:
27367
- return 557748224 /* ArrowFunctionExcludes */;
27379
+ return 612179968 /* ArrowFunctionExcludes */;
27368
27380
  case 213 /* FunctionExpression */:
27369
27381
  case 256 /* FunctionDeclaration */:
27370
- return 591310848 /* FunctionExcludes */;
27382
+ return 746414080 /* FunctionExcludes */;
27371
27383
  case 255 /* VariableDeclarationList */:
27372
- return 537165824 /* VariableDeclarationListExcludes */;
27384
+ return 537460736 /* VariableDeclarationListExcludes */;
27373
27385
  case 257 /* ClassDeclaration */:
27374
27386
  case 226 /* ClassExpression */:
27375
- return 536940544 /* ClassExcludes */;
27387
+ return 537010176 /* ClassExcludes */;
27376
27388
  case 171 /* Constructor */:
27377
- return 591306752 /* ConstructorExcludes */;
27389
+ return 746405888 /* ConstructorExcludes */;
27378
27390
  case 167 /* PropertyDeclaration */:
27379
- return 570433536 /* PropertyExcludes */;
27391
+ return 671105024 /* PropertyExcludes */;
27380
27392
  case 169 /* MethodDeclaration */:
27381
27393
  case 172 /* GetAccessor */:
27382
27394
  case 173 /* SetAccessor */:
27383
- return 574529536 /* MethodOrAccessorExcludes */;
27395
+ return 679297024 /* MethodOrAccessorExcludes */;
27384
27396
  case 130 /* AnyKeyword */:
27385
27397
  case 147 /* NumberKeyword */:
27386
27398
  case 158 /* BigIntKeyword */:
@@ -27400,12 +27412,12 @@ var ts;
27400
27412
  case 259 /* TypeAliasDeclaration */:
27401
27413
  return -2 /* TypeExcludes */;
27402
27414
  case 205 /* ObjectLiteralExpression */:
27403
- return 536973312 /* ObjectLiteralExcludes */;
27415
+ return 537075712 /* ObjectLiteralExcludes */;
27404
27416
  case 292 /* CatchClause */:
27405
- return 536903680 /* CatchClauseExcludes */;
27417
+ return 536936448 /* CatchClauseExcludes */;
27406
27418
  case 201 /* ObjectBindingPattern */:
27407
27419
  case 202 /* ArrayBindingPattern */:
27408
- return 536887296 /* BindingPatternExcludes */;
27420
+ return 536903680 /* BindingPatternExcludes */;
27409
27421
  case 211 /* TypeAssertionExpression */:
27410
27422
  case 229 /* AsExpression */:
27411
27423
  case 350 /* PartiallyEmittedExpression */:
@@ -29281,6 +29293,10 @@ var ts;
29281
29293
  return node.kind === 267 /* ImportClause */;
29282
29294
  }
29283
29295
  ts.isImportClause = isImportClause;
29296
+ function isImportTypeAssertionContainer(node) {
29297
+ return node.kind === 295 /* ImportTypeAssertionContainer */;
29298
+ }
29299
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29284
29300
  function isAssertClause(node) {
29285
29301
  return node.kind === 293 /* AssertClause */;
29286
29302
  }
@@ -30635,6 +30651,14 @@ var ts;
30635
30651
  }
30636
30652
  }
30637
30653
  ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
30654
+ function elideNodes(factory, nodes) {
30655
+ if (nodes === undefined)
30656
+ return undefined;
30657
+ if (nodes.length === 0)
30658
+ return nodes;
30659
+ return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
30660
+ }
30661
+ ts.elideNodes = elideNodes;
30638
30662
  })(ts || (ts = {}));
30639
30663
  var ts;
30640
30664
  (function (ts) {
@@ -31806,7 +31830,7 @@ var ts;
31806
31830
  return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
31807
31831
  function containsPossibleTopLevelAwait(node) {
31808
31832
  return !(node.flags & 32768 /* AwaitContext */)
31809
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
31833
+ && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
31810
31834
  }
31811
31835
  function findNextStatementWithAwait(statements, start) {
31812
31836
  for (var i = start; i < statements.length; i++) {
@@ -31847,7 +31871,7 @@ var ts;
31847
31871
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31848
31872
  setFields(sourceFile);
31849
31873
  // If we parsed this as an external module, it may contain top-level await
31850
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31874
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
31851
31875
  sourceFile = reparseTopLevelAwait(sourceFile);
31852
31876
  setFields(sourceFile);
31853
31877
  }
@@ -35853,6 +35877,9 @@ var ts;
35853
35877
  typeArguments = expression.typeArguments;
35854
35878
  expression = expression.expression;
35855
35879
  }
35880
+ if (token() === 28 /* QuestionDotToken */) {
35881
+ parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression));
35882
+ }
35856
35883
  var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35857
35884
  return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35858
35885
  }
@@ -44044,13 +44071,36 @@ var ts;
44044
44071
  }
44045
44072
  return toSearchResult(/*value*/ undefined);
44046
44073
  }
44074
+ /**
44075
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44076
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44077
+ */
44078
+ function comparePatternKeys(a, b) {
44079
+ var aPatternIndex = a.indexOf("*");
44080
+ var bPatternIndex = b.indexOf("*");
44081
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
44082
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
44083
+ if (baseLenA > baseLenB)
44084
+ return -1;
44085
+ if (baseLenB > baseLenA)
44086
+ return 1;
44087
+ if (aPatternIndex === -1)
44088
+ return 1;
44089
+ if (bPatternIndex === -1)
44090
+ return -1;
44091
+ if (a.length > b.length)
44092
+ return -1;
44093
+ if (b.length > a.length)
44094
+ return 1;
44095
+ return 0;
44096
+ }
44047
44097
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44048
44098
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44049
44099
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
44050
44100
  var target = lookupTable[moduleName];
44051
44101
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
44052
44102
  }
44053
- var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), function (a, b) { return a.length - b.length; });
44103
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
44054
44104
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
44055
44105
  var potentialTarget = expandingKeys_1[_i];
44056
44106
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -53629,6 +53679,7 @@ var ts;
53629
53679
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53630
53680
  }
53631
53681
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53682
+ var _a, _b, _c, _d;
53632
53683
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53633
53684
  var isTypeOf = meaning === 111551 /* Value */;
53634
53685
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53646,6 +53697,7 @@ var ts;
53646
53697
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53647
53698
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53648
53699
  ])));
53700
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53649
53701
  }
53650
53702
  }
53651
53703
  if (!specifier) {
@@ -53665,6 +53717,7 @@ var ts;
53665
53717
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53666
53718
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53667
53719
  ])));
53720
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53668
53721
  }
53669
53722
  }
53670
53723
  if (!assertion) {
@@ -81074,8 +81127,11 @@ var ts;
81074
81127
  if (node.assertions) {
81075
81128
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
81076
81129
  if (override) {
81130
+ if (!ts.isNightly()) {
81131
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
81132
+ }
81077
81133
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
81078
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81134
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
81079
81135
  }
81080
81136
  }
81081
81137
  }
@@ -85481,10 +85537,10 @@ var ts;
85481
85537
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85482
85538
  if (validForTypeAssertions && override) {
85483
85539
  if (!ts.isNightly()) {
85484
- grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
85540
+ grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
85485
85541
  }
85486
85542
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85487
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85543
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85488
85544
  }
85489
85545
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85490
85546
  }
@@ -91213,6 +91269,124 @@ var ts;
91213
91269
  return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
91214
91270
  }
91215
91271
  ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
91272
+ /**
91273
+ * Gets an array of arrays of decorators for the parameters of a function-like node.
91274
+ * The offset into the result array should correspond to the offset of the parameter.
91275
+ *
91276
+ * @param node The function-like node.
91277
+ */
91278
+ function getDecoratorsOfParameters(node) {
91279
+ var decorators;
91280
+ if (node) {
91281
+ var parameters = node.parameters;
91282
+ var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
91283
+ var firstParameterOffset = firstParameterIsThis ? 1 : 0;
91284
+ var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
91285
+ for (var i = 0; i < numParameters; i++) {
91286
+ var parameter = parameters[i + firstParameterOffset];
91287
+ if (decorators || parameter.decorators) {
91288
+ if (!decorators) {
91289
+ decorators = new Array(numParameters);
91290
+ }
91291
+ decorators[i] = parameter.decorators;
91292
+ }
91293
+ }
91294
+ }
91295
+ return decorators;
91296
+ }
91297
+ /**
91298
+ * Gets an AllDecorators object containing the decorators for the class and the decorators for the
91299
+ * parameters of the constructor of the class.
91300
+ *
91301
+ * @param node The class node.
91302
+ */
91303
+ function getAllDecoratorsOfClass(node) {
91304
+ var decorators = node.decorators;
91305
+ var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
91306
+ if (!decorators && !parameters) {
91307
+ return undefined;
91308
+ }
91309
+ return {
91310
+ decorators: decorators,
91311
+ parameters: parameters
91312
+ };
91313
+ }
91314
+ ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
91315
+ /**
91316
+ * Gets an AllDecorators object containing the decorators for the member and its parameters.
91317
+ *
91318
+ * @param parent The class node that contains the member.
91319
+ * @param member The class member.
91320
+ */
91321
+ function getAllDecoratorsOfClassElement(member, parent) {
91322
+ switch (member.kind) {
91323
+ case 172 /* GetAccessor */:
91324
+ case 173 /* SetAccessor */:
91325
+ return getAllDecoratorsOfAccessors(member, parent);
91326
+ case 169 /* MethodDeclaration */:
91327
+ return getAllDecoratorsOfMethod(member);
91328
+ case 167 /* PropertyDeclaration */:
91329
+ return getAllDecoratorsOfProperty(member);
91330
+ default:
91331
+ return undefined;
91332
+ }
91333
+ }
91334
+ ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
91335
+ /**
91336
+ * Gets an AllDecorators object containing the decorators for the accessor and its parameters.
91337
+ *
91338
+ * @param parent The class node that contains the accessor.
91339
+ * @param accessor The class accessor member.
91340
+ */
91341
+ function getAllDecoratorsOfAccessors(accessor, parent) {
91342
+ if (!accessor.body) {
91343
+ return undefined;
91344
+ }
91345
+ var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
91346
+ var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
91347
+ if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
91348
+ return undefined;
91349
+ }
91350
+ var decorators = firstAccessorWithDecorators.decorators;
91351
+ var parameters = getDecoratorsOfParameters(setAccessor);
91352
+ if (!decorators && !parameters) {
91353
+ return undefined;
91354
+ }
91355
+ return {
91356
+ decorators: decorators,
91357
+ parameters: parameters,
91358
+ getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
91359
+ setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
91360
+ };
91361
+ }
91362
+ /**
91363
+ * Gets an AllDecorators object containing the decorators for the method and its parameters.
91364
+ *
91365
+ * @param method The class method member.
91366
+ */
91367
+ function getAllDecoratorsOfMethod(method) {
91368
+ if (!method.body) {
91369
+ return undefined;
91370
+ }
91371
+ var decorators = method.decorators;
91372
+ var parameters = getDecoratorsOfParameters(method);
91373
+ if (!decorators && !parameters) {
91374
+ return undefined;
91375
+ }
91376
+ return { decorators: decorators, parameters: parameters };
91377
+ }
91378
+ /**
91379
+ * Gets an AllDecorators object containing the decorators for the property.
91380
+ *
91381
+ * @param property The class property member.
91382
+ */
91383
+ function getAllDecoratorsOfProperty(property) {
91384
+ var decorators = property.decorators;
91385
+ if (!decorators) {
91386
+ return undefined;
91387
+ }
91388
+ return { decorators: decorators };
91389
+ }
91216
91390
  })(ts || (ts = {}));
91217
91391
  /*@internal*/
91218
91392
  var ts;
@@ -91486,8 +91660,8 @@ var ts;
91486
91660
  if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
91487
91661
  var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
91488
91662
  if (flattenContext.level >= 1 /* ObjectRest */
91489
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91490
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91663
+ && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91664
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91491
91665
  && !ts.isComputedPropertyName(propertyName)) {
91492
91666
  bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
91493
91667
  }
@@ -91553,7 +91727,7 @@ var ts;
91553
91727
  if (flattenContext.level >= 1 /* ObjectRest */) {
91554
91728
  // If an array pattern contains an ObjectRest, we must cache the result so that we
91555
91729
  // can perform the ObjectRest destructuring in a different declaration
91556
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91730
+ if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91557
91731
  flattenContext.hasTransformedPriorElement = true;
91558
91732
  var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
91559
91733
  if (flattenContext.hoistTempVariables) {
@@ -91775,8 +91949,6 @@ var ts;
91775
91949
  var USE_NEW_TYPE_METADATA_FORMAT = false;
91776
91950
  var TypeScriptSubstitutionFlags;
91777
91951
  (function (TypeScriptSubstitutionFlags) {
91778
- /** Enables substitutions for decorated classes. */
91779
- TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
91780
91952
  /** Enables substitutions for namespace exports. */
91781
91953
  TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
91782
91954
  /* Enables substitutions for unqualified enum members */
@@ -91802,9 +91974,9 @@ var ts;
91802
91974
  var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
91803
91975
  var resolver = context.getEmitResolver();
91804
91976
  var compilerOptions = context.getCompilerOptions();
91805
- var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
91806
91977
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
91807
91978
  var moduleKind = ts.getEmitModuleKind(compilerOptions);
91979
+ var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
91808
91980
  // Save the previous transformation hooks.
91809
91981
  var previousOnEmitNode = context.onEmitNode;
91810
91982
  var previousOnSubstituteNode = context.onSubstituteNode;
@@ -91819,7 +91991,6 @@ var ts;
91819
91991
  var currentNamespace;
91820
91992
  var currentNamespaceContainerName;
91821
91993
  var currentLexicalScope;
91822
- var currentNameScope;
91823
91994
  var currentScopeFirstDeclarationsOfName;
91824
91995
  var currentClassHasParameterProperties;
91825
91996
  /**
@@ -91827,11 +91998,6 @@ var ts;
91827
91998
  * They are persisted between each SourceFile transformation and should not be reset.
91828
91999
  */
91829
92000
  var enabledSubstitutions;
91830
- /**
91831
- * A map that keeps track of aliases created for classes with decorators to avoid issues
91832
- * with the double-binding behavior of classes.
91833
- */
91834
- var classAliases;
91835
92001
  /**
91836
92002
  * Keeps track of whether we are within any containing namespaces when performing
91837
92003
  * just-in-time substitution while printing an expression identifier.
@@ -91875,7 +92041,6 @@ var ts;
91875
92041
  function saveStateAndInvoke(node, f) {
91876
92042
  // Save state
91877
92043
  var savedCurrentScope = currentLexicalScope;
91878
- var savedCurrentNameScope = currentNameScope;
91879
92044
  var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
91880
92045
  var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
91881
92046
  // Handle state changes before visiting a node.
@@ -91886,7 +92051,6 @@ var ts;
91886
92051
  currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
91887
92052
  }
91888
92053
  currentLexicalScope = savedCurrentScope;
91889
- currentNameScope = savedCurrentNameScope;
91890
92054
  currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
91891
92055
  return visited;
91892
92056
  }
@@ -91902,7 +92066,6 @@ var ts;
91902
92066
  case 262 /* ModuleBlock */:
91903
92067
  case 235 /* Block */:
91904
92068
  currentLexicalScope = node;
91905
- currentNameScope = undefined;
91906
92069
  currentScopeFirstDeclarationsOfName = undefined;
91907
92070
  break;
91908
92071
  case 257 /* ClassDeclaration */:
@@ -91920,10 +92083,6 @@ var ts;
91920
92083
  // programs may also have an undefined name.
91921
92084
  ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
91922
92085
  }
91923
- if (ts.isClassDeclaration(node)) {
91924
- // XXX: should probably also cover interfaces and type aliases that can have type variables?
91925
- currentNameScope = node;
91926
- }
91927
92086
  break;
91928
92087
  }
91929
92088
  }
@@ -92025,35 +92184,66 @@ var ts;
92025
92184
  return node;
92026
92185
  }
92027
92186
  /**
92028
- * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
92187
+ * Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
92029
92188
  *
92030
- * @param node The node to visit.
92189
+ * @param parent The class containing the elements to visit.
92031
92190
  */
92032
- function classElementVisitor(node) {
92033
- return saveStateAndInvoke(node, classElementVisitorWorker);
92191
+ function getClassElementVisitor(parent) {
92192
+ return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
92034
92193
  }
92035
92194
  /**
92036
92195
  * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
92037
92196
  *
92038
92197
  * @param node The node to visit.
92039
92198
  */
92040
- function classElementVisitorWorker(node) {
92199
+ function classElementVisitorWorker(node, parent) {
92041
92200
  switch (node.kind) {
92042
92201
  case 171 /* Constructor */:
92043
92202
  return visitConstructor(node);
92044
92203
  case 167 /* PropertyDeclaration */:
92045
92204
  // Property declarations are not TypeScript syntax, but they must be visited
92046
92205
  // for the decorator transformation.
92047
- return visitPropertyDeclaration(node);
92048
- case 176 /* IndexSignature */:
92206
+ return visitPropertyDeclaration(node, parent);
92049
92207
  case 172 /* GetAccessor */:
92208
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92209
+ return visitGetAccessor(node, parent);
92050
92210
  case 173 /* SetAccessor */:
92211
+ // Set Accessors can have TypeScript modifiers and type annotations.
92212
+ return visitSetAccessor(node, parent);
92051
92213
  case 169 /* MethodDeclaration */:
92214
+ // TypeScript method declarations may have decorators, modifiers
92215
+ // or type annotations.
92216
+ return visitMethodDeclaration(node, parent);
92052
92217
  case 170 /* ClassStaticBlockDeclaration */:
92053
- // Fallback to the default visit behavior.
92054
- return visitorWorker(node);
92218
+ return ts.visitEachChild(node, visitor, context);
92055
92219
  case 234 /* SemicolonClassElement */:
92056
92220
  return node;
92221
+ case 176 /* IndexSignature */:
92222
+ // Index signatures are elided
92223
+ return;
92224
+ default:
92225
+ return ts.Debug.failBadSyntaxKind(node);
92226
+ }
92227
+ }
92228
+ function getObjectLiteralElementVisitor(parent) {
92229
+ return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
92230
+ }
92231
+ function objectLiteralElementVisitorWorker(node, parent) {
92232
+ switch (node.kind) {
92233
+ case 296 /* PropertyAssignment */:
92234
+ case 297 /* ShorthandPropertyAssignment */:
92235
+ case 298 /* SpreadAssignment */:
92236
+ return visitor(node);
92237
+ case 172 /* GetAccessor */:
92238
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92239
+ return visitGetAccessor(node, parent);
92240
+ case 173 /* SetAccessor */:
92241
+ // Set Accessors can have TypeScript modifiers and type annotations.
92242
+ return visitSetAccessor(node, parent);
92243
+ case 169 /* MethodDeclaration */:
92244
+ // TypeScript method declarations may have decorators, modifiers
92245
+ // or type annotations.
92246
+ return visitMethodDeclaration(node, parent);
92057
92247
  default:
92058
92248
  return ts.Debug.failBadSyntaxKind(node);
92059
92249
  }
@@ -92126,22 +92316,14 @@ var ts;
92126
92316
  // TypeScript type nodes are elided.
92127
92317
  // falls through
92128
92318
  case 176 /* IndexSignature */:
92129
- // TypeScript index signatures are elided.
92130
- // falls through
92131
- case 165 /* Decorator */:
92132
- // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
92319
+ // TypeScript index signatures are elided.
92133
92320
  return undefined;
92134
92321
  case 259 /* TypeAliasDeclaration */:
92135
92322
  // TypeScript type-only declarations are elided.
92136
92323
  return factory.createNotEmittedStatement(node);
92137
- case 167 /* PropertyDeclaration */:
92138
- // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
92139
- return visitPropertyDeclaration(node);
92140
92324
  case 264 /* NamespaceExportDeclaration */:
92141
92325
  // TypeScript namespace export declarations are elided.
92142
92326
  return undefined;
92143
- case 171 /* Constructor */:
92144
- return visitConstructor(node);
92145
92327
  case 258 /* InterfaceDeclaration */:
92146
92328
  // TypeScript interfaces are elided, but some comments may be preserved.
92147
92329
  // See the implementation of `getLeadingComments` in comments.ts for more details.
@@ -92175,16 +92357,15 @@ var ts;
92175
92357
  case 228 /* ExpressionWithTypeArguments */:
92176
92358
  // TypeScript supports type arguments on an expression in an `extends` heritage clause.
92177
92359
  return visitExpressionWithTypeArguments(node);
92360
+ case 205 /* ObjectLiteralExpression */:
92361
+ return visitObjectLiteralExpression(node);
92362
+ case 171 /* Constructor */:
92363
+ case 167 /* PropertyDeclaration */:
92178
92364
  case 169 /* MethodDeclaration */:
92179
- // TypeScript method declarations may have decorators, modifiers
92180
- // or type annotations.
92181
- return visitMethodDeclaration(node);
92182
92365
  case 172 /* GetAccessor */:
92183
- // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92184
- return visitGetAccessor(node);
92185
92366
  case 173 /* SetAccessor */:
92186
- // Set Accessors can have TypeScript modifiers and type annotations.
92187
- return visitSetAccessor(node);
92367
+ case 170 /* ClassStaticBlockDeclaration */:
92368
+ return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
92188
92369
  case 256 /* FunctionDeclaration */:
92189
92370
  // Typescript function declarations can have modifiers, decorators, and type annotations.
92190
92371
  return visitFunctionDeclaration(node);
@@ -92250,6 +92431,9 @@ var ts;
92250
92431
  !ts.isJsonSourceFile(node);
92251
92432
  return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
92252
92433
  }
92434
+ function visitObjectLiteralExpression(node) {
92435
+ return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
92436
+ }
92253
92437
  function getClassFacts(node, staticProperties) {
92254
92438
  var facts = 0 /* None */;
92255
92439
  if (ts.some(staticProperties))
@@ -92272,7 +92456,7 @@ var ts;
92272
92456
  return facts;
92273
92457
  }
92274
92458
  function hasTypeScriptClassSyntax(node) {
92275
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
92459
+ return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
92276
92460
  }
92277
92461
  function isClassLikeDeclarationWithTypeScriptSyntax(node) {
92278
92462
  return ts.some(node.decorators)
@@ -92282,7 +92466,9 @@ var ts;
92282
92466
  }
92283
92467
  function visitClassDeclaration(node) {
92284
92468
  if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
92285
- return ts.visitEachChild(node, visitor, context);
92469
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92470
+ ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
92471
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92286
92472
  }
92287
92473
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
92288
92474
  var facts = getClassFacts(node, staticProperties);
@@ -92290,14 +92476,25 @@ var ts;
92290
92476
  context.startLexicalEnvironment();
92291
92477
  }
92292
92478
  var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
92293
- var classStatement = facts & 2 /* HasConstructorDecorators */
92294
- ? createClassDeclarationHeadWithDecorators(node, name)
92295
- : createClassDeclarationHeadWithoutDecorators(node, name, facts);
92479
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92480
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92481
+ // we do not emit modifiers on the declaration if we are emitting an IIFE
92482
+ var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92483
+ ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92484
+ : ts.elideNodes(factory, node.modifiers); // preserve positions, if available
92485
+ // ${modifiers} class ${name} ${heritageClauses} {
92486
+ // ${members}
92487
+ // }
92488
+ var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
92489
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92490
+ // To better align with the old emitter, we should not emit a trailing source map
92491
+ // entry if the class has static properties.
92492
+ var emitFlags = ts.getEmitFlags(node);
92493
+ if (facts & 1 /* HasStaticInitializedProperties */) {
92494
+ emitFlags |= 32 /* NoTrailingSourceMap */;
92495
+ }
92496
+ ts.setEmitFlags(classStatement, emitFlags);
92296
92497
  var statements = [classStatement];
92297
- // Write any decorators of the node.
92298
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
92299
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
92300
- addConstructorDecorationStatement(statements, node);
92301
92498
  if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
92302
92499
  // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
92303
92500
  // 'es2015' transformer can properly nest static initializers and decorators. The result
@@ -92357,164 +92554,14 @@ var ts;
92357
92554
  }
92358
92555
  return ts.singleOrMany(statements);
92359
92556
  }
92360
- /**
92361
- * Transforms a non-decorated class declaration and appends the resulting statements.
92362
- *
92363
- * @param node A ClassDeclaration node.
92364
- * @param name The name of the class.
92365
- * @param facts Precomputed facts about the class.
92366
- */
92367
- function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
92368
- // ${modifiers} class ${name} ${heritageClauses} {
92369
- // ${members}
92370
- // }
92371
- // we do not emit modifiers on the declaration if we are emitting an IIFE
92372
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92373
- ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92374
- : undefined;
92375
- var classDeclaration = factory.createClassDeclaration(
92376
- /*decorators*/ undefined, modifiers, name,
92377
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92378
- // To better align with the old emitter, we should not emit a trailing source map
92379
- // entry if the class has static properties.
92380
- var emitFlags = ts.getEmitFlags(node);
92381
- if (facts & 1 /* HasStaticInitializedProperties */) {
92382
- emitFlags |= 32 /* NoTrailingSourceMap */;
92383
- }
92384
- ts.setTextRange(classDeclaration, node);
92385
- ts.setOriginalNode(classDeclaration, node);
92386
- ts.setEmitFlags(classDeclaration, emitFlags);
92387
- return classDeclaration;
92388
- }
92389
- /**
92390
- * Transforms a decorated class declaration and appends the resulting statements. If
92391
- * the class requires an alias to avoid issues with double-binding, the alias is returned.
92392
- */
92393
- function createClassDeclarationHeadWithDecorators(node, name) {
92394
- // When we emit an ES6 class that has a class decorator, we must tailor the
92395
- // emit to certain specific cases.
92396
- //
92397
- // In the simplest case, we emit the class declaration as a let declaration, and
92398
- // evaluate decorators after the close of the class body:
92399
- //
92400
- // [Example 1]
92401
- // ---------------------------------------------------------------------
92402
- // TypeScript | Javascript
92403
- // ---------------------------------------------------------------------
92404
- // @dec | let C = class C {
92405
- // class C { | }
92406
- // } | C = __decorate([dec], C);
92407
- // ---------------------------------------------------------------------
92408
- // @dec | let C = class C {
92409
- // export class C { | }
92410
- // } | C = __decorate([dec], C);
92411
- // | export { C };
92412
- // ---------------------------------------------------------------------
92413
- //
92414
- // If a class declaration contains a reference to itself *inside* of the class body,
92415
- // this introduces two bindings to the class: One outside of the class body, and one
92416
- // inside of the class body. If we apply decorators as in [Example 1] above, there
92417
- // is the possibility that the decorator `dec` will return a new value for the
92418
- // constructor, which would result in the binding inside of the class no longer
92419
- // pointing to the same reference as the binding outside of the class.
92420
- //
92421
- // As a result, we must instead rewrite all references to the class *inside* of the
92422
- // class body to instead point to a local temporary alias for the class:
92423
- //
92424
- // [Example 2]
92425
- // ---------------------------------------------------------------------
92426
- // TypeScript | Javascript
92427
- // ---------------------------------------------------------------------
92428
- // @dec | let C = C_1 = class C {
92429
- // class C { | static x() { return C_1.y; }
92430
- // static x() { return C.y; } | }
92431
- // static y = 1; | C.y = 1;
92432
- // } | C = C_1 = __decorate([dec], C);
92433
- // | var C_1;
92434
- // ---------------------------------------------------------------------
92435
- // @dec | let C = class C {
92436
- // export class C { | static x() { return C_1.y; }
92437
- // static x() { return C.y; } | }
92438
- // static y = 1; | C.y = 1;
92439
- // } | C = C_1 = __decorate([dec], C);
92440
- // | export { C };
92441
- // | var C_1;
92442
- // ---------------------------------------------------------------------
92443
- //
92444
- // If a class declaration is the default export of a module, we instead emit
92445
- // the export after the decorated declaration:
92446
- //
92447
- // [Example 3]
92448
- // ---------------------------------------------------------------------
92449
- // TypeScript | Javascript
92450
- // ---------------------------------------------------------------------
92451
- // @dec | let default_1 = class {
92452
- // export default class { | }
92453
- // } | default_1 = __decorate([dec], default_1);
92454
- // | export default default_1;
92455
- // ---------------------------------------------------------------------
92456
- // @dec | let C = class C {
92457
- // export default class C { | }
92458
- // } | C = __decorate([dec], C);
92459
- // | export default C;
92460
- // ---------------------------------------------------------------------
92461
- //
92462
- // If the class declaration is the default export and a reference to itself
92463
- // inside of the class body, we must emit both an alias for the class *and*
92464
- // move the export after the declaration:
92465
- //
92466
- // [Example 4]
92467
- // ---------------------------------------------------------------------
92468
- // TypeScript | Javascript
92469
- // ---------------------------------------------------------------------
92470
- // @dec | let C = class C {
92471
- // export default class C { | static x() { return C_1.y; }
92472
- // static x() { return C.y; } | }
92473
- // static y = 1; | C.y = 1;
92474
- // } | C = C_1 = __decorate([dec], C);
92475
- // | export default C;
92476
- // | var C_1;
92477
- // ---------------------------------------------------------------------
92478
- //
92479
- var location = ts.moveRangePastDecorators(node);
92480
- var classAlias = getClassAliasIfNeeded(node);
92481
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92482
- // without any block-scoped variable collision handling
92483
- var declName = languageVersion <= 2 /* ES2015 */ ?
92484
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92485
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92486
- // ... = class ${name} ${heritageClauses} {
92487
- // ${members}
92488
- // }
92489
- var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
92490
- var members = transformClassMembers(node);
92491
- var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
92492
- ts.setOriginalNode(classExpression, node);
92493
- ts.setTextRange(classExpression, location);
92494
- // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
92495
- // or decoratedClassAlias if the class contain self-reference.
92496
- var statement = factory.createVariableStatement(
92497
- /*modifiers*/ undefined, factory.createVariableDeclarationList([
92498
- factory.createVariableDeclaration(declName,
92499
- /*exclamationToken*/ undefined,
92500
- /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
92501
- ], 1 /* Let */));
92502
- ts.setOriginalNode(statement, node);
92503
- ts.setTextRange(statement, location);
92504
- ts.setCommentRange(statement, node);
92505
- return statement;
92506
- }
92507
92557
  function visitClassExpression(node) {
92508
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
92509
- return ts.visitEachChild(node, visitor, context);
92510
- }
92511
- var classExpression = factory.createClassExpression(
92512
- /*decorators*/ undefined,
92558
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92559
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92560
+ return factory.updateClassExpression(node, decorators,
92513
92561
  /*modifiers*/ undefined, node.name,
92514
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92515
- ts.setOriginalNode(classExpression, node);
92516
- ts.setTextRange(classExpression, node);
92517
- return classExpression;
92562
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
92563
+ transformClassMembers(node) :
92564
+ ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92518
92565
  }
92519
92566
  /**
92520
92567
  * Transforms the members of a class.
@@ -92539,48 +92586,9 @@ var ts;
92539
92586
  }
92540
92587
  }
92541
92588
  }
92542
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
92589
+ ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92543
92590
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
92544
92591
  }
92545
- /**
92546
- * Gets either the static or instance members of a class that are decorated, or have
92547
- * parameters that are decorated.
92548
- *
92549
- * @param node The class containing the member.
92550
- * @param isStatic A value indicating whether to retrieve static or instance members of
92551
- * the class.
92552
- */
92553
- function getDecoratedClassElements(node, isStatic) {
92554
- return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
92555
- }
92556
- /**
92557
- * Determines whether a class member is a static member of a class that is decorated, or
92558
- * has parameters that are decorated.
92559
- *
92560
- * @param member The class member.
92561
- */
92562
- function isStaticDecoratedClassElement(member, parent) {
92563
- return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
92564
- }
92565
- /**
92566
- * Determines whether a class member is an instance member of a class that is decorated,
92567
- * or has parameters that are decorated.
92568
- *
92569
- * @param member The class member.
92570
- */
92571
- function isInstanceDecoratedClassElement(member, parent) {
92572
- return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
92573
- }
92574
- /**
92575
- * Determines whether a class member is either a static or an instance member of a class
92576
- * that is decorated, or has parameters that are decorated.
92577
- *
92578
- * @param member The class member.
92579
- */
92580
- function isDecoratedClassElement(member, isStaticElement, parent) {
92581
- return ts.nodeOrChildIsDecorated(member, parent)
92582
- && isStaticElement === ts.isStatic(member);
92583
- }
92584
92592
  /**
92585
92593
  * Gets an array of arrays of decorators for the parameters of a function-like node.
92586
92594
  * The offset into the result array should correspond to the offset of the parameter.
@@ -92626,14 +92634,14 @@ var ts;
92626
92634
  /**
92627
92635
  * Gets an AllDecorators object containing the decorators for the member and its parameters.
92628
92636
  *
92629
- * @param node The class node that contains the member.
92637
+ * @param parent The class node that contains the member.
92630
92638
  * @param member The class member.
92631
92639
  */
92632
- function getAllDecoratorsOfClassElement(node, member) {
92640
+ function getAllDecoratorsOfClassElement(member, parent) {
92633
92641
  switch (member.kind) {
92634
92642
  case 172 /* GetAccessor */:
92635
92643
  case 173 /* SetAccessor */:
92636
- return getAllDecoratorsOfAccessors(node, member);
92644
+ return getAllDecoratorsOfAccessors(parent, member);
92637
92645
  case 169 /* MethodDeclaration */:
92638
92646
  return getAllDecoratorsOfMethod(member);
92639
92647
  case 167 /* PropertyDeclaration */:
@@ -92702,209 +92710,82 @@ var ts;
92702
92710
  if (!allDecorators) {
92703
92711
  return undefined;
92704
92712
  }
92705
- var decoratorExpressions = [];
92706
- ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
92707
- ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
92708
- addTypeMetadata(node, container, decoratorExpressions);
92709
- return decoratorExpressions;
92710
- }
92711
- /**
92712
- * Generates statements used to apply decorators to either the static or instance members
92713
- * of a class.
92714
- *
92715
- * @param node The class node.
92716
- * @param isStatic A value indicating whether to generate statements for static or
92717
- * instance members.
92718
- */
92719
- function addClassElementDecorationStatements(statements, node, isStatic) {
92720
- ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
92721
- }
92722
- /**
92723
- * Generates expressions used to apply decorators to either the static or instance members
92724
- * of a class.
92725
- *
92726
- * @param node The class node.
92727
- * @param isStatic A value indicating whether to generate expressions for static or
92728
- * instance members.
92729
- */
92730
- function generateClassElementDecorationExpressions(node, isStatic) {
92731
- var members = getDecoratedClassElements(node, isStatic);
92732
- var expressions;
92733
- for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
92734
- var member = members_8[_i];
92735
- var expression = generateClassElementDecorationExpression(node, member);
92736
- if (expression) {
92737
- if (!expressions) {
92738
- expressions = [expression];
92739
- }
92740
- else {
92741
- expressions.push(expression);
92742
- }
92743
- }
92744
- }
92745
- return expressions;
92746
- }
92747
- /**
92748
- * Generates an expression used to evaluate class element decorators at runtime.
92749
- *
92750
- * @param node The class node that contains the member.
92751
- * @param member The class member.
92752
- */
92753
- function generateClassElementDecorationExpression(node, member) {
92754
- var allDecorators = getAllDecoratorsOfClassElement(node, member);
92755
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
92756
- if (!decoratorExpressions) {
92757
- return undefined;
92758
- }
92759
- // Emit the call to __decorate. Given the following:
92760
- //
92761
- // class C {
92762
- // @dec method(@dec2 x) {}
92763
- // @dec get accessor() {}
92764
- // @dec prop;
92765
- // }
92766
- //
92767
- // The emit for a method is:
92768
- //
92769
- // __decorate([
92770
- // dec,
92771
- // __param(0, dec2),
92772
- // __metadata("design:type", Function),
92773
- // __metadata("design:paramtypes", [Object]),
92774
- // __metadata("design:returntype", void 0)
92775
- // ], C.prototype, "method", null);
92776
- //
92777
- // The emit for an accessor is:
92778
- //
92779
- // __decorate([
92780
- // dec
92781
- // ], C.prototype, "accessor", null);
92782
- //
92783
- // The emit for a property is:
92784
- //
92785
- // __decorate([
92786
- // dec
92787
- // ], C.prototype, "prop");
92788
- //
92789
- var prefix = getClassMemberPrefix(node, member);
92790
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
92791
- var descriptor = languageVersion > 0 /* ES3 */
92792
- ? member.kind === 167 /* PropertyDeclaration */
92793
- // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
92794
- // should not invoke `Object.getOwnPropertyDescriptor`.
92795
- ? factory.createVoidZero()
92796
- // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
92797
- // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
92798
- : factory.createNull()
92799
- : undefined;
92800
- var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
92801
- ts.setTextRange(helper, ts.moveRangePastDecorators(member));
92802
- ts.setEmitFlags(helper, 1536 /* NoComments */);
92803
- return helper;
92804
- }
92805
- /**
92806
- * Generates a __decorate helper call for a class constructor.
92807
- *
92808
- * @param node The class node.
92809
- */
92810
- function addConstructorDecorationStatement(statements, node) {
92811
- var expression = generateConstructorDecorationExpression(node);
92812
- if (expression) {
92813
- statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
92814
- }
92815
- }
92816
- /**
92817
- * Generates a __decorate helper call for a class constructor.
92818
- *
92819
- * @param node The class node.
92820
- */
92821
- function generateConstructorDecorationExpression(node) {
92822
- var allDecorators = getAllDecoratorsOfConstructor(node);
92823
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92824
- if (!decoratorExpressions) {
92825
- return undefined;
92826
- }
92827
- var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
92828
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92829
- // without any block-scoped variable collision handling
92830
- var localName = languageVersion <= 2 /* ES2015 */ ?
92831
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92832
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92833
- var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
92834
- var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
92835
- ts.setEmitFlags(expression, 1536 /* NoComments */);
92836
- ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
92837
- return expression;
92838
- }
92839
- /**
92840
- * Transforms a decorator into an expression.
92841
- *
92842
- * @param decorator The decorator node.
92843
- */
92844
- function transformDecorator(decorator) {
92845
- return ts.visitNode(decorator.expression, visitor, ts.isExpression);
92713
+ var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
92714
+ var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
92715
+ var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
92716
+ var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
92717
+ ts.setTextRange(result, decorators);
92718
+ return result;
92846
92719
  }
92847
92720
  /**
92848
- * Transforms the decorators of a parameter.
92721
+ * Transforms the decorators of a parameter into decorators of the class/method.
92849
92722
  *
92850
- * @param decorators The decorators for the parameter at the provided offset.
92723
+ * @param parameterDecorators The decorators for the parameter at the provided offset.
92851
92724
  * @param parameterOffset The offset of the parameter.
92852
92725
  */
92853
- function transformDecoratorsOfParameter(decorators, parameterOffset) {
92854
- var expressions;
92855
- if (decorators) {
92856
- expressions = [];
92857
- for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
92858
- var decorator = decorators_1[_i];
92859
- var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
92860
- ts.setTextRange(helper, decorator.expression);
92726
+ function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
92727
+ if (parameterDecorators) {
92728
+ var decorators = [];
92729
+ for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
92730
+ var parameterDecorator = parameterDecorators_1[_i];
92731
+ var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
92732
+ var helper = emitHelpers().createParamHelper(expression, parameterOffset);
92733
+ ts.setTextRange(helper, parameterDecorator.expression);
92861
92734
  ts.setEmitFlags(helper, 1536 /* NoComments */);
92862
- expressions.push(helper);
92735
+ var decorator = factory.createDecorator(helper);
92736
+ ts.setTextRange(decorator, parameterDecorator.expression);
92737
+ ts.setEmitFlags(decorator, 1536 /* NoComments */);
92738
+ decorators.push(decorator);
92863
92739
  }
92740
+ return decorators;
92864
92741
  }
92865
- return expressions;
92866
92742
  }
92867
92743
  /**
92868
- * Adds optional type metadata for a declaration.
92744
+ * Gets optional type metadata for a declaration.
92869
92745
  *
92870
92746
  * @param node The declaration node.
92871
- * @param decoratorExpressions The destination array to which to add new decorator expressions.
92872
92747
  */
92873
- function addTypeMetadata(node, container, decoratorExpressions) {
92874
- if (USE_NEW_TYPE_METADATA_FORMAT) {
92875
- addNewTypeMetadata(node, container, decoratorExpressions);
92876
- }
92877
- else {
92878
- addOldTypeMetadata(node, container, decoratorExpressions);
92879
- }
92748
+ function getTypeMetadata(node, container) {
92749
+ return USE_NEW_TYPE_METADATA_FORMAT ?
92750
+ getNewTypeMetadata(node, container) :
92751
+ getOldTypeMetadata(node, container);
92880
92752
  }
92881
- function addOldTypeMetadata(node, container, decoratorExpressions) {
92882
- if (compilerOptions.emitDecoratorMetadata) {
92753
+ function getOldTypeMetadata(node, container) {
92754
+ if (typeSerializer) {
92755
+ var decorators = void 0;
92883
92756
  if (shouldAddTypeMetadata(node)) {
92884
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
92757
+ var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92758
+ decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
92885
92759
  }
92886
92760
  if (shouldAddParamTypesMetadata(node)) {
92887
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
92761
+ var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
92762
+ decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
92888
92763
  }
92889
92764
  if (shouldAddReturnTypeMetadata(node)) {
92890
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
92765
+ var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92766
+ decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
92891
92767
  }
92768
+ return decorators;
92892
92769
  }
92893
92770
  }
92894
- function addNewTypeMetadata(node, container, decoratorExpressions) {
92895
- if (compilerOptions.emitDecoratorMetadata) {
92771
+ function getNewTypeMetadata(node, container) {
92772
+ if (typeSerializer) {
92896
92773
  var properties = void 0;
92897
92774
  if (shouldAddTypeMetadata(node)) {
92898
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
92775
+ var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92776
+ properties = ts.append(properties, typeProperty);
92899
92777
  }
92900
92778
  if (shouldAddParamTypesMetadata(node)) {
92901
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
92779
+ var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container)));
92780
+ properties = ts.append(properties, paramTypeProperty);
92902
92781
  }
92903
92782
  if (shouldAddReturnTypeMetadata(node)) {
92904
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
92783
+ var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92784
+ properties = ts.append(properties, returnTypeProperty);
92905
92785
  }
92906
92786
  if (properties) {
92907
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
92787
+ var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
92788
+ return [factory.createDecorator(typeInfoMetadata)];
92908
92789
  }
92909
92790
  }
92910
92791
  }
@@ -92951,347 +92832,6 @@ var ts;
92951
92832
  }
92952
92833
  return false;
92953
92834
  }
92954
- function getAccessorTypeNode(node) {
92955
- var accessors = resolver.getAllAccessorDeclarations(node);
92956
- return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
92957
- || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
92958
- }
92959
- /**
92960
- * Serializes the type of a node for use with decorator type metadata.
92961
- *
92962
- * @param node The node that should have its type serialized.
92963
- */
92964
- function serializeTypeOfNode(node) {
92965
- switch (node.kind) {
92966
- case 167 /* PropertyDeclaration */:
92967
- case 164 /* Parameter */:
92968
- return serializeTypeNode(node.type);
92969
- case 173 /* SetAccessor */:
92970
- case 172 /* GetAccessor */:
92971
- return serializeTypeNode(getAccessorTypeNode(node));
92972
- case 257 /* ClassDeclaration */:
92973
- case 226 /* ClassExpression */:
92974
- case 169 /* MethodDeclaration */:
92975
- return factory.createIdentifier("Function");
92976
- default:
92977
- return factory.createVoidZero();
92978
- }
92979
- }
92980
- /**
92981
- * Serializes the types of the parameters of a node for use with decorator type metadata.
92982
- *
92983
- * @param node The node that should have its parameter types serialized.
92984
- */
92985
- function serializeParameterTypesOfNode(node, container) {
92986
- var valueDeclaration = ts.isClassLike(node)
92987
- ? ts.getFirstConstructorWithBody(node)
92988
- : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
92989
- ? node
92990
- : undefined;
92991
- var expressions = [];
92992
- if (valueDeclaration) {
92993
- var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
92994
- var numParameters = parameters.length;
92995
- for (var i = 0; i < numParameters; i++) {
92996
- var parameter = parameters[i];
92997
- if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
92998
- continue;
92999
- }
93000
- if (parameter.dotDotDotToken) {
93001
- expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
93002
- }
93003
- else {
93004
- expressions.push(serializeTypeOfNode(parameter));
93005
- }
93006
- }
93007
- }
93008
- return factory.createArrayLiteralExpression(expressions);
93009
- }
93010
- function getParametersOfDecoratedDeclaration(node, container) {
93011
- if (container && node.kind === 172 /* GetAccessor */) {
93012
- var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
93013
- if (setAccessor) {
93014
- return setAccessor.parameters;
93015
- }
93016
- }
93017
- return node.parameters;
93018
- }
93019
- /**
93020
- * Serializes the return type of a node for use with decorator type metadata.
93021
- *
93022
- * @param node The node that should have its return type serialized.
93023
- */
93024
- function serializeReturnTypeOfNode(node) {
93025
- if (ts.isFunctionLike(node) && node.type) {
93026
- return serializeTypeNode(node.type);
93027
- }
93028
- else if (ts.isAsyncFunction(node)) {
93029
- return factory.createIdentifier("Promise");
93030
- }
93031
- return factory.createVoidZero();
93032
- }
93033
- /**
93034
- * Serializes a type node for use with decorator type metadata.
93035
- *
93036
- * Types are serialized in the following fashion:
93037
- * - Void types point to "undefined" (e.g. "void 0")
93038
- * - Function and Constructor types point to the global "Function" constructor.
93039
- * - Interface types with a call or construct signature types point to the global
93040
- * "Function" constructor.
93041
- * - Array and Tuple types point to the global "Array" constructor.
93042
- * - Type predicates and booleans point to the global "Boolean" constructor.
93043
- * - String literal types and strings point to the global "String" constructor.
93044
- * - Enum and number types point to the global "Number" constructor.
93045
- * - Symbol types point to the global "Symbol" constructor.
93046
- * - Type references to classes (or class-like variables) point to the constructor for the class.
93047
- * - Anything else points to the global "Object" constructor.
93048
- *
93049
- * @param node The type node to serialize.
93050
- */
93051
- function serializeTypeNode(node) {
93052
- if (node === undefined) {
93053
- return factory.createIdentifier("Object");
93054
- }
93055
- switch (node.kind) {
93056
- case 114 /* VoidKeyword */:
93057
- case 153 /* UndefinedKeyword */:
93058
- case 143 /* NeverKeyword */:
93059
- return factory.createVoidZero();
93060
- case 191 /* ParenthesizedType */:
93061
- return serializeTypeNode(node.type);
93062
- case 179 /* FunctionType */:
93063
- case 180 /* ConstructorType */:
93064
- return factory.createIdentifier("Function");
93065
- case 183 /* ArrayType */:
93066
- case 184 /* TupleType */:
93067
- return factory.createIdentifier("Array");
93068
- case 177 /* TypePredicate */:
93069
- case 133 /* BooleanKeyword */:
93070
- return factory.createIdentifier("Boolean");
93071
- case 198 /* TemplateLiteralType */:
93072
- case 150 /* StringKeyword */:
93073
- return factory.createIdentifier("String");
93074
- case 148 /* ObjectKeyword */:
93075
- return factory.createIdentifier("Object");
93076
- case 196 /* LiteralType */:
93077
- switch (node.literal.kind) {
93078
- case 10 /* StringLiteral */:
93079
- case 14 /* NoSubstitutionTemplateLiteral */:
93080
- return factory.createIdentifier("String");
93081
- case 219 /* PrefixUnaryExpression */:
93082
- case 8 /* NumericLiteral */:
93083
- return factory.createIdentifier("Number");
93084
- case 9 /* BigIntLiteral */:
93085
- return getGlobalBigIntNameWithFallback();
93086
- case 110 /* TrueKeyword */:
93087
- case 95 /* FalseKeyword */:
93088
- return factory.createIdentifier("Boolean");
93089
- case 104 /* NullKeyword */:
93090
- return factory.createVoidZero();
93091
- default:
93092
- return ts.Debug.failBadSyntaxKind(node.literal);
93093
- }
93094
- case 147 /* NumberKeyword */:
93095
- return factory.createIdentifier("Number");
93096
- case 158 /* BigIntKeyword */:
93097
- return getGlobalBigIntNameWithFallback();
93098
- case 151 /* SymbolKeyword */:
93099
- return languageVersion < 2 /* ES2015 */
93100
- ? getGlobalSymbolNameWithFallback()
93101
- : factory.createIdentifier("Symbol");
93102
- case 178 /* TypeReference */:
93103
- return serializeTypeReferenceNode(node);
93104
- case 188 /* IntersectionType */:
93105
- case 187 /* UnionType */:
93106
- return serializeTypeList(node.types);
93107
- case 189 /* ConditionalType */:
93108
- return serializeTypeList([node.trueType, node.falseType]);
93109
- case 193 /* TypeOperator */:
93110
- if (node.operator === 145 /* ReadonlyKeyword */) {
93111
- return serializeTypeNode(node.type);
93112
- }
93113
- break;
93114
- case 181 /* TypeQuery */:
93115
- case 194 /* IndexedAccessType */:
93116
- case 195 /* MappedType */:
93117
- case 182 /* TypeLiteral */:
93118
- case 130 /* AnyKeyword */:
93119
- case 155 /* UnknownKeyword */:
93120
- case 192 /* ThisType */:
93121
- case 200 /* ImportType */:
93122
- break;
93123
- // handle JSDoc types from an invalid parse
93124
- case 312 /* JSDocAllType */:
93125
- case 313 /* JSDocUnknownType */:
93126
- case 317 /* JSDocFunctionType */:
93127
- case 318 /* JSDocVariadicType */:
93128
- case 319 /* JSDocNamepathType */:
93129
- break;
93130
- case 314 /* JSDocNullableType */:
93131
- case 315 /* JSDocNonNullableType */:
93132
- case 316 /* JSDocOptionalType */:
93133
- return serializeTypeNode(node.type);
93134
- default:
93135
- return ts.Debug.failBadSyntaxKind(node);
93136
- }
93137
- return factory.createIdentifier("Object");
93138
- }
93139
- function serializeTypeList(types) {
93140
- // Note when updating logic here also update getEntityNameForDecoratorMetadata
93141
- // so that aliases can be marked as referenced
93142
- var serializedUnion;
93143
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
93144
- var typeNode = types_22[_i];
93145
- while (typeNode.kind === 191 /* ParenthesizedType */) {
93146
- typeNode = typeNode.type; // Skip parens if need be
93147
- }
93148
- if (typeNode.kind === 143 /* NeverKeyword */) {
93149
- continue; // Always elide `never` from the union/intersection if possible
93150
- }
93151
- if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
93152
- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
93153
- }
93154
- var serializedIndividual = serializeTypeNode(typeNode);
93155
- if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
93156
- // One of the individual is global object, return immediately
93157
- return serializedIndividual;
93158
- }
93159
- // If there exists union that is not void 0 expression, check if the the common type is identifier.
93160
- // anything more complex and we will just default to Object
93161
- else if (serializedUnion) {
93162
- // Different types
93163
- if (!ts.isIdentifier(serializedUnion) ||
93164
- !ts.isIdentifier(serializedIndividual) ||
93165
- serializedUnion.escapedText !== serializedIndividual.escapedText) {
93166
- return factory.createIdentifier("Object");
93167
- }
93168
- }
93169
- else {
93170
- // Initialize the union type
93171
- serializedUnion = serializedIndividual;
93172
- }
93173
- }
93174
- // If we were able to find common type, use it
93175
- return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
93176
- }
93177
- /**
93178
- * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
93179
- * decorator type metadata.
93180
- *
93181
- * @param node The type reference node.
93182
- */
93183
- function serializeTypeReferenceNode(node) {
93184
- var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
93185
- switch (kind) {
93186
- case ts.TypeReferenceSerializationKind.Unknown:
93187
- // From conditional type type reference that cannot be resolved is Similar to any or unknown
93188
- if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
93189
- return factory.createIdentifier("Object");
93190
- }
93191
- var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
93192
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93193
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
93194
- /*questionToken*/ undefined, temp,
93195
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93196
- case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
93197
- return serializeEntityNameAsExpression(node.typeName);
93198
- case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
93199
- return factory.createVoidZero();
93200
- case ts.TypeReferenceSerializationKind.BigIntLikeType:
93201
- return getGlobalBigIntNameWithFallback();
93202
- case ts.TypeReferenceSerializationKind.BooleanType:
93203
- return factory.createIdentifier("Boolean");
93204
- case ts.TypeReferenceSerializationKind.NumberLikeType:
93205
- return factory.createIdentifier("Number");
93206
- case ts.TypeReferenceSerializationKind.StringLikeType:
93207
- return factory.createIdentifier("String");
93208
- case ts.TypeReferenceSerializationKind.ArrayLikeType:
93209
- return factory.createIdentifier("Array");
93210
- case ts.TypeReferenceSerializationKind.ESSymbolType:
93211
- return languageVersion < 2 /* ES2015 */
93212
- ? getGlobalSymbolNameWithFallback()
93213
- : factory.createIdentifier("Symbol");
93214
- case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
93215
- return factory.createIdentifier("Function");
93216
- case ts.TypeReferenceSerializationKind.Promise:
93217
- return factory.createIdentifier("Promise");
93218
- case ts.TypeReferenceSerializationKind.ObjectType:
93219
- return factory.createIdentifier("Object");
93220
- default:
93221
- return ts.Debug.assertNever(kind);
93222
- }
93223
- }
93224
- function createCheckedValue(left, right) {
93225
- return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
93226
- }
93227
- /**
93228
- * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
93229
- *
93230
- * @param node The entity name to serialize.
93231
- */
93232
- function serializeEntityNameAsExpressionFallback(node) {
93233
- if (node.kind === 79 /* Identifier */) {
93234
- // A -> typeof A !== undefined && A
93235
- var copied = serializeEntityNameAsExpression(node);
93236
- return createCheckedValue(copied, copied);
93237
- }
93238
- if (node.left.kind === 79 /* Identifier */) {
93239
- // A.B -> typeof A !== undefined && A.B
93240
- return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
93241
- }
93242
- // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
93243
- var left = serializeEntityNameAsExpressionFallback(node.left);
93244
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93245
- return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
93246
- }
93247
- /**
93248
- * Serializes an entity name as an expression for decorator type metadata.
93249
- *
93250
- * @param node The entity name to serialize.
93251
- */
93252
- function serializeEntityNameAsExpression(node) {
93253
- switch (node.kind) {
93254
- case 79 /* Identifier */:
93255
- // Create a clone of the name with a new parent, and treat it as if it were
93256
- // a source tree node for the purposes of the checker.
93257
- var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
93258
- name.original = undefined;
93259
- ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
93260
- return name;
93261
- case 161 /* QualifiedName */:
93262
- return serializeQualifiedNameAsExpression(node);
93263
- }
93264
- }
93265
- /**
93266
- * Serializes an qualified name as an expression for decorator type metadata.
93267
- *
93268
- * @param node The qualified name to serialize.
93269
- * @param useFallback A value indicating whether to use logical operators to test for the
93270
- * qualified name at runtime.
93271
- */
93272
- function serializeQualifiedNameAsExpression(node) {
93273
- return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
93274
- }
93275
- /**
93276
- * Gets an expression that points to the global "Symbol" constructor at runtime if it is
93277
- * available.
93278
- */
93279
- function getGlobalSymbolNameWithFallback() {
93280
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
93281
- /*questionToken*/ undefined, factory.createIdentifier("Symbol"),
93282
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93283
- }
93284
- /**
93285
- * Gets an expression that points to the global "BigInt" constructor at runtime if it is
93286
- * available.
93287
- */
93288
- function getGlobalBigIntNameWithFallback() {
93289
- return languageVersion < 99 /* ESNext */
93290
- ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
93291
- /*questionToken*/ undefined, factory.createIdentifier("BigInt"),
93292
- /*colonToken*/ undefined, factory.createIdentifier("Object"))
93293
- : factory.createIdentifier("BigInt");
93294
- }
93295
92835
  /**
93296
92836
  * Gets an expression that represents a property name (for decorated properties or enums).
93297
92837
  * For a computed property, a name is generated for the node.
@@ -93376,21 +92916,23 @@ var ts;
93376
92916
  function shouldEmitFunctionLikeDeclaration(node) {
93377
92917
  return !ts.nodeIsMissing(node.body);
93378
92918
  }
93379
- function visitPropertyDeclaration(node) {
93380
- if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92919
+ function visitPropertyDeclaration(node, parent) {
92920
+ var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
92921
+ if (isAmbient && !ts.some(node.decorators)) {
93381
92922
  return undefined;
93382
92923
  }
93383
- var updated = factory.updatePropertyDeclaration(node,
93384
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
92924
+ var allDecorators = getAllDecoratorsOfClassElement(node, parent);
92925
+ var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
92926
+ // Preserve a `declare x` property with decorators to be handled by the decorators transform
92927
+ if (isAmbient) {
92928
+ return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
92929
+ /*questionOrExclamationToken*/ undefined,
92930
+ /*type*/ undefined,
92931
+ /*initializer*/ undefined);
92932
+ }
92933
+ return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
93385
92934
  /*questionOrExclamationToken*/ undefined,
93386
92935
  /*type*/ undefined, ts.visitNode(node.initializer, visitor));
93387
- if (updated !== node) {
93388
- // While we emit the source map for the node after skipping decorators and modifiers,
93389
- // we need to emit the comments for the original range.
93390
- ts.setCommentRange(updated, node);
93391
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93392
- }
93393
- return updated;
93394
92936
  }
93395
92937
  function visitConstructor(node) {
93396
92938
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93398,7 +92940,7 @@ var ts;
93398
92940
  }
93399
92941
  return factory.updateConstructorDeclaration(node,
93400
92942
  /*decorators*/ undefined,
93401
- /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
92943
+ /*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
93402
92944
  }
93403
92945
  function transformConstructorBody(body, constructor) {
93404
92946
  var parametersWithPropertyAssignments = constructor &&
@@ -93462,22 +93004,19 @@ var ts;
93462
93004
  ts.setEmitFlags(localName, 1536 /* NoComments */);
93463
93005
  return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1))));
93464
93006
  }
93465
- function visitMethodDeclaration(node) {
93007
+ function visitMethodDeclaration(node, parent) {
93008
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93009
+ return node;
93010
+ }
93466
93011
  if (!shouldEmitFunctionLikeDeclaration(node)) {
93467
93012
  return undefined;
93468
93013
  }
93469
- var updated = factory.updateMethodDeclaration(node,
93470
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93014
+ var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
93015
+ var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
93016
+ return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93471
93017
  /*questionToken*/ undefined,
93472
93018
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
93473
93019
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
93474
- if (updated !== node) {
93475
- // While we emit the source map for the node after skipping decorators and modifiers,
93476
- // we need to emit the comments for the original range.
93477
- ts.setCommentRange(updated, node);
93478
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93479
- }
93480
- return updated;
93481
93020
  }
93482
93021
  /**
93483
93022
  * Determines whether to emit an accessor declaration. We should not emit the
@@ -93488,34 +93027,30 @@ var ts;
93488
93027
  function shouldEmitAccessorDeclaration(node) {
93489
93028
  return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
93490
93029
  }
93491
- function visitGetAccessor(node) {
93030
+ function visitGetAccessor(node, parent) {
93031
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93032
+ return node;
93033
+ }
93492
93034
  if (!shouldEmitAccessorDeclaration(node)) {
93493
93035
  return undefined;
93494
93036
  }
93495
- var updated = factory.updateGetAccessorDeclaration(node,
93496
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93037
+ var decorators = ts.isClassLike(parent) ?
93038
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
93039
+ undefined;
93040
+ return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93497
93041
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93498
- if (updated !== node) {
93499
- // While we emit the source map for the node after skipping decorators and modifiers,
93500
- // we need to emit the comments for the original range.
93501
- ts.setCommentRange(updated, node);
93502
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93503
- }
93504
- return updated;
93505
93042
  }
93506
- function visitSetAccessor(node) {
93043
+ function visitSetAccessor(node, parent) {
93044
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
93045
+ return node;
93046
+ }
93507
93047
  if (!shouldEmitAccessorDeclaration(node)) {
93508
93048
  return undefined;
93509
93049
  }
93510
- var updated = factory.updateSetAccessorDeclaration(node,
93511
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93512
- if (updated !== node) {
93513
- // While we emit the source map for the node after skipping decorators and modifiers,
93514
- // we need to emit the comments for the original range.
93515
- ts.setCommentRange(updated, node);
93516
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93517
- }
93518
- return updated;
93050
+ var decorators = ts.isClassLike(parent) ?
93051
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
93052
+ undefined;
93053
+ return factory.updateSetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93519
93054
  }
93520
93055
  function visitFunctionDeclaration(node) {
93521
93056
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93551,9 +93086,9 @@ var ts;
93551
93086
  if (ts.parameterIsThisKeyword(node)) {
93552
93087
  return undefined;
93553
93088
  }
93554
- var updated = factory.updateParameterDeclaration(node,
93555
- /*decorators*/ undefined,
93556
- /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93089
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
93090
+ ts.elideNodes(factory, node.modifiers), // preserve positions, if available
93091
+ node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93557
93092
  /*questionToken*/ undefined,
93558
93093
  /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
93559
93094
  if (updated !== node) {
@@ -94249,12 +93784,6 @@ var ts;
94249
93784
  return isExternalModuleExport(node)
94250
93785
  && ts.hasSyntacticModifier(node, 512 /* Default */);
94251
93786
  }
94252
- /**
94253
- * Creates a statement for the provided expression. This is used in calls to `map`.
94254
- */
94255
- function expressionToStatement(expression) {
94256
- return factory.createExpressionStatement(expression);
94257
- }
94258
93787
  function addExportMemberAssignment(statements, node) {
94259
93788
  var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
94260
93789
  ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
@@ -94286,44 +93815,12 @@ var ts;
94286
93815
  function getNamespaceContainerName(node) {
94287
93816
  return factory.getGeneratedNameForNode(node);
94288
93817
  }
94289
- /**
94290
- * Gets a local alias for a class declaration if it is a decorated class with an internal
94291
- * reference to the static side of the class. This is necessary to avoid issues with
94292
- * double-binding semantics for the class name.
94293
- */
94294
- function getClassAliasIfNeeded(node) {
94295
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
94296
- enableSubstitutionForClassAliases();
94297
- var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
94298
- classAliases[ts.getOriginalNodeId(node)] = classAlias;
94299
- hoistVariableDeclaration(classAlias);
94300
- return classAlias;
94301
- }
94302
- }
94303
- function getClassPrototype(node) {
94304
- return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
94305
- }
94306
- function getClassMemberPrefix(node, member) {
94307
- return ts.isStatic(member)
94308
- ? factory.getDeclarationName(node)
94309
- : getClassPrototype(node);
94310
- }
94311
93818
  function enableSubstitutionForNonQualifiedEnumMembers() {
94312
93819
  if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
94313
93820
  enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
94314
93821
  context.enableSubstitution(79 /* Identifier */);
94315
93822
  }
94316
93823
  }
94317
- function enableSubstitutionForClassAliases() {
94318
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
94319
- enabledSubstitutions |= 1 /* ClassAliases */;
94320
- // We need to enable substitutions for identifiers. This allows us to
94321
- // substitute class names inside of a class declaration.
94322
- context.enableSubstitution(79 /* Identifier */);
94323
- // Keep track of class aliases.
94324
- classAliases = [];
94325
- }
94326
- }
94327
93824
  function enableSubstitutionForNamespaceExports() {
94328
93825
  if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
94329
93826
  enabledSubstitutions |= 2 /* NamespaceExports */;
@@ -94408,32 +93905,9 @@ var ts;
94408
93905
  return node;
94409
93906
  }
94410
93907
  function substituteExpressionIdentifier(node) {
94411
- return trySubstituteClassAlias(node)
94412
- || trySubstituteNamespaceExportedName(node)
93908
+ return trySubstituteNamespaceExportedName(node)
94413
93909
  || node;
94414
93910
  }
94415
- function trySubstituteClassAlias(node) {
94416
- if (enabledSubstitutions & 1 /* ClassAliases */) {
94417
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
94418
- // Due to the emit for class decorators, any reference to the class from inside of the class body
94419
- // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
94420
- // behavior of class names in ES6.
94421
- // Also, when emitting statics for class expressions, we must substitute a class alias for
94422
- // constructor references in static property initializers.
94423
- var declaration = resolver.getReferencedValueDeclaration(node);
94424
- if (declaration) {
94425
- var classAlias = classAliases[declaration.id]; // TODO: GH#18217
94426
- if (classAlias) {
94427
- var clone_2 = factory.cloneNode(classAlias);
94428
- ts.setSourceMapRange(clone_2, node);
94429
- ts.setCommentRange(clone_2, node);
94430
- return clone_2;
94431
- }
94432
- }
94433
- }
94434
- }
94435
- return undefined;
94436
- }
94437
93911
  function trySubstituteNamespaceExportedName(node) {
94438
93912
  // If this is explicitly a local name, do not substitute.
94439
93913
  if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
@@ -94571,7 +94045,7 @@ var ts;
94571
94045
  return visited;
94572
94046
  }
94573
94047
  function visitorWorker(node, valueIsDiscarded) {
94574
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
94048
+ if (node.transformFlags & 16777216 /* ContainsClassFields */) {
94575
94049
  switch (node.kind) {
94576
94050
  case 226 /* ClassExpression */:
94577
94051
  case 257 /* ClassDeclaration */:
@@ -94586,8 +94060,8 @@ var ts;
94586
94060
  return visitClassStaticBlockDeclaration(node);
94587
94061
  }
94588
94062
  }
94589
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
94590
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
94063
+ if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
94064
+ node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
94591
94065
  shouldTransformSuperInStaticInitializers &&
94592
94066
  currentStaticPropertyDeclarationOrStaticBlock &&
94593
94067
  currentClassLexicalEnvironment) {
@@ -95161,13 +94635,13 @@ var ts;
95161
94635
  facts |= 2 /* NeedsClassConstructorReference */;
95162
94636
  }
95163
94637
  if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
95164
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
94638
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
95165
94639
  facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
95166
94640
  if (!(facts & 1 /* ClassWasDecorated */)) {
95167
94641
  facts |= 2 /* NeedsClassConstructorReference */;
95168
94642
  }
95169
94643
  }
95170
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
94644
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
95171
94645
  if (!(facts & 1 /* ClassWasDecorated */)) {
95172
94646
  facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
95173
94647
  }
@@ -95752,10 +95226,10 @@ var ts;
95752
95226
  if (declaration) {
95753
95227
  var classAlias = classAliases[declaration.id]; // TODO: GH#18217
95754
95228
  if (classAlias) {
95755
- var clone_3 = factory.cloneNode(classAlias);
95756
- ts.setSourceMapRange(clone_3, node);
95757
- ts.setCommentRange(clone_3, node);
95758
- return clone_3;
95229
+ var clone_2 = factory.cloneNode(classAlias);
95230
+ ts.setSourceMapRange(clone_2, node);
95231
+ ts.setCommentRange(clone_2, node);
95232
+ return clone_2;
95759
95233
  }
95760
95234
  }
95761
95235
  }
@@ -96117,6 +95591,965 @@ var ts;
96117
95591
  })(ts || (ts = {}));
96118
95592
  /*@internal*/
96119
95593
  var ts;
95594
+ (function (ts) {
95595
+ function createRuntimeTypeSerializer(context) {
95596
+ var hoistVariableDeclaration = context.hoistVariableDeclaration;
95597
+ var resolver = context.getEmitResolver();
95598
+ var compilerOptions = context.getCompilerOptions();
95599
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95600
+ var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
95601
+ var currentLexicalScope;
95602
+ var currentNameScope;
95603
+ return {
95604
+ serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
95605
+ serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
95606
+ serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
95607
+ serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
95608
+ };
95609
+ function setSerializerContextAnd(serializerContext, cb, node, arg) {
95610
+ var savedCurrentLexicalScope = currentLexicalScope;
95611
+ var savedCurrentNameScope = currentNameScope;
95612
+ currentLexicalScope = serializerContext.currentLexicalScope;
95613
+ currentNameScope = serializerContext.currentNameScope;
95614
+ var result = arg === undefined ? cb(node) : cb(node, arg);
95615
+ currentLexicalScope = savedCurrentLexicalScope;
95616
+ currentNameScope = savedCurrentNameScope;
95617
+ return result;
95618
+ }
95619
+ function getAccessorTypeNode(node) {
95620
+ var accessors = resolver.getAllAccessorDeclarations(node);
95621
+ return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
95622
+ || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
95623
+ }
95624
+ /**
95625
+ * Serializes the type of a node for use with decorator type metadata.
95626
+ * @param node The node that should have its type serialized.
95627
+ */
95628
+ function serializeTypeOfNode(node) {
95629
+ switch (node.kind) {
95630
+ case 167 /* PropertyDeclaration */:
95631
+ case 164 /* Parameter */:
95632
+ return serializeTypeNode(node.type);
95633
+ case 173 /* SetAccessor */:
95634
+ case 172 /* GetAccessor */:
95635
+ return serializeTypeNode(getAccessorTypeNode(node));
95636
+ case 257 /* ClassDeclaration */:
95637
+ case 226 /* ClassExpression */:
95638
+ case 169 /* MethodDeclaration */:
95639
+ return ts.factory.createIdentifier("Function");
95640
+ default:
95641
+ return ts.factory.createVoidZero();
95642
+ }
95643
+ }
95644
+ /**
95645
+ * Serializes the type of a node for use with decorator type metadata.
95646
+ * @param node The node that should have its type serialized.
95647
+ */
95648
+ function serializeParameterTypesOfNode(node, container) {
95649
+ var valueDeclaration = ts.isClassLike(node)
95650
+ ? ts.getFirstConstructorWithBody(node)
95651
+ : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
95652
+ ? node
95653
+ : undefined;
95654
+ var expressions = [];
95655
+ if (valueDeclaration) {
95656
+ var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
95657
+ var numParameters = parameters.length;
95658
+ for (var i = 0; i < numParameters; i++) {
95659
+ var parameter = parameters[i];
95660
+ if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
95661
+ continue;
95662
+ }
95663
+ if (parameter.dotDotDotToken) {
95664
+ expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
95665
+ }
95666
+ else {
95667
+ expressions.push(serializeTypeOfNode(parameter));
95668
+ }
95669
+ }
95670
+ }
95671
+ return ts.factory.createArrayLiteralExpression(expressions);
95672
+ }
95673
+ function getParametersOfDecoratedDeclaration(node, container) {
95674
+ if (container && node.kind === 172 /* GetAccessor */) {
95675
+ var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
95676
+ if (setAccessor) {
95677
+ return setAccessor.parameters;
95678
+ }
95679
+ }
95680
+ return node.parameters;
95681
+ }
95682
+ /**
95683
+ * Serializes the return type of a node for use with decorator type metadata.
95684
+ * @param node The node that should have its return type serialized.
95685
+ */
95686
+ function serializeReturnTypeOfNode(node) {
95687
+ if (ts.isFunctionLike(node) && node.type) {
95688
+ return serializeTypeNode(node.type);
95689
+ }
95690
+ else if (ts.isAsyncFunction(node)) {
95691
+ return ts.factory.createIdentifier("Promise");
95692
+ }
95693
+ return ts.factory.createVoidZero();
95694
+ }
95695
+ /**
95696
+ * Serializes a type node for use with decorator type metadata.
95697
+ *
95698
+ * Types are serialized in the following fashion:
95699
+ * - Void types point to "undefined" (e.g. "void 0")
95700
+ * - Function and Constructor types point to the global "Function" constructor.
95701
+ * - Interface types with a call or construct signature types point to the global
95702
+ * "Function" constructor.
95703
+ * - Array and Tuple types point to the global "Array" constructor.
95704
+ * - Type predicates and booleans point to the global "Boolean" constructor.
95705
+ * - String literal types and strings point to the global "String" constructor.
95706
+ * - Enum and number types point to the global "Number" constructor.
95707
+ * - Symbol types point to the global "Symbol" constructor.
95708
+ * - Type references to classes (or class-like variables) point to the constructor for the class.
95709
+ * - Anything else points to the global "Object" constructor.
95710
+ *
95711
+ * @param node The type node to serialize.
95712
+ */
95713
+ function serializeTypeNode(node) {
95714
+ if (node === undefined) {
95715
+ return ts.factory.createIdentifier("Object");
95716
+ }
95717
+ node = ts.skipTypeParentheses(node);
95718
+ switch (node.kind) {
95719
+ case 114 /* VoidKeyword */:
95720
+ case 153 /* UndefinedKeyword */:
95721
+ case 143 /* NeverKeyword */:
95722
+ return ts.factory.createVoidZero();
95723
+ case 179 /* FunctionType */:
95724
+ case 180 /* ConstructorType */:
95725
+ return ts.factory.createIdentifier("Function");
95726
+ case 183 /* ArrayType */:
95727
+ case 184 /* TupleType */:
95728
+ return ts.factory.createIdentifier("Array");
95729
+ case 177 /* TypePredicate */:
95730
+ return node.assertsModifier ?
95731
+ ts.factory.createVoidZero() :
95732
+ ts.factory.createIdentifier("Boolean");
95733
+ case 133 /* BooleanKeyword */:
95734
+ return ts.factory.createIdentifier("Boolean");
95735
+ case 198 /* TemplateLiteralType */:
95736
+ case 150 /* StringKeyword */:
95737
+ return ts.factory.createIdentifier("String");
95738
+ case 148 /* ObjectKeyword */:
95739
+ return ts.factory.createIdentifier("Object");
95740
+ case 196 /* LiteralType */:
95741
+ return serializeLiteralOfLiteralTypeNode(node.literal);
95742
+ case 147 /* NumberKeyword */:
95743
+ return ts.factory.createIdentifier("Number");
95744
+ case 158 /* BigIntKeyword */:
95745
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95746
+ case 151 /* SymbolKeyword */:
95747
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95748
+ case 178 /* TypeReference */:
95749
+ return serializeTypeReferenceNode(node);
95750
+ case 188 /* IntersectionType */:
95751
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
95752
+ case 187 /* UnionType */:
95753
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
95754
+ case 189 /* ConditionalType */:
95755
+ return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
95756
+ case 193 /* TypeOperator */:
95757
+ if (node.operator === 145 /* ReadonlyKeyword */) {
95758
+ return serializeTypeNode(node.type);
95759
+ }
95760
+ break;
95761
+ case 181 /* TypeQuery */:
95762
+ case 194 /* IndexedAccessType */:
95763
+ case 195 /* MappedType */:
95764
+ case 182 /* TypeLiteral */:
95765
+ case 130 /* AnyKeyword */:
95766
+ case 155 /* UnknownKeyword */:
95767
+ case 192 /* ThisType */:
95768
+ case 200 /* ImportType */:
95769
+ break;
95770
+ // handle JSDoc types from an invalid parse
95771
+ case 312 /* JSDocAllType */:
95772
+ case 313 /* JSDocUnknownType */:
95773
+ case 317 /* JSDocFunctionType */:
95774
+ case 318 /* JSDocVariadicType */:
95775
+ case 319 /* JSDocNamepathType */:
95776
+ break;
95777
+ case 314 /* JSDocNullableType */:
95778
+ case 315 /* JSDocNonNullableType */:
95779
+ case 316 /* JSDocOptionalType */:
95780
+ return serializeTypeNode(node.type);
95781
+ default:
95782
+ return ts.Debug.failBadSyntaxKind(node);
95783
+ }
95784
+ return ts.factory.createIdentifier("Object");
95785
+ }
95786
+ function serializeLiteralOfLiteralTypeNode(node) {
95787
+ switch (node.kind) {
95788
+ case 10 /* StringLiteral */:
95789
+ case 14 /* NoSubstitutionTemplateLiteral */:
95790
+ return ts.factory.createIdentifier("String");
95791
+ case 219 /* PrefixUnaryExpression */: {
95792
+ var operand = node.operand;
95793
+ switch (operand.kind) {
95794
+ case 8 /* NumericLiteral */:
95795
+ case 9 /* BigIntLiteral */:
95796
+ return serializeLiteralOfLiteralTypeNode(operand);
95797
+ default:
95798
+ return ts.Debug.failBadSyntaxKind(operand);
95799
+ }
95800
+ }
95801
+ case 8 /* NumericLiteral */:
95802
+ return ts.factory.createIdentifier("Number");
95803
+ case 9 /* BigIntLiteral */:
95804
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95805
+ case 110 /* TrueKeyword */:
95806
+ case 95 /* FalseKeyword */:
95807
+ return ts.factory.createIdentifier("Boolean");
95808
+ case 104 /* NullKeyword */:
95809
+ return ts.factory.createVoidZero();
95810
+ default:
95811
+ return ts.Debug.failBadSyntaxKind(node);
95812
+ }
95813
+ }
95814
+ function serializeUnionOrIntersectionConstituents(types, isIntersection) {
95815
+ // Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
95816
+ var serializedType;
95817
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
95818
+ var typeNode = types_22[_i];
95819
+ typeNode = ts.skipTypeParentheses(typeNode);
95820
+ if (typeNode.kind === 143 /* NeverKeyword */) {
95821
+ if (isIntersection)
95822
+ return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
95823
+ continue; // Elide `never` in a union
95824
+ }
95825
+ if (typeNode.kind === 155 /* UnknownKeyword */) {
95826
+ if (!isIntersection)
95827
+ return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
95828
+ continue; // Elide `unknown` in an intersection
95829
+ }
95830
+ if (typeNode.kind === 130 /* AnyKeyword */) {
95831
+ return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
95832
+ }
95833
+ if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
95834
+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
95835
+ }
95836
+ var serializedConstituent = serializeTypeNode(typeNode);
95837
+ if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
95838
+ // One of the individual is global object, return immediately
95839
+ return serializedConstituent;
95840
+ }
95841
+ // If there exists union that is not `void 0` expression, check if the the common type is identifier.
95842
+ // anything more complex and we will just default to Object
95843
+ if (serializedType) {
95844
+ // Different types
95845
+ if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
95846
+ return ts.factory.createIdentifier("Object");
95847
+ }
95848
+ }
95849
+ else {
95850
+ // Initialize the union type
95851
+ serializedType = serializedConstituent;
95852
+ }
95853
+ }
95854
+ // If we were able to find common type, use it
95855
+ return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
95856
+ }
95857
+ function equateSerializedTypeNodes(left, right) {
95858
+ return (
95859
+ // temp vars used in fallback
95860
+ ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
95861
+ // entity names
95862
+ ts.isIdentifier(left) ? ts.isIdentifier(right)
95863
+ && left.escapedText === right.escapedText :
95864
+ ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
95865
+ && equateSerializedTypeNodes(left.expression, right.expression)
95866
+ && equateSerializedTypeNodes(left.name, right.name) :
95867
+ // `void 0`
95868
+ ts.isVoidExpression(left) ? ts.isVoidExpression(right)
95869
+ && ts.isNumericLiteral(left.expression) && left.expression.text === "0"
95870
+ && ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
95871
+ // `"undefined"` or `"function"` in `typeof` checks
95872
+ ts.isStringLiteral(left) ? ts.isStringLiteral(right)
95873
+ && left.text === right.text :
95874
+ // used in `typeof` checks for fallback
95875
+ ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
95876
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95877
+ // parens in `typeof` checks with temps
95878
+ ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
95879
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95880
+ // conditionals used in fallback
95881
+ ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
95882
+ && equateSerializedTypeNodes(left.condition, right.condition)
95883
+ && equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
95884
+ && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
95885
+ // logical binary and assignments used in fallback
95886
+ ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
95887
+ && left.operatorToken.kind === right.operatorToken.kind
95888
+ && equateSerializedTypeNodes(left.left, right.left)
95889
+ && equateSerializedTypeNodes(left.right, right.right) :
95890
+ false);
95891
+ }
95892
+ /**
95893
+ * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
95894
+ * @param node The type reference node.
95895
+ */
95896
+ function serializeTypeReferenceNode(node) {
95897
+ var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
95898
+ switch (kind) {
95899
+ case ts.TypeReferenceSerializationKind.Unknown:
95900
+ // From conditional type type reference that cannot be resolved is Similar to any or unknown
95901
+ if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
95902
+ return ts.factory.createIdentifier("Object");
95903
+ }
95904
+ var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
95905
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95906
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
95907
+ /*questionToken*/ undefined, temp,
95908
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95909
+ case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
95910
+ return serializeEntityNameAsExpression(node.typeName);
95911
+ case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
95912
+ return ts.factory.createVoidZero();
95913
+ case ts.TypeReferenceSerializationKind.BigIntLikeType:
95914
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95915
+ case ts.TypeReferenceSerializationKind.BooleanType:
95916
+ return ts.factory.createIdentifier("Boolean");
95917
+ case ts.TypeReferenceSerializationKind.NumberLikeType:
95918
+ return ts.factory.createIdentifier("Number");
95919
+ case ts.TypeReferenceSerializationKind.StringLikeType:
95920
+ return ts.factory.createIdentifier("String");
95921
+ case ts.TypeReferenceSerializationKind.ArrayLikeType:
95922
+ return ts.factory.createIdentifier("Array");
95923
+ case ts.TypeReferenceSerializationKind.ESSymbolType:
95924
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95925
+ case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
95926
+ return ts.factory.createIdentifier("Function");
95927
+ case ts.TypeReferenceSerializationKind.Promise:
95928
+ return ts.factory.createIdentifier("Promise");
95929
+ case ts.TypeReferenceSerializationKind.ObjectType:
95930
+ return ts.factory.createIdentifier("Object");
95931
+ default:
95932
+ return ts.Debug.assertNever(kind);
95933
+ }
95934
+ }
95935
+ /**
95936
+ * Produces an expression that results in `right` if `left` is not undefined at runtime:
95937
+ *
95938
+ * ```
95939
+ * typeof left !== "undefined" && right
95940
+ * ```
95941
+ *
95942
+ * We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
95943
+ * It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
95944
+ * further checked by any containing expression.
95945
+ */
95946
+ function createCheckedValue(left, right) {
95947
+ return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
95948
+ }
95949
+ /**
95950
+ * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
95951
+ * @param node The entity name to serialize.
95952
+ */
95953
+ function serializeEntityNameAsExpressionFallback(node) {
95954
+ if (node.kind === 79 /* Identifier */) {
95955
+ // A -> typeof A !== "undefined" && A
95956
+ var copied = serializeEntityNameAsExpression(node);
95957
+ return createCheckedValue(copied, copied);
95958
+ }
95959
+ if (node.left.kind === 79 /* Identifier */) {
95960
+ // A.B -> typeof A !== "undefined" && A.B
95961
+ return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
95962
+ }
95963
+ // A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
95964
+ var left = serializeEntityNameAsExpressionFallback(node.left);
95965
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95966
+ return ts.factory.createLogicalAnd(ts.factory.createLogicalAnd(left.left, ts.factory.createStrictInequality(ts.factory.createAssignment(temp, left.right), ts.factory.createVoidZero())), ts.factory.createPropertyAccessExpression(temp, node.right));
95967
+ }
95968
+ /**
95969
+ * Serializes an entity name as an expression for decorator type metadata.
95970
+ * @param node The entity name to serialize.
95971
+ */
95972
+ function serializeEntityNameAsExpression(node) {
95973
+ switch (node.kind) {
95974
+ case 79 /* Identifier */:
95975
+ // Create a clone of the name with a new parent, and treat it as if it were
95976
+ // a source tree node for the purposes of the checker.
95977
+ var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
95978
+ name.original = undefined;
95979
+ ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
95980
+ return name;
95981
+ case 161 /* QualifiedName */:
95982
+ return serializeQualifiedNameAsExpression(node);
95983
+ }
95984
+ }
95985
+ /**
95986
+ * Serializes an qualified name as an expression for decorator type metadata.
95987
+ * @param node The qualified name to serialize.
95988
+ */
95989
+ function serializeQualifiedNameAsExpression(node) {
95990
+ return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
95991
+ }
95992
+ function getGlobalConstructorWithFallback(name) {
95993
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
95994
+ /*questionToken*/ undefined, ts.factory.createIdentifier(name),
95995
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95996
+ }
95997
+ function getGlobalConstructor(name, minLanguageVersion) {
95998
+ return languageVersion < minLanguageVersion ?
95999
+ getGlobalConstructorWithFallback(name) :
96000
+ ts.factory.createIdentifier(name);
96001
+ }
96002
+ }
96003
+ ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
96004
+ })(ts || (ts = {}));
96005
+ /*@internal*/
96006
+ var ts;
96007
+ (function (ts) {
96008
+ function transformLegacyDecorators(context) {
96009
+ var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
96010
+ var resolver = context.getEmitResolver();
96011
+ var compilerOptions = context.getCompilerOptions();
96012
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
96013
+ // Save the previous transformation hooks.
96014
+ var previousOnSubstituteNode = context.onSubstituteNode;
96015
+ // Set new transformation hooks.
96016
+ context.onSubstituteNode = onSubstituteNode;
96017
+ /**
96018
+ * A map that keeps track of aliases created for classes with decorators to avoid issues
96019
+ * with the double-binding behavior of classes.
96020
+ */
96021
+ var classAliases;
96022
+ return ts.chainBundle(context, transformSourceFile);
96023
+ function transformSourceFile(node) {
96024
+ var visited = ts.visitEachChild(node, visitor, context);
96025
+ ts.addEmitHelpers(visited, context.readEmitHelpers());
96026
+ return visited;
96027
+ }
96028
+ function visitor(node) {
96029
+ if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
96030
+ return node;
96031
+ }
96032
+ switch (node.kind) {
96033
+ case 165 /* Decorator */:
96034
+ // Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
96035
+ return undefined;
96036
+ case 257 /* ClassDeclaration */:
96037
+ return visitClassDeclaration(node);
96038
+ case 226 /* ClassExpression */:
96039
+ return visitClassExpression(node);
96040
+ case 171 /* Constructor */:
96041
+ return visitConstructorDeclaration(node);
96042
+ case 169 /* MethodDeclaration */:
96043
+ return visitMethodDeclaration(node);
96044
+ case 173 /* SetAccessor */:
96045
+ return visitSetAccessorDeclaration(node);
96046
+ case 172 /* GetAccessor */:
96047
+ return visitGetAccessorDeclaration(node);
96048
+ case 170 /* ClassStaticBlockDeclaration */:
96049
+ return visitClassStaticBlockDeclaration(node);
96050
+ case 167 /* PropertyDeclaration */:
96051
+ return visitPropertyDeclaration(node);
96052
+ case 164 /* Parameter */:
96053
+ return visitParameterDeclaration(node);
96054
+ default:
96055
+ return ts.visitEachChild(node, visitor, context);
96056
+ }
96057
+ }
96058
+ function visitClassDeclaration(node) {
96059
+ if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
96060
+ return ts.visitEachChild(node, visitor, context);
96061
+ var classStatement = ts.some(node.decorators) ?
96062
+ createClassDeclarationHeadWithDecorators(node, node.name) :
96063
+ createClassDeclarationHeadWithoutDecorators(node, node.name);
96064
+ var statements = [classStatement];
96065
+ // Write any decorators of the node.
96066
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
96067
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
96068
+ addConstructorDecorationStatement(statements, node);
96069
+ if (statements.length > 1) {
96070
+ // Add a DeclarationMarker as a marker for the end of the declaration
96071
+ statements.push(factory.createEndOfDeclarationMarker(node));
96072
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
96073
+ }
96074
+ return ts.singleOrMany(statements);
96075
+ }
96076
+ /**
96077
+ * Transforms a non-decorated class declaration.
96078
+ *
96079
+ * @param node A ClassDeclaration node.
96080
+ * @param name The name of the class.
96081
+ */
96082
+ function createClassDeclarationHeadWithoutDecorators(node, name) {
96083
+ // ${modifiers} class ${name} ${heritageClauses} {
96084
+ // ${members}
96085
+ // }
96086
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
96087
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96088
+ }
96089
+ /**
96090
+ * Transforms a decorated class declaration and appends the resulting statements. If
96091
+ * the class requires an alias to avoid issues with double-binding, the alias is returned.
96092
+ */
96093
+ function createClassDeclarationHeadWithDecorators(node, name) {
96094
+ // When we emit an ES6 class that has a class decorator, we must tailor the
96095
+ // emit to certain specific cases.
96096
+ //
96097
+ // In the simplest case, we emit the class declaration as a let declaration, and
96098
+ // evaluate decorators after the close of the class body:
96099
+ //
96100
+ // [Example 1]
96101
+ // ---------------------------------------------------------------------
96102
+ // TypeScript | Javascript
96103
+ // ---------------------------------------------------------------------
96104
+ // @dec | let C = class C {
96105
+ // class C { | }
96106
+ // } | C = __decorate([dec], C);
96107
+ // ---------------------------------------------------------------------
96108
+ // @dec | let C = class C {
96109
+ // export class C { | }
96110
+ // } | C = __decorate([dec], C);
96111
+ // | export { C };
96112
+ // ---------------------------------------------------------------------
96113
+ //
96114
+ // If a class declaration contains a reference to itself *inside* of the class body,
96115
+ // this introduces two bindings to the class: One outside of the class body, and one
96116
+ // inside of the class body. If we apply decorators as in [Example 1] above, there
96117
+ // is the possibility that the decorator `dec` will return a new value for the
96118
+ // constructor, which would result in the binding inside of the class no longer
96119
+ // pointing to the same reference as the binding outside of the class.
96120
+ //
96121
+ // As a result, we must instead rewrite all references to the class *inside* of the
96122
+ // class body to instead point to a local temporary alias for the class:
96123
+ //
96124
+ // [Example 2]
96125
+ // ---------------------------------------------------------------------
96126
+ // TypeScript | Javascript
96127
+ // ---------------------------------------------------------------------
96128
+ // @dec | let C = C_1 = class C {
96129
+ // class C { | static x() { return C_1.y; }
96130
+ // static x() { return C.y; } | }
96131
+ // static y = 1; | C.y = 1;
96132
+ // } | C = C_1 = __decorate([dec], C);
96133
+ // | var C_1;
96134
+ // ---------------------------------------------------------------------
96135
+ // @dec | let C = class C {
96136
+ // export class C { | static x() { return C_1.y; }
96137
+ // static x() { return C.y; } | }
96138
+ // static y = 1; | C.y = 1;
96139
+ // } | C = C_1 = __decorate([dec], C);
96140
+ // | export { C };
96141
+ // | var C_1;
96142
+ // ---------------------------------------------------------------------
96143
+ //
96144
+ // If a class declaration is the default export of a module, we instead emit
96145
+ // the export after the decorated declaration:
96146
+ //
96147
+ // [Example 3]
96148
+ // ---------------------------------------------------------------------
96149
+ // TypeScript | Javascript
96150
+ // ---------------------------------------------------------------------
96151
+ // @dec | let default_1 = class {
96152
+ // export default class { | }
96153
+ // } | default_1 = __decorate([dec], default_1);
96154
+ // | export default default_1;
96155
+ // ---------------------------------------------------------------------
96156
+ // @dec | let C = class C {
96157
+ // export default class C { | }
96158
+ // } | C = __decorate([dec], C);
96159
+ // | export default C;
96160
+ // ---------------------------------------------------------------------
96161
+ //
96162
+ // If the class declaration is the default export and a reference to itself
96163
+ // inside of the class body, we must emit both an alias for the class *and*
96164
+ // move the export after the declaration:
96165
+ //
96166
+ // [Example 4]
96167
+ // ---------------------------------------------------------------------
96168
+ // TypeScript | Javascript
96169
+ // ---------------------------------------------------------------------
96170
+ // @dec | let C = class C {
96171
+ // export default class C { | static x() { return C_1.y; }
96172
+ // static x() { return C.y; } | }
96173
+ // static y = 1; | C.y = 1;
96174
+ // } | C = C_1 = __decorate([dec], C);
96175
+ // | export default C;
96176
+ // | var C_1;
96177
+ // ---------------------------------------------------------------------
96178
+ //
96179
+ var location = ts.moveRangePastModifiers(node);
96180
+ var classAlias = getClassAliasIfNeeded(node);
96181
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96182
+ // without any block-scoped variable collision handling
96183
+ var declName = languageVersion <= 2 /* ES2015 */ ?
96184
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96185
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96186
+ // ... = class ${name} ${heritageClauses} {
96187
+ // ${members}
96188
+ // }
96189
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
96190
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
96191
+ var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
96192
+ ts.setOriginalNode(classExpression, node);
96193
+ ts.setTextRange(classExpression, location);
96194
+ // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
96195
+ // or decoratedClassAlias if the class contain self-reference.
96196
+ var statement = factory.createVariableStatement(
96197
+ /*modifiers*/ undefined, factory.createVariableDeclarationList([
96198
+ factory.createVariableDeclaration(declName,
96199
+ /*exclamationToken*/ undefined,
96200
+ /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
96201
+ ], 1 /* Let */));
96202
+ ts.setOriginalNode(statement, node);
96203
+ ts.setTextRange(statement, location);
96204
+ ts.setCommentRange(statement, node);
96205
+ return statement;
96206
+ }
96207
+ function visitClassExpression(node) {
96208
+ // Legacy decorators were not supported on class expressions
96209
+ return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
96210
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96211
+ }
96212
+ function visitConstructorDeclaration(node) {
96213
+ return factory.updateConstructorDeclaration(node,
96214
+ /*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
96215
+ }
96216
+ function finishClassElement(updated, original) {
96217
+ if (updated !== original) {
96218
+ // While we emit the source map for the node after skipping decorators and modifiers,
96219
+ // we need to emit the comments for the original range.
96220
+ ts.setCommentRange(updated, original);
96221
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
96222
+ }
96223
+ return updated;
96224
+ }
96225
+ function visitMethodDeclaration(node) {
96226
+ return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
96227
+ /*questionToken*/ undefined,
96228
+ /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96229
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96230
+ }
96231
+ function visitGetAccessorDeclaration(node) {
96232
+ return finishClassElement(factory.updateGetAccessorDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96233
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96234
+ }
96235
+ function visitSetAccessorDeclaration(node) {
96236
+ return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node);
96237
+ }
96238
+ function visitClassStaticBlockDeclaration(node) {
96239
+ return factory.updateClassStaticBlockDeclaration(node,
96240
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
96241
+ }
96242
+ function visitPropertyDeclaration(node) {
96243
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
96244
+ return undefined;
96245
+ }
96246
+ return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
96247
+ /*questionOrExclamationToken*/ undefined,
96248
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
96249
+ }
96250
+ function visitParameterDeclaration(node) {
96251
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
96252
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
96253
+ /*questionToken*/ undefined,
96254
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
96255
+ if (updated !== node) {
96256
+ // While we emit the source map for the node after skipping decorators and modifiers,
96257
+ // we need to emit the comments for the original range.
96258
+ ts.setCommentRange(updated, node);
96259
+ ts.setTextRange(updated, ts.moveRangePastModifiers(node));
96260
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
96261
+ ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
96262
+ }
96263
+ return updated;
96264
+ }
96265
+ /**
96266
+ * Transforms all of the decorators for a declaration into an array of expressions.
96267
+ *
96268
+ * @param allDecorators An object containing all of the decorators for the declaration.
96269
+ */
96270
+ function transformAllDecoratorsOfDeclaration(allDecorators) {
96271
+ if (!allDecorators) {
96272
+ return undefined;
96273
+ }
96274
+ var decoratorExpressions = [];
96275
+ ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
96276
+ ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
96277
+ return decoratorExpressions;
96278
+ }
96279
+ /**
96280
+ * Generates statements used to apply decorators to either the static or instance members
96281
+ * of a class.
96282
+ *
96283
+ * @param node The class node.
96284
+ * @param isStatic A value indicating whether to generate statements for static or
96285
+ * instance members.
96286
+ */
96287
+ function addClassElementDecorationStatements(statements, node, isStatic) {
96288
+ ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
96289
+ }
96290
+ /**
96291
+ * Determines whether a class member is either a static or an instance member of a class
96292
+ * that is decorated, or has parameters that are decorated.
96293
+ *
96294
+ * @param member The class member.
96295
+ */
96296
+ function isDecoratedClassElement(member, isStaticElement, parent) {
96297
+ return ts.nodeOrChildIsDecorated(member, parent)
96298
+ && isStaticElement === ts.isStatic(member);
96299
+ }
96300
+ /**
96301
+ * Gets either the static or instance members of a class that are decorated, or have
96302
+ * parameters that are decorated.
96303
+ *
96304
+ * @param node The class containing the member.
96305
+ * @param isStatic A value indicating whether to retrieve static or instance members of
96306
+ * the class.
96307
+ */
96308
+ function getDecoratedClassElements(node, isStatic) {
96309
+ return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
96310
+ }
96311
+ /**
96312
+ * Generates expressions used to apply decorators to either the static or instance members
96313
+ * of a class.
96314
+ *
96315
+ * @param node The class node.
96316
+ * @param isStatic A value indicating whether to generate expressions for static or
96317
+ * instance members.
96318
+ */
96319
+ function generateClassElementDecorationExpressions(node, isStatic) {
96320
+ var members = getDecoratedClassElements(node, isStatic);
96321
+ var expressions;
96322
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
96323
+ var member = members_8[_i];
96324
+ expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
96325
+ }
96326
+ return expressions;
96327
+ }
96328
+ /**
96329
+ * Generates an expression used to evaluate class element decorators at runtime.
96330
+ *
96331
+ * @param node The class node that contains the member.
96332
+ * @param member The class member.
96333
+ */
96334
+ function generateClassElementDecorationExpression(node, member) {
96335
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96336
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96337
+ if (!decoratorExpressions) {
96338
+ return undefined;
96339
+ }
96340
+ // Emit the call to __decorate. Given the following:
96341
+ //
96342
+ // class C {
96343
+ // @dec method(@dec2 x) {}
96344
+ // @dec get accessor() {}
96345
+ // @dec prop;
96346
+ // }
96347
+ //
96348
+ // The emit for a method is:
96349
+ //
96350
+ // __decorate([
96351
+ // dec,
96352
+ // __param(0, dec2),
96353
+ // __metadata("design:type", Function),
96354
+ // __metadata("design:paramtypes", [Object]),
96355
+ // __metadata("design:returntype", void 0)
96356
+ // ], C.prototype, "method", null);
96357
+ //
96358
+ // The emit for an accessor is:
96359
+ //
96360
+ // __decorate([
96361
+ // dec
96362
+ // ], C.prototype, "accessor", null);
96363
+ //
96364
+ // The emit for a property is:
96365
+ //
96366
+ // __decorate([
96367
+ // dec
96368
+ // ], C.prototype, "prop");
96369
+ //
96370
+ var prefix = getClassMemberPrefix(node, member);
96371
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
96372
+ var descriptor = languageVersion > 0 /* ES3 */
96373
+ ? member.kind === 167 /* PropertyDeclaration */
96374
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
96375
+ // should not invoke `Object.getOwnPropertyDescriptor`.
96376
+ ? factory.createVoidZero()
96377
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
96378
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
96379
+ : factory.createNull()
96380
+ : undefined;
96381
+ var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
96382
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96383
+ ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
96384
+ return helper;
96385
+ }
96386
+ /**
96387
+ * Generates a __decorate helper call for a class constructor.
96388
+ *
96389
+ * @param node The class node.
96390
+ */
96391
+ function addConstructorDecorationStatement(statements, node) {
96392
+ var expression = generateConstructorDecorationExpression(node);
96393
+ if (expression) {
96394
+ statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
96395
+ }
96396
+ }
96397
+ /**
96398
+ * Generates a __decorate helper call for a class constructor.
96399
+ *
96400
+ * @param node The class node.
96401
+ */
96402
+ function generateConstructorDecorationExpression(node) {
96403
+ var allDecorators = ts.getAllDecoratorsOfClass(node);
96404
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96405
+ if (!decoratorExpressions) {
96406
+ return undefined;
96407
+ }
96408
+ var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
96409
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96410
+ // without any block-scoped variable collision handling
96411
+ var localName = languageVersion <= 2 /* ES2015 */ ?
96412
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96413
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96414
+ var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
96415
+ var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
96416
+ ts.setEmitFlags(expression, 1536 /* NoComments */);
96417
+ ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
96418
+ return expression;
96419
+ }
96420
+ /**
96421
+ * Transforms a decorator into an expression.
96422
+ *
96423
+ * @param decorator The decorator node.
96424
+ */
96425
+ function transformDecorator(decorator) {
96426
+ return ts.visitNode(decorator.expression, visitor, ts.isExpression);
96427
+ }
96428
+ /**
96429
+ * Transforms the decorators of a parameter.
96430
+ *
96431
+ * @param decorators The decorators for the parameter at the provided offset.
96432
+ * @param parameterOffset The offset of the parameter.
96433
+ */
96434
+ function transformDecoratorsOfParameter(decorators, parameterOffset) {
96435
+ var expressions;
96436
+ if (decorators) {
96437
+ expressions = [];
96438
+ for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
96439
+ var decorator = decorators_1[_i];
96440
+ var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
96441
+ ts.setTextRange(helper, decorator.expression);
96442
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96443
+ expressions.push(helper);
96444
+ }
96445
+ }
96446
+ return expressions;
96447
+ }
96448
+ /**
96449
+ * Gets an expression that represents a property name (for decorated properties or enums).
96450
+ * For a computed property, a name is generated for the node.
96451
+ *
96452
+ * @param member The member whose name should be converted into an expression.
96453
+ */
96454
+ function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
96455
+ var name = member.name;
96456
+ if (ts.isPrivateIdentifier(name)) {
96457
+ return factory.createIdentifier("");
96458
+ }
96459
+ else if (ts.isComputedPropertyName(name)) {
96460
+ return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
96461
+ ? factory.getGeneratedNameForNode(name)
96462
+ : name.expression;
96463
+ }
96464
+ else if (ts.isIdentifier(name)) {
96465
+ return factory.createStringLiteral(ts.idText(name));
96466
+ }
96467
+ else {
96468
+ return factory.cloneNode(name);
96469
+ }
96470
+ }
96471
+ function enableSubstitutionForClassAliases() {
96472
+ if (!classAliases) {
96473
+ // We need to enable substitutions for identifiers. This allows us to
96474
+ // substitute class names inside of a class declaration.
96475
+ context.enableSubstitution(79 /* Identifier */);
96476
+ // Keep track of class aliases.
96477
+ classAliases = [];
96478
+ }
96479
+ }
96480
+ /**
96481
+ * Gets a local alias for a class declaration if it is a decorated class with an internal
96482
+ * reference to the static side of the class. This is necessary to avoid issues with
96483
+ * double-binding semantics for the class name.
96484
+ */
96485
+ function getClassAliasIfNeeded(node) {
96486
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
96487
+ enableSubstitutionForClassAliases();
96488
+ var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
96489
+ classAliases[ts.getOriginalNodeId(node)] = classAlias;
96490
+ hoistVariableDeclaration(classAlias);
96491
+ return classAlias;
96492
+ }
96493
+ }
96494
+ function getClassPrototype(node) {
96495
+ return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
96496
+ }
96497
+ function getClassMemberPrefix(node, member) {
96498
+ return ts.isStatic(member)
96499
+ ? factory.getDeclarationName(node)
96500
+ : getClassPrototype(node);
96501
+ }
96502
+ /**
96503
+ * Hooks node substitutions.
96504
+ *
96505
+ * @param hint A hint as to the intended usage of the node.
96506
+ * @param node The node to substitute.
96507
+ */
96508
+ function onSubstituteNode(hint, node) {
96509
+ node = previousOnSubstituteNode(hint, node);
96510
+ if (hint === 1 /* Expression */) {
96511
+ return substituteExpression(node);
96512
+ }
96513
+ return node;
96514
+ }
96515
+ function substituteExpression(node) {
96516
+ switch (node.kind) {
96517
+ case 79 /* Identifier */:
96518
+ return substituteExpressionIdentifier(node);
96519
+ }
96520
+ return node;
96521
+ }
96522
+ function substituteExpressionIdentifier(node) {
96523
+ var _a;
96524
+ return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
96525
+ }
96526
+ function trySubstituteClassAlias(node) {
96527
+ if (classAliases) {
96528
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
96529
+ // Due to the emit for class decorators, any reference to the class from inside of the class body
96530
+ // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
96531
+ // behavior of class names in ES6.
96532
+ // Also, when emitting statics for class expressions, we must substitute a class alias for
96533
+ // constructor references in static property initializers.
96534
+ var declaration = resolver.getReferencedValueDeclaration(node);
96535
+ if (declaration) {
96536
+ var classAlias = classAliases[declaration.id]; // TODO: GH#18217
96537
+ if (classAlias) {
96538
+ var clone_3 = factory.cloneNode(classAlias);
96539
+ ts.setSourceMapRange(clone_3, node);
96540
+ ts.setCommentRange(clone_3, node);
96541
+ return clone_3;
96542
+ }
96543
+ }
96544
+ }
96545
+ }
96546
+ return undefined;
96547
+ }
96548
+ }
96549
+ ts.transformLegacyDecorators = transformLegacyDecorators;
96550
+ })(ts || (ts = {}));
96551
+ /*@internal*/
96552
+ var ts;
96120
96553
  (function (ts) {
96121
96554
  var ES2017SubstitutionFlags;
96122
96555
  (function (ES2017SubstitutionFlags) {
@@ -96965,7 +97398,7 @@ var ts;
96965
97398
  return objects;
96966
97399
  }
96967
97400
  function visitObjectLiteralExpression(node) {
96968
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97401
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96969
97402
  // spread elements emit like so:
96970
97403
  // non-spread elements are chunked together into object literals, and then all are passed to __assign:
96971
97404
  // { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -97038,7 +97471,7 @@ var ts;
97038
97471
  * expression of an `ExpressionStatement`).
97039
97472
  */
97040
97473
  function visitBinaryExpression(node, expressionResultIsUnused) {
97041
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97474
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97042
97475
  return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
97043
97476
  }
97044
97477
  if (node.operatorToken.kind === 27 /* CommaToken */) {
@@ -97069,7 +97502,7 @@ var ts;
97069
97502
  function visitCatchClause(node) {
97070
97503
  if (node.variableDeclaration &&
97071
97504
  ts.isBindingPattern(node.variableDeclaration.name) &&
97072
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97505
+ node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97073
97506
  var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
97074
97507
  var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
97075
97508
  var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
@@ -97110,7 +97543,7 @@ var ts;
97110
97543
  }
97111
97544
  function visitVariableDeclarationWorker(node, exportedVariableStatement) {
97112
97545
  // If we are here it is because the name contains a binding pattern with a rest somewhere in it.
97113
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97546
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97114
97547
  return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
97115
97548
  /*rval*/ undefined, exportedVariableStatement);
97116
97549
  }
@@ -97129,7 +97562,7 @@ var ts;
97129
97562
  */
97130
97563
  function visitForOfStatement(node, outermostLabeledStatement) {
97131
97564
  var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
97132
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97565
+ if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97133
97566
  node = transformForOfStatementWithObjectRest(node);
97134
97567
  }
97135
97568
  var result = node.awaitModifier ?
@@ -97242,7 +97675,7 @@ var ts;
97242
97675
  /*type*/ undefined,
97243
97676
  /*initializer*/ undefined);
97244
97677
  }
97245
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97678
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97246
97679
  // Binding patterns are converted into a generated name and are
97247
97680
  // evaluated inside the function body.
97248
97681
  return factory.updateParameterDeclaration(node,
@@ -97260,7 +97693,7 @@ var ts;
97260
97693
  if (parameters) {
97261
97694
  parameters.add(parameter);
97262
97695
  }
97263
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97696
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97264
97697
  parameters = new ts.Set();
97265
97698
  }
97266
97699
  }
@@ -97483,7 +97916,7 @@ var ts;
97483
97916
  statements = ts.append(statements, statement);
97484
97917
  }
97485
97918
  }
97486
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97919
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97487
97920
  containsPrecedingObjectRestOrSpread = true;
97488
97921
  var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
97489
97922
  /*doNotRecordTempVariablesInLine*/ false,
@@ -98855,7 +99288,7 @@ var ts;
98855
99288
  && !node.expression;
98856
99289
  }
98857
99290
  function isOrMayContainReturnCompletion(node) {
98858
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
99291
+ return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
98859
99292
  && (ts.isReturnStatement(node)
98860
99293
  || ts.isIfStatement(node)
98861
99294
  || ts.isWithStatement(node)
@@ -99419,7 +99852,7 @@ var ts;
99419
99852
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
99420
99853
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
99421
99854
  if (isDerivedClass || superCallExpression) {
99422
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
99855
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
99423
99856
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
99424
99857
  // following representation:
99425
99858
  //
@@ -99964,7 +100397,7 @@ var ts;
99964
100397
  * @param node An ArrowFunction node.
99965
100398
  */
99966
100399
  function visitArrowFunction(node) {
99967
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100400
+ if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
99968
100401
  hierarchyFacts |= 65536 /* CapturedLexicalThis */;
99969
100402
  }
99970
100403
  var savedConvertedLoopState = convertedLoopState;
@@ -100250,7 +100683,7 @@ var ts;
100250
100683
  * @param node A VariableDeclarationList node.
100251
100684
  */
100252
100685
  function visitVariableDeclarationList(node) {
100253
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
100686
+ if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
100254
100687
  if (node.flags & 3 /* BlockScoped */) {
100255
100688
  enableSubstitutionsForBlockScopedBindings();
100256
100689
  }
@@ -100263,7 +100696,7 @@ var ts;
100263
100696
  ts.setCommentRange(declarationList, node);
100264
100697
  // If the first or last declaration is a binding pattern, we need to modify
100265
100698
  // the source map range for the declaration list.
100266
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
100699
+ if (node.transformFlags & 524288 /* ContainsBindingPattern */
100267
100700
  && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
100268
100701
  ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
100269
100702
  }
@@ -100587,7 +101020,7 @@ var ts;
100587
101020
  var numInitialProperties = -1, hasComputed = false;
100588
101021
  for (var i = 0; i < properties.length; i++) {
100589
101022
  var property = properties[i];
100590
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
101023
+ if ((property.transformFlags & 1048576 /* ContainsYield */ &&
100591
101024
  hierarchyFacts & 4 /* AsyncFunctionBody */)
100592
101025
  || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
100593
101026
  numInitialProperties = i;
@@ -100860,7 +101293,7 @@ var ts;
100860
101293
  */
100861
101294
  function createFunctionForInitializerOfForStatement(node, currentState) {
100862
101295
  var functionName = factory.createUniqueName("_loop_init");
100863
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
101296
+ var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
100864
101297
  var emitFlags = 0 /* None */;
100865
101298
  if (currentState.containsLexicalThis)
100866
101299
  emitFlags |= 8 /* CapturesThis */;
@@ -100975,7 +101408,7 @@ var ts;
100975
101408
  var loopBody = factory.createBlock(statements, /*multiLine*/ true);
100976
101409
  if (ts.isBlock(statement))
100977
101410
  ts.setOriginalNode(loopBody, statement);
100978
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
101411
+ var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
100979
101412
  var emitFlags = 524288 /* ReuseTempVariableScope */;
100980
101413
  if (currentState.containsLexicalThis)
100981
101414
  emitFlags |= 8 /* CapturesThis */;
@@ -101457,7 +101890,7 @@ var ts;
101457
101890
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
101458
101891
  // We are here either because SuperKeyword was used somewhere in the expression, or
101459
101892
  // because we contain a SpreadElementExpression.
101460
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
101893
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
101461
101894
  node.expression.kind === 106 /* SuperKeyword */ ||
101462
101895
  ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
101463
101896
  var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
@@ -101465,7 +101898,7 @@ var ts;
101465
101898
  ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
101466
101899
  }
101467
101900
  var resultingCall = void 0;
101468
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
101901
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
101469
101902
  // [source]
101470
101903
  // f(...a, b)
101471
101904
  // x.m(...a, b)
@@ -102307,10 +102740,10 @@ var ts;
102307
102740
  case 247 /* ReturnStatement */:
102308
102741
  return visitReturnStatement(node);
102309
102742
  default:
102310
- if (node.transformFlags & 524288 /* ContainsYield */) {
102743
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102311
102744
  return visitJavaScriptContainingYield(node);
102312
102745
  }
102313
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
102746
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
102314
102747
  return ts.visitEachChild(node, visitor, context);
102315
102748
  }
102316
102749
  else {
@@ -102515,7 +102948,7 @@ var ts;
102515
102948
  * @param node The node to visit.
102516
102949
  */
102517
102950
  function visitVariableStatement(node) {
102518
- if (node.transformFlags & 524288 /* ContainsYield */) {
102951
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102519
102952
  transformAndEmitVariableDeclarationList(node.declarationList);
102520
102953
  return undefined;
102521
102954
  }
@@ -103573,7 +104006,7 @@ var ts;
103573
104006
  }
103574
104007
  }
103575
104008
  function containsYield(node) {
103576
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
104009
+ return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
103577
104010
  }
103578
104011
  function countInitialNodesWithoutYield(nodes) {
103579
104012
  var numNodes = nodes.length;
@@ -104622,7 +105055,7 @@ var ts;
104622
105055
  function transformSourceFile(node) {
104623
105056
  if (node.isDeclarationFile ||
104624
105057
  !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104625
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
105058
+ node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
104626
105059
  (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104627
105060
  return node;
104628
105061
  }
@@ -104959,7 +105392,7 @@ var ts;
104959
105392
  function visitorWorker(node, valueIsDiscarded) {
104960
105393
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
104961
105394
  // as export/import statements are only transformed at the top level of a file.
104962
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
105395
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
104963
105396
  return node;
104964
105397
  }
104965
105398
  switch (node.kind) {
@@ -105110,7 +105543,7 @@ var ts;
105110
105543
  var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
105111
105544
  // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output.
105112
105545
  var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
105113
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
105546
+ var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
105114
105547
  switch (compilerOptions.module) {
105115
105548
  case ts.ModuleKind.AMD:
105116
105549
  return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -106097,7 +106530,7 @@ var ts;
106097
106530
  * @param node The SourceFile node.
106098
106531
  */
106099
106532
  function transformSourceFile(node) {
106100
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
106533
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
106101
106534
  return node;
106102
106535
  }
106103
106536
  var id = ts.getOriginalNodeId(node);
@@ -106266,7 +106699,7 @@ var ts;
106266
106699
  // - Temporary variables will appear at the top rather than at the bottom of the file
106267
106700
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
106268
106701
  var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
106269
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
106702
+ var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
106270
106703
  factory.createModifiersFromModifierFlags(256 /* Async */) :
106271
106704
  undefined;
106272
106705
  var moduleObject = factory.createObjectLiteralExpression([
@@ -107175,7 +107608,7 @@ var ts;
107175
107608
  * @param node The node to visit.
107176
107609
  */
107177
107610
  function visitorWorker(node, valueIsDiscarded) {
107178
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
107611
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
107179
107612
  return node;
107180
107613
  }
107181
107614
  switch (node.kind) {
@@ -108343,7 +108776,8 @@ var ts;
108343
108776
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108344
108777
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108345
108778
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108346
- reportNonSerializableProperty: reportNonSerializableProperty
108779
+ reportNonSerializableProperty: reportNonSerializableProperty,
108780
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108347
108781
  };
108348
108782
  var errorNameNode;
108349
108783
  var errorFallbackNode;
@@ -108470,6 +108904,11 @@ var ts;
108470
108904
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108471
108905
  }
108472
108906
  }
108907
+ function reportImportTypeNodeResolutionModeOverride() {
108908
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108909
+ context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
108910
+ }
108911
+ }
108473
108912
  function transformDeclarationsForJS(sourceFile, bundled) {
108474
108913
  var oldDiag = getSymbolAccessibilityDiagnostic;
108475
108914
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108920,7 +109359,7 @@ var ts;
108920
109359
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108921
109360
  if (mode !== undefined) {
108922
109361
  if (!ts.isNightly()) {
108923
- context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
109362
+ context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
108924
109363
  }
108925
109364
  return assertClause;
108926
109365
  }
@@ -109712,6 +110151,7 @@ var ts;
109712
110151
  var transformers = [];
109713
110152
  ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
109714
110153
  transformers.push(ts.transformTypeScript);
110154
+ transformers.push(ts.transformLegacyDecorators);
109715
110155
  transformers.push(ts.transformClassFields);
109716
110156
  if (ts.getJSXTransformEnabled(compilerOptions)) {
109717
110157
  transformers.push(ts.transformJsx);
@@ -116429,12 +116869,14 @@ var ts;
116429
116869
  }
116430
116870
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116431
116871
  ;
116432
- /* @internal */
116872
+ /**
116873
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116874
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116875
+ */
116433
116876
  function getModeForFileReference(ref, containingFileMode) {
116434
116877
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116435
116878
  }
116436
116879
  ts.getModeForFileReference = getModeForFileReference;
116437
- /* @internal */
116438
116880
  function getModeForResolutionAtIndex(file, index) {
116439
116881
  if (file.impliedNodeFormat === undefined)
116440
116882
  return undefined;
@@ -116455,7 +116897,15 @@ var ts;
116455
116897
  return false;
116456
116898
  }
116457
116899
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116458
- /* @internal */
116900
+ /**
116901
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116902
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116903
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116904
+ * `moduleResolution` is `node16`+.
116905
+ * @param file The file the import or import-like reference is contained within
116906
+ * @param usage The module reference string
116907
+ * @returns The final resolution mode of the import
116908
+ */
116459
116909
  function getModeForUsageLocation(file, usage) {
116460
116910
  var _a, _b;
116461
116911
  if (file.impliedNodeFormat === undefined)
@@ -118691,7 +119141,7 @@ var ts;
118691
119141
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118692
119142
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118693
119143
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118694
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
119144
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118695
119145
  }
118696
119146
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118697
119147
  }
@@ -126001,7 +126451,7 @@ var ts;
126001
126451
  * @param typeAcquisition is used to customize the typing acquisition process
126002
126452
  * @param compilerOptions are used as a source for typing inference
126003
126453
  */
126004
- function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
126454
+ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
126005
126455
  if (!typeAcquisition || !typeAcquisition.enable) {
126006
126456
  return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
126007
126457
  }
@@ -126019,12 +126469,14 @@ var ts;
126019
126469
  addInferredTypings(typeAcquisition.include, "Explicitly included types");
126020
126470
  var exclude = typeAcquisition.exclude || [];
126021
126471
  // Directories to search for package.json, bower.json and other typing information
126022
- var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
126023
- possibleSearchDirs.add(projectRootPath);
126024
- possibleSearchDirs.forEach(function (searchDir) {
126025
- getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
126026
- getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
126027
- });
126472
+ if (!compilerOptions.types) {
126473
+ var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
126474
+ possibleSearchDirs.add(projectRootPath);
126475
+ possibleSearchDirs.forEach(function (searchDir) {
126476
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
126477
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
126478
+ });
126479
+ }
126028
126480
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
126029
126481
  getTypingNamesFromSourceFileNames(fileNames);
126030
126482
  }
@@ -168023,7 +168475,7 @@ var ts;
168023
168475
  if (_this.safeList === undefined) {
168024
168476
  _this.safeList = ts.JsTyping.loadSafeList(_this.host, ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
168025
168477
  }
168026
- return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry);
168478
+ return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry, ts.emptyOptions);
168027
168479
  });
168028
168480
  };
168029
168481
  return CoreServicesShimObject;