typescript 4.8.0-dev.20220601 → 4.8.0-dev.20220604

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220601";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220604";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -5561,21 +5561,22 @@ var ts;
5561
5561
  TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5562
5562
  // Markers
5563
5563
  // - Flags used to indicate that a subtree contains a specific transformation.
5564
- TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
5565
- TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis";
5566
- TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread";
5567
- TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread";
5568
- TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName";
5569
- TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding";
5570
- TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern";
5571
- TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield";
5572
- TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait";
5573
- TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion";
5574
- TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport";
5575
- TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields";
5576
- TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait";
5577
- TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper";
5578
- TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier";
5564
+ TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
5565
+ TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
5566
+ TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
5567
+ TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
5568
+ TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
5569
+ TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
5570
+ TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
5571
+ TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
5572
+ TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
5573
+ TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
5574
+ TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
5575
+ TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
5576
+ TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
5577
+ TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5578
+ TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5579
+ TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5579
5580
  // Please leave this as 1 << 29.
5580
5581
  // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5581
5582
  // It is a good reminder of how much room we have left
@@ -5601,24 +5602,24 @@ var ts;
5601
5602
  TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5602
5603
  TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5603
5604
  TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5604
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes";
5605
- TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes";
5606
- TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes";
5607
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes";
5608
- TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes";
5609
- TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes";
5610
- TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes";
5605
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5606
+ TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5607
+ TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5608
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5609
+ TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5610
+ TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5611
+ TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5611
5612
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5612
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes";
5613
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes";
5614
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes";
5613
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5614
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5615
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5615
5616
  TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5616
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes";
5617
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes";
5618
- TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper";
5617
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5618
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5619
+ TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5619
5620
  // Propagating flags
5620
5621
  // - Bitmasks for flags that should propagate from a child
5621
- TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags";
5622
+ TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
5622
5623
  // Masks
5623
5624
  // - Additional bitmasks
5624
5625
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
@@ -8191,6 +8192,7 @@ var ts;
8191
8192
  Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
8192
8193
  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."),
8193
8194
  _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."),
8195
+ 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}()'?"),
8194
8196
  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."),
8195
8197
  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."),
8196
8198
  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."),
@@ -8387,7 +8389,7 @@ var ts;
8387
8389
  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."),
8388
8390
  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"),
8389
8391
  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"),
8390
- 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`."),
8392
+ 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`."),
8391
8393
  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`."),
8392
8394
  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."),
8393
8395
  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."),
@@ -8895,6 +8897,7 @@ var ts;
8895
8897
  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."),
8896
8898
  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."),
8897
8899
  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"),
8900
+ 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'."),
8898
8901
  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}'."),
8899
8902
  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}'."),
8900
8903
  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}'."),
@@ -9002,7 +9005,7 @@ var ts;
9002
9005
  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}'."),
9003
9006
  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}'?"),
9004
9007
  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'."),
9005
- 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'."),
9008
+ 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'."),
9006
9009
  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."),
9007
9010
  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."),
9008
9011
  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}'."),
@@ -16043,6 +16046,8 @@ var ts;
16043
16046
  case 218 /* AwaitExpression */:
16044
16047
  case 231 /* MetaProperty */:
16045
16048
  return true;
16049
+ case 228 /* ExpressionWithTypeArguments */:
16050
+ return !ts.isHeritageClause(node.parent);
16046
16051
  case 161 /* QualifiedName */:
16047
16052
  while (node.parent.kind === 161 /* QualifiedName */) {
16048
16053
  node = node.parent;
@@ -16986,6 +16991,12 @@ var ts;
16986
16991
  return [child, node];
16987
16992
  }
16988
16993
  ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
16994
+ function skipTypeParentheses(node) {
16995
+ while (ts.isParenthesizedTypeNode(node))
16996
+ node = node.type;
16997
+ return node;
16998
+ }
16999
+ ts.skipTypeParentheses = skipTypeParentheses;
16989
17000
  function skipParentheses(node, excludeJSDocTypeAssertions) {
16990
17001
  var flags = excludeJSDocTypeAssertions ?
16991
17002
  1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
@@ -19220,7 +19231,7 @@ var ts;
19220
19231
  * Moves the start position of a range past any decorators.
19221
19232
  */
19222
19233
  function moveRangePastDecorators(node) {
19223
- return node.decorators && node.decorators.length > 0
19234
+ return node.decorators && !positionIsSynthesized(node.decorators.end)
19224
19235
  ? moveRangePos(node, node.decorators.end)
19225
19236
  : node;
19226
19237
  }
@@ -19229,7 +19240,7 @@ var ts;
19229
19240
  * Moves the start position of a range past any decorators or modifiers.
19230
19241
  */
19231
19242
  function moveRangePastModifiers(node) {
19232
- return node.modifiers && node.modifiers.length > 0
19243
+ return node.modifiers && !positionIsSynthesized(node.modifiers.end)
19233
19244
  ? moveRangePos(node, node.modifiers.end)
19234
19245
  : moveRangePastDecorators(node);
19235
19246
  }
@@ -22659,7 +22670,7 @@ var ts;
22659
22670
  function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
22660
22671
  var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
22661
22672
  node.body = body;
22662
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
22673
+ node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
22663
22674
  if (!body)
22664
22675
  node.transformFlags |= 1 /* ContainsTypeScript */;
22665
22676
  return node;
@@ -22787,7 +22798,7 @@ var ts;
22787
22798
  node.typeArguments = createNodeArray(typeArguments);
22788
22799
  }
22789
22800
  if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
22790
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
22801
+ node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
22791
22802
  }
22792
22803
  return node;
22793
22804
  }
@@ -22839,7 +22850,7 @@ var ts;
22839
22850
  ts.Debug.fail("First character of private identifier must be #: " + text);
22840
22851
  var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
22841
22852
  node.escapedText = ts.escapeLeadingUnderscores(text);
22842
- node.transformFlags |= 8388608 /* ContainsClassFields */;
22853
+ node.transformFlags |= 16777216 /* ContainsClassFields */;
22843
22854
  return node;
22844
22855
  }
22845
22856
  //
@@ -22886,14 +22897,14 @@ var ts;
22886
22897
  transformFlags = 1 /* ContainsTypeScript */;
22887
22898
  break;
22888
22899
  case 106 /* SuperKeyword */:
22889
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
22900
+ transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
22890
22901
  break;
22891
22902
  case 124 /* StaticKeyword */:
22892
22903
  transformFlags = 1024 /* ContainsES2015 */;
22893
22904
  break;
22894
22905
  case 108 /* ThisKeyword */:
22895
22906
  // 'this' indicates a lexical 'this'
22896
- transformFlags = 8192 /* ContainsLexicalThis */;
22907
+ transformFlags = 16384 /* ContainsLexicalThis */;
22897
22908
  break;
22898
22909
  }
22899
22910
  if (transformFlags) {
@@ -22991,7 +23002,7 @@ var ts;
22991
23002
  node.transformFlags |=
22992
23003
  propagateChildFlags(node.expression) |
22993
23004
  1024 /* ContainsES2015 */ |
22994
- 65536 /* ContainsComputedPropertyName */;
23005
+ 131072 /* ContainsComputedPropertyName */;
22995
23006
  return node;
22996
23007
  }
22997
23008
  // @api
@@ -23057,7 +23068,7 @@ var ts;
23057
23068
  if (questionToken)
23058
23069
  node.transformFlags |= 1 /* ContainsTypeScript */;
23059
23070
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
23060
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23071
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23061
23072
  if (initializer || dotDotDotToken)
23062
23073
  node.transformFlags |= 1024 /* ContainsES2015 */;
23063
23074
  }
@@ -23082,7 +23093,8 @@ var ts;
23082
23093
  node.transformFlags |=
23083
23094
  propagateChildFlags(node.expression) |
23084
23095
  1 /* ContainsTypeScript */ |
23085
- 4096 /* ContainsTypeScriptClassSyntax */;
23096
+ 8192 /* ContainsTypeScriptClassSyntax */ |
23097
+ 33554432 /* ContainsDecorators */;
23086
23098
  return node;
23087
23099
  }
23088
23100
  // @api
@@ -23120,9 +23132,9 @@ var ts;
23120
23132
  node.transformFlags |=
23121
23133
  propagateChildFlags(node.questionToken) |
23122
23134
  propagateChildFlags(node.exclamationToken) |
23123
- 8388608 /* ContainsClassFields */;
23135
+ 16777216 /* ContainsClassFields */;
23124
23136
  if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
23125
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23137
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23126
23138
  }
23127
23139
  if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
23128
23140
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -23205,7 +23217,7 @@ var ts;
23205
23217
  /*name*/ undefined,
23206
23218
  /*typeParameters*/ undefined);
23207
23219
  node.body = body;
23208
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
23220
+ node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
23209
23221
  return node;
23210
23222
  }
23211
23223
  // @api
@@ -23729,11 +23741,11 @@ var ts;
23729
23741
  node.transformFlags |=
23730
23742
  propagateChildrenFlags(node.elements) |
23731
23743
  1024 /* ContainsES2015 */ |
23732
- 262144 /* ContainsBindingPattern */;
23733
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
23744
+ 524288 /* ContainsBindingPattern */;
23745
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
23734
23746
  node.transformFlags |=
23735
23747
  128 /* ContainsES2018 */ |
23736
- 32768 /* ContainsObjectRestOrSpread */;
23748
+ 65536 /* ContainsObjectRestOrSpread */;
23737
23749
  }
23738
23750
  return node;
23739
23751
  }
@@ -23750,7 +23762,7 @@ var ts;
23750
23762
  node.transformFlags |=
23751
23763
  propagateChildrenFlags(node.elements) |
23752
23764
  1024 /* ContainsES2015 */ |
23753
- 262144 /* ContainsBindingPattern */;
23765
+ 524288 /* ContainsBindingPattern */;
23754
23766
  return node;
23755
23767
  }
23756
23768
  // @api
@@ -23775,7 +23787,7 @@ var ts;
23775
23787
  propagateChildFlags(node.propertyName);
23776
23788
  }
23777
23789
  if (dotDotDotToken)
23778
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
23790
+ node.transformFlags |= 32768 /* ContainsRestOrSpread */;
23779
23791
  return node;
23780
23792
  }
23781
23793
  // @api
@@ -23950,10 +23962,10 @@ var ts;
23950
23962
  node.transformFlags |= 1 /* ContainsTypeScript */;
23951
23963
  }
23952
23964
  if (ts.isImportKeyword(node.expression)) {
23953
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
23965
+ node.transformFlags |= 8388608 /* ContainsDynamicImport */;
23954
23966
  }
23955
23967
  else if (ts.isSuperProperty(node.expression)) {
23956
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
23968
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
23957
23969
  }
23958
23970
  return node;
23959
23971
  }
@@ -23986,7 +23998,7 @@ var ts;
23986
23998
  node.transformFlags |= 1 /* ContainsTypeScript */;
23987
23999
  }
23988
24000
  if (ts.isSuperProperty(node.expression)) {
23989
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24001
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
23990
24002
  }
23991
24003
  return node;
23992
24004
  }
@@ -24126,7 +24138,7 @@ var ts;
24126
24138
  propagateChildFlags(node.equalsGreaterThanToken) |
24127
24139
  1024 /* ContainsES2015 */;
24128
24140
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24129
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
24141
+ node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
24130
24142
  }
24131
24143
  return node;
24132
24144
  }
@@ -24188,7 +24200,7 @@ var ts;
24188
24200
  propagateChildFlags(node.expression) |
24189
24201
  256 /* ContainsES2017 */ |
24190
24202
  128 /* ContainsES2018 */ |
24191
- 1048576 /* ContainsAwait */;
24203
+ 2097152 /* ContainsAwait */;
24192
24204
  return node;
24193
24205
  }
24194
24206
  // @api
@@ -24209,7 +24221,7 @@ var ts;
24209
24221
  ts.isIdentifier(node.operand) &&
24210
24222
  !ts.isGeneratedIdentifier(node.operand) &&
24211
24223
  !ts.isLocalName(node.operand)) {
24212
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24224
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24213
24225
  }
24214
24226
  return node;
24215
24227
  }
@@ -24230,7 +24242,7 @@ var ts;
24230
24242
  if (ts.isIdentifier(node.operand) &&
24231
24243
  !ts.isGeneratedIdentifier(node.operand) &&
24232
24244
  !ts.isLocalName(node.operand)) {
24233
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24245
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24234
24246
  }
24235
24247
  return node;
24236
24248
  }
@@ -24279,8 +24291,8 @@ var ts;
24279
24291
  return node;
24280
24292
  }
24281
24293
  function propagateAssignmentPatternFlags(node) {
24282
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
24283
- return 32768 /* ContainsObjectRestOrSpread */;
24294
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
24295
+ return 65536 /* ContainsObjectRestOrSpread */;
24284
24296
  if (node.transformFlags & 128 /* ContainsES2018 */) {
24285
24297
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
24286
24298
  // will not be correctly interpreted by the ES2018 transformer
@@ -24288,8 +24300,8 @@ var ts;
24288
24300
  var element = _a[_i];
24289
24301
  var target = ts.getTargetOfBindingOrAssignmentElement(element);
24290
24302
  if (target && ts.isAssignmentPattern(target)) {
24291
- if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
24292
- return 32768 /* ContainsObjectRestOrSpread */;
24303
+ if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
24304
+ return 65536 /* ContainsObjectRestOrSpread */;
24293
24305
  }
24294
24306
  if (target.transformFlags & 128 /* ContainsES2018 */) {
24295
24307
  var flags_1 = propagateAssignmentPatternFlags(target);
@@ -24415,7 +24427,7 @@ var ts;
24415
24427
  propagateChildFlags(node.asteriskToken) |
24416
24428
  1024 /* ContainsES2015 */ |
24417
24429
  128 /* ContainsES2018 */ |
24418
- 524288 /* ContainsYield */;
24430
+ 1048576 /* ContainsYield */;
24419
24431
  return node;
24420
24432
  }
24421
24433
  // @api
@@ -24432,7 +24444,7 @@ var ts;
24432
24444
  node.transformFlags |=
24433
24445
  propagateChildFlags(node.expression) |
24434
24446
  1024 /* ContainsES2015 */ |
24435
- 16384 /* ContainsRestOrSpread */;
24447
+ 32768 /* ContainsRestOrSpread */;
24436
24448
  return node;
24437
24449
  }
24438
24450
  // @api
@@ -24765,7 +24777,7 @@ var ts;
24765
24777
  node.label = asName(label);
24766
24778
  node.transformFlags |=
24767
24779
  propagateChildFlags(node.label) |
24768
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24780
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24769
24781
  return node;
24770
24782
  }
24771
24783
  // @api
@@ -24780,7 +24792,7 @@ var ts;
24780
24792
  node.label = asName(label);
24781
24793
  node.transformFlags |=
24782
24794
  propagateChildFlags(node.label) |
24783
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24795
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24784
24796
  return node;
24785
24797
  }
24786
24798
  // @api
@@ -24797,7 +24809,7 @@ var ts;
24797
24809
  node.transformFlags |=
24798
24810
  propagateChildFlags(node.expression) |
24799
24811
  128 /* ContainsES2018 */ |
24800
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24812
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24801
24813
  return node;
24802
24814
  }
24803
24815
  // @api
@@ -24923,11 +24935,11 @@ var ts;
24923
24935
  node.declarations = createNodeArray(declarations);
24924
24936
  node.transformFlags |=
24925
24937
  propagateChildrenFlags(node.declarations) |
24926
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24938
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24927
24939
  if (flags & 3 /* BlockScoped */) {
24928
24940
  node.transformFlags |=
24929
24941
  1024 /* ContainsES2015 */ |
24930
- 131072 /* ContainsBlockScopedBinding */;
24942
+ 262144 /* ContainsBlockScopedBinding */;
24931
24943
  }
24932
24944
  return node;
24933
24945
  }
@@ -24947,7 +24959,7 @@ var ts;
24947
24959
  else {
24948
24960
  node.transformFlags |=
24949
24961
  propagateChildFlags(node.asteriskToken) |
24950
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24962
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24951
24963
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24952
24964
  if (node.asteriskToken) {
24953
24965
  node.transformFlags |= 128 /* ContainsES2018 */;
@@ -24983,7 +24995,7 @@ var ts;
24983
24995
  }
24984
24996
  else {
24985
24997
  node.transformFlags |= 1024 /* ContainsES2015 */;
24986
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
24998
+ if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
24987
24999
  node.transformFlags |= 1 /* ContainsTypeScript */;
24988
25000
  }
24989
25001
  }
@@ -25042,7 +25054,7 @@ var ts;
25042
25054
  node.transformFlags |=
25043
25055
  propagateChildrenFlags(node.members) |
25044
25056
  1 /* ContainsTypeScript */;
25045
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25057
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25046
25058
  return node;
25047
25059
  }
25048
25060
  // @api
@@ -25070,7 +25082,7 @@ var ts;
25070
25082
  propagateChildFlags(node.body) |
25071
25083
  1 /* ContainsTypeScript */;
25072
25084
  }
25073
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25085
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25074
25086
  return node;
25075
25087
  }
25076
25088
  // @api
@@ -25130,7 +25142,7 @@ var ts;
25130
25142
  node.transformFlags |= propagateChildFlags(node.moduleReference);
25131
25143
  if (!ts.isExternalModuleReference(node.moduleReference))
25132
25144
  node.transformFlags |= 1 /* ContainsTypeScript */;
25133
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25145
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25134
25146
  return node;
25135
25147
  }
25136
25148
  // @api
@@ -25152,7 +25164,7 @@ var ts;
25152
25164
  node.transformFlags |=
25153
25165
  propagateChildFlags(node.importClause) |
25154
25166
  propagateChildFlags(node.moduleSpecifier);
25155
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25167
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25156
25168
  return node;
25157
25169
  }
25158
25170
  // @api
@@ -25177,7 +25189,7 @@ var ts;
25177
25189
  if (isTypeOnly) {
25178
25190
  node.transformFlags |= 1 /* ContainsTypeScript */;
25179
25191
  }
25180
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25192
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25181
25193
  return node;
25182
25194
  }
25183
25195
  // @api
@@ -25237,7 +25249,7 @@ var ts;
25237
25249
  var node = createBaseNode(268 /* NamespaceImport */);
25238
25250
  node.name = name;
25239
25251
  node.transformFlags |= propagateChildFlags(node.name);
25240
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25252
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25241
25253
  return node;
25242
25254
  }
25243
25255
  // @api
@@ -25253,7 +25265,7 @@ var ts;
25253
25265
  node.transformFlags |=
25254
25266
  propagateChildFlags(node.name) |
25255
25267
  4 /* ContainsESNext */;
25256
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25268
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25257
25269
  return node;
25258
25270
  }
25259
25271
  // @api
@@ -25267,7 +25279,7 @@ var ts;
25267
25279
  var node = createBaseNode(269 /* NamedImports */);
25268
25280
  node.elements = createNodeArray(elements);
25269
25281
  node.transformFlags |= propagateChildrenFlags(node.elements);
25270
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25282
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25271
25283
  return node;
25272
25284
  }
25273
25285
  // @api
@@ -25285,7 +25297,7 @@ var ts;
25285
25297
  node.transformFlags |=
25286
25298
  propagateChildFlags(node.propertyName) |
25287
25299
  propagateChildFlags(node.name);
25288
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25300
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25289
25301
  return node;
25290
25302
  }
25291
25303
  // @api
@@ -25304,7 +25316,7 @@ var ts;
25304
25316
  ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
25305
25317
  : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
25306
25318
  node.transformFlags |= propagateChildFlags(node.expression);
25307
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25319
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25308
25320
  return node;
25309
25321
  }
25310
25322
  // @api
@@ -25325,7 +25337,7 @@ var ts;
25325
25337
  node.transformFlags |=
25326
25338
  propagateChildFlags(node.exportClause) |
25327
25339
  propagateChildFlags(node.moduleSpecifier);
25328
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25340
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25329
25341
  return node;
25330
25342
  }
25331
25343
  // @api
@@ -25344,7 +25356,7 @@ var ts;
25344
25356
  var node = createBaseNode(273 /* NamedExports */);
25345
25357
  node.elements = createNodeArray(elements);
25346
25358
  node.transformFlags |= propagateChildrenFlags(node.elements);
25347
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25359
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25348
25360
  return node;
25349
25361
  }
25350
25362
  // @api
@@ -25362,7 +25374,7 @@ var ts;
25362
25374
  node.transformFlags |=
25363
25375
  propagateChildFlags(node.propertyName) |
25364
25376
  propagateChildFlags(node.name);
25365
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25377
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25366
25378
  return node;
25367
25379
  }
25368
25380
  // @api
@@ -25388,7 +25400,7 @@ var ts;
25388
25400
  var node = createBaseNode(277 /* ExternalModuleReference */);
25389
25401
  node.expression = expression;
25390
25402
  node.transformFlags |= propagateChildFlags(node.expression);
25391
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25403
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25392
25404
  return node;
25393
25405
  }
25394
25406
  // @api
@@ -26162,7 +26174,7 @@ var ts;
26162
26174
  node.transformFlags |=
26163
26175
  propagateChildFlags(node.expression) |
26164
26176
  128 /* ContainsES2018 */ |
26165
- 32768 /* ContainsObjectRestOrSpread */;
26177
+ 65536 /* ContainsObjectRestOrSpread */;
26166
26178
  return node;
26167
26179
  }
26168
26180
  // @api
@@ -27119,10 +27131,10 @@ var ts;
27119
27131
  }
27120
27132
  function propagateIdentifierNameFlags(node) {
27121
27133
  // An IdentifierName is allowed to be `await`
27122
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
27134
+ return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
27123
27135
  }
27124
27136
  function propagatePropertyNameFlagsOfChild(node, transformFlags) {
27125
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
27137
+ return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
27126
27138
  }
27127
27139
  function propagateChildFlags(child) {
27128
27140
  if (!child)
@@ -27153,29 +27165,29 @@ var ts;
27153
27165
  case 208 /* CallExpression */:
27154
27166
  case 209 /* NewExpression */:
27155
27167
  case 204 /* ArrayLiteralExpression */:
27156
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
27168
+ return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27157
27169
  case 261 /* ModuleDeclaration */:
27158
- return 589443072 /* ModuleExcludes */;
27170
+ return 742678528 /* ModuleExcludes */;
27159
27171
  case 164 /* Parameter */:
27160
27172
  return 536870912 /* ParameterExcludes */;
27161
27173
  case 214 /* ArrowFunction */:
27162
- return 557748224 /* ArrowFunctionExcludes */;
27174
+ return 612179968 /* ArrowFunctionExcludes */;
27163
27175
  case 213 /* FunctionExpression */:
27164
27176
  case 256 /* FunctionDeclaration */:
27165
- return 591310848 /* FunctionExcludes */;
27177
+ return 746414080 /* FunctionExcludes */;
27166
27178
  case 255 /* VariableDeclarationList */:
27167
- return 537165824 /* VariableDeclarationListExcludes */;
27179
+ return 537460736 /* VariableDeclarationListExcludes */;
27168
27180
  case 257 /* ClassDeclaration */:
27169
27181
  case 226 /* ClassExpression */:
27170
- return 536940544 /* ClassExcludes */;
27182
+ return 537010176 /* ClassExcludes */;
27171
27183
  case 171 /* Constructor */:
27172
- return 591306752 /* ConstructorExcludes */;
27184
+ return 746405888 /* ConstructorExcludes */;
27173
27185
  case 167 /* PropertyDeclaration */:
27174
- return 570433536 /* PropertyExcludes */;
27186
+ return 671105024 /* PropertyExcludes */;
27175
27187
  case 169 /* MethodDeclaration */:
27176
27188
  case 172 /* GetAccessor */:
27177
27189
  case 173 /* SetAccessor */:
27178
- return 574529536 /* MethodOrAccessorExcludes */;
27190
+ return 679297024 /* MethodOrAccessorExcludes */;
27179
27191
  case 130 /* AnyKeyword */:
27180
27192
  case 147 /* NumberKeyword */:
27181
27193
  case 158 /* BigIntKeyword */:
@@ -27195,12 +27207,12 @@ var ts;
27195
27207
  case 259 /* TypeAliasDeclaration */:
27196
27208
  return -2 /* TypeExcludes */;
27197
27209
  case 205 /* ObjectLiteralExpression */:
27198
- return 536973312 /* ObjectLiteralExcludes */;
27210
+ return 537075712 /* ObjectLiteralExcludes */;
27199
27211
  case 292 /* CatchClause */:
27200
- return 536903680 /* CatchClauseExcludes */;
27212
+ return 536936448 /* CatchClauseExcludes */;
27201
27213
  case 201 /* ObjectBindingPattern */:
27202
27214
  case 202 /* ArrayBindingPattern */:
27203
- return 536887296 /* BindingPatternExcludes */;
27215
+ return 536903680 /* BindingPatternExcludes */;
27204
27216
  case 211 /* TypeAssertionExpression */:
27205
27217
  case 229 /* AsExpression */:
27206
27218
  case 350 /* PartiallyEmittedExpression */:
@@ -29076,6 +29088,10 @@ var ts;
29076
29088
  return node.kind === 267 /* ImportClause */;
29077
29089
  }
29078
29090
  ts.isImportClause = isImportClause;
29091
+ function isImportTypeAssertionContainer(node) {
29092
+ return node.kind === 295 /* ImportTypeAssertionContainer */;
29093
+ }
29094
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29079
29095
  function isAssertClause(node) {
29080
29096
  return node.kind === 293 /* AssertClause */;
29081
29097
  }
@@ -30430,6 +30446,14 @@ var ts;
30430
30446
  }
30431
30447
  }
30432
30448
  ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
30449
+ function elideNodes(factory, nodes) {
30450
+ if (nodes === undefined)
30451
+ return undefined;
30452
+ if (nodes.length === 0)
30453
+ return nodes;
30454
+ return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
30455
+ }
30456
+ ts.elideNodes = elideNodes;
30433
30457
  })(ts || (ts = {}));
30434
30458
  var ts;
30435
30459
  (function (ts) {
@@ -31601,7 +31625,7 @@ var ts;
31601
31625
  return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
31602
31626
  function containsPossibleTopLevelAwait(node) {
31603
31627
  return !(node.flags & 32768 /* AwaitContext */)
31604
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
31628
+ && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
31605
31629
  }
31606
31630
  function findNextStatementWithAwait(statements, start) {
31607
31631
  for (var i = start; i < statements.length; i++) {
@@ -31642,7 +31666,7 @@ var ts;
31642
31666
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31643
31667
  setFields(sourceFile);
31644
31668
  // If we parsed this as an external module, it may contain top-level await
31645
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31669
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
31646
31670
  sourceFile = reparseTopLevelAwait(sourceFile);
31647
31671
  setFields(sourceFile);
31648
31672
  }
@@ -35648,6 +35672,9 @@ var ts;
35648
35672
  typeArguments = expression.typeArguments;
35649
35673
  expression = expression.expression;
35650
35674
  }
35675
+ if (token() === 28 /* QuestionDotToken */) {
35676
+ parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression));
35677
+ }
35651
35678
  var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35652
35679
  return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35653
35680
  }
@@ -43839,13 +43866,36 @@ var ts;
43839
43866
  }
43840
43867
  return toSearchResult(/*value*/ undefined);
43841
43868
  }
43869
+ /**
43870
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
43871
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
43872
+ */
43873
+ function comparePatternKeys(a, b) {
43874
+ var aPatternIndex = a.indexOf("*");
43875
+ var bPatternIndex = b.indexOf("*");
43876
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
43877
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
43878
+ if (baseLenA > baseLenB)
43879
+ return -1;
43880
+ if (baseLenB > baseLenA)
43881
+ return 1;
43882
+ if (aPatternIndex === -1)
43883
+ return 1;
43884
+ if (bPatternIndex === -1)
43885
+ return -1;
43886
+ if (a.length > b.length)
43887
+ return -1;
43888
+ if (b.length > a.length)
43889
+ return 1;
43890
+ return 0;
43891
+ }
43842
43892
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
43843
43893
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
43844
43894
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
43845
43895
  var target = lookupTable[moduleName];
43846
43896
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
43847
43897
  }
43848
- 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; });
43898
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
43849
43899
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
43850
43900
  var potentialTarget = expandingKeys_1[_i];
43851
43901
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -53424,6 +53474,7 @@ var ts;
53424
53474
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53425
53475
  }
53426
53476
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53477
+ var _a, _b, _c, _d;
53427
53478
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53428
53479
  var isTypeOf = meaning === 111551 /* Value */;
53429
53480
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53441,6 +53492,7 @@ var ts;
53441
53492
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53442
53493
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53443
53494
  ])));
53495
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53444
53496
  }
53445
53497
  }
53446
53498
  if (!specifier) {
@@ -53460,6 +53512,7 @@ var ts;
53460
53512
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53461
53513
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53462
53514
  ])));
53515
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53463
53516
  }
53464
53517
  }
53465
53518
  if (!assertion) {
@@ -58948,7 +59001,7 @@ var ts;
58948
59001
  var objectType;
58949
59002
  return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58950
59003
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58951
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
59004
+ !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
58952
59005
  }
58953
59006
  /**
58954
59007
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -78775,6 +78828,10 @@ var ts;
78775
78828
  if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) {
78776
78829
  checkBinaryExpression(target, checkMode);
78777
78830
  target = target.left;
78831
+ // A default value is specified, so remove undefined from the final type.
78832
+ if (strictNullChecks) {
78833
+ sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
78834
+ }
78778
78835
  }
78779
78836
  if (target.kind === 205 /* ObjectLiteralExpression */) {
78780
78837
  return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
@@ -80865,8 +80922,11 @@ var ts;
80865
80922
  if (node.assertions) {
80866
80923
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
80867
80924
  if (override) {
80925
+ if (!ts.isNightly()) {
80926
+ 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);
80927
+ }
80868
80928
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
80869
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80929
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80870
80930
  }
80871
80931
  }
80872
80932
  }
@@ -85272,10 +85332,10 @@ var ts;
85272
85332
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85273
85333
  if (validForTypeAssertions && override) {
85274
85334
  if (!ts.isNightly()) {
85275
- 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);
85335
+ 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);
85276
85336
  }
85277
85337
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85278
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85338
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85279
85339
  }
85280
85340
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85281
85341
  }
@@ -91004,6 +91064,124 @@ var ts;
91004
91064
  return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
91005
91065
  }
91006
91066
  ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
91067
+ /**
91068
+ * Gets an array of arrays of decorators for the parameters of a function-like node.
91069
+ * The offset into the result array should correspond to the offset of the parameter.
91070
+ *
91071
+ * @param node The function-like node.
91072
+ */
91073
+ function getDecoratorsOfParameters(node) {
91074
+ var decorators;
91075
+ if (node) {
91076
+ var parameters = node.parameters;
91077
+ var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
91078
+ var firstParameterOffset = firstParameterIsThis ? 1 : 0;
91079
+ var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
91080
+ for (var i = 0; i < numParameters; i++) {
91081
+ var parameter = parameters[i + firstParameterOffset];
91082
+ if (decorators || parameter.decorators) {
91083
+ if (!decorators) {
91084
+ decorators = new Array(numParameters);
91085
+ }
91086
+ decorators[i] = parameter.decorators;
91087
+ }
91088
+ }
91089
+ }
91090
+ return decorators;
91091
+ }
91092
+ /**
91093
+ * Gets an AllDecorators object containing the decorators for the class and the decorators for the
91094
+ * parameters of the constructor of the class.
91095
+ *
91096
+ * @param node The class node.
91097
+ */
91098
+ function getAllDecoratorsOfClass(node) {
91099
+ var decorators = node.decorators;
91100
+ var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
91101
+ if (!decorators && !parameters) {
91102
+ return undefined;
91103
+ }
91104
+ return {
91105
+ decorators: decorators,
91106
+ parameters: parameters
91107
+ };
91108
+ }
91109
+ ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
91110
+ /**
91111
+ * Gets an AllDecorators object containing the decorators for the member and its parameters.
91112
+ *
91113
+ * @param parent The class node that contains the member.
91114
+ * @param member The class member.
91115
+ */
91116
+ function getAllDecoratorsOfClassElement(member, parent) {
91117
+ switch (member.kind) {
91118
+ case 172 /* GetAccessor */:
91119
+ case 173 /* SetAccessor */:
91120
+ return getAllDecoratorsOfAccessors(member, parent);
91121
+ case 169 /* MethodDeclaration */:
91122
+ return getAllDecoratorsOfMethod(member);
91123
+ case 167 /* PropertyDeclaration */:
91124
+ return getAllDecoratorsOfProperty(member);
91125
+ default:
91126
+ return undefined;
91127
+ }
91128
+ }
91129
+ ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
91130
+ /**
91131
+ * Gets an AllDecorators object containing the decorators for the accessor and its parameters.
91132
+ *
91133
+ * @param parent The class node that contains the accessor.
91134
+ * @param accessor The class accessor member.
91135
+ */
91136
+ function getAllDecoratorsOfAccessors(accessor, parent) {
91137
+ if (!accessor.body) {
91138
+ return undefined;
91139
+ }
91140
+ var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
91141
+ var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
91142
+ if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
91143
+ return undefined;
91144
+ }
91145
+ var decorators = firstAccessorWithDecorators.decorators;
91146
+ var parameters = getDecoratorsOfParameters(setAccessor);
91147
+ if (!decorators && !parameters) {
91148
+ return undefined;
91149
+ }
91150
+ return {
91151
+ decorators: decorators,
91152
+ parameters: parameters,
91153
+ getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
91154
+ setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
91155
+ };
91156
+ }
91157
+ /**
91158
+ * Gets an AllDecorators object containing the decorators for the method and its parameters.
91159
+ *
91160
+ * @param method The class method member.
91161
+ */
91162
+ function getAllDecoratorsOfMethod(method) {
91163
+ if (!method.body) {
91164
+ return undefined;
91165
+ }
91166
+ var decorators = method.decorators;
91167
+ var parameters = getDecoratorsOfParameters(method);
91168
+ if (!decorators && !parameters) {
91169
+ return undefined;
91170
+ }
91171
+ return { decorators: decorators, parameters: parameters };
91172
+ }
91173
+ /**
91174
+ * Gets an AllDecorators object containing the decorators for the property.
91175
+ *
91176
+ * @param property The class property member.
91177
+ */
91178
+ function getAllDecoratorsOfProperty(property) {
91179
+ var decorators = property.decorators;
91180
+ if (!decorators) {
91181
+ return undefined;
91182
+ }
91183
+ return { decorators: decorators };
91184
+ }
91007
91185
  })(ts || (ts = {}));
91008
91186
  /*@internal*/
91009
91187
  var ts;
@@ -91277,8 +91455,8 @@ var ts;
91277
91455
  if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
91278
91456
  var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
91279
91457
  if (flattenContext.level >= 1 /* ObjectRest */
91280
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91281
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91458
+ && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91459
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91282
91460
  && !ts.isComputedPropertyName(propertyName)) {
91283
91461
  bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
91284
91462
  }
@@ -91344,7 +91522,7 @@ var ts;
91344
91522
  if (flattenContext.level >= 1 /* ObjectRest */) {
91345
91523
  // If an array pattern contains an ObjectRest, we must cache the result so that we
91346
91524
  // can perform the ObjectRest destructuring in a different declaration
91347
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91525
+ if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91348
91526
  flattenContext.hasTransformedPriorElement = true;
91349
91527
  var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
91350
91528
  if (flattenContext.hoistTempVariables) {
@@ -91566,8 +91744,6 @@ var ts;
91566
91744
  var USE_NEW_TYPE_METADATA_FORMAT = false;
91567
91745
  var TypeScriptSubstitutionFlags;
91568
91746
  (function (TypeScriptSubstitutionFlags) {
91569
- /** Enables substitutions for decorated classes. */
91570
- TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
91571
91747
  /** Enables substitutions for namespace exports. */
91572
91748
  TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
91573
91749
  /* Enables substitutions for unqualified enum members */
@@ -91593,9 +91769,9 @@ var ts;
91593
91769
  var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
91594
91770
  var resolver = context.getEmitResolver();
91595
91771
  var compilerOptions = context.getCompilerOptions();
91596
- var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
91597
91772
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
91598
91773
  var moduleKind = ts.getEmitModuleKind(compilerOptions);
91774
+ var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
91599
91775
  // Save the previous transformation hooks.
91600
91776
  var previousOnEmitNode = context.onEmitNode;
91601
91777
  var previousOnSubstituteNode = context.onSubstituteNode;
@@ -91610,7 +91786,6 @@ var ts;
91610
91786
  var currentNamespace;
91611
91787
  var currentNamespaceContainerName;
91612
91788
  var currentLexicalScope;
91613
- var currentNameScope;
91614
91789
  var currentScopeFirstDeclarationsOfName;
91615
91790
  var currentClassHasParameterProperties;
91616
91791
  /**
@@ -91618,11 +91793,6 @@ var ts;
91618
91793
  * They are persisted between each SourceFile transformation and should not be reset.
91619
91794
  */
91620
91795
  var enabledSubstitutions;
91621
- /**
91622
- * A map that keeps track of aliases created for classes with decorators to avoid issues
91623
- * with the double-binding behavior of classes.
91624
- */
91625
- var classAliases;
91626
91796
  /**
91627
91797
  * Keeps track of whether we are within any containing namespaces when performing
91628
91798
  * just-in-time substitution while printing an expression identifier.
@@ -91666,7 +91836,6 @@ var ts;
91666
91836
  function saveStateAndInvoke(node, f) {
91667
91837
  // Save state
91668
91838
  var savedCurrentScope = currentLexicalScope;
91669
- var savedCurrentNameScope = currentNameScope;
91670
91839
  var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
91671
91840
  var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
91672
91841
  // Handle state changes before visiting a node.
@@ -91677,7 +91846,6 @@ var ts;
91677
91846
  currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
91678
91847
  }
91679
91848
  currentLexicalScope = savedCurrentScope;
91680
- currentNameScope = savedCurrentNameScope;
91681
91849
  currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
91682
91850
  return visited;
91683
91851
  }
@@ -91693,7 +91861,6 @@ var ts;
91693
91861
  case 262 /* ModuleBlock */:
91694
91862
  case 235 /* Block */:
91695
91863
  currentLexicalScope = node;
91696
- currentNameScope = undefined;
91697
91864
  currentScopeFirstDeclarationsOfName = undefined;
91698
91865
  break;
91699
91866
  case 257 /* ClassDeclaration */:
@@ -91711,10 +91878,6 @@ var ts;
91711
91878
  // programs may also have an undefined name.
91712
91879
  ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
91713
91880
  }
91714
- if (ts.isClassDeclaration(node)) {
91715
- // XXX: should probably also cover interfaces and type aliases that can have type variables?
91716
- currentNameScope = node;
91717
- }
91718
91881
  break;
91719
91882
  }
91720
91883
  }
@@ -91816,35 +91979,66 @@ var ts;
91816
91979
  return node;
91817
91980
  }
91818
91981
  /**
91819
- * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91982
+ * Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
91820
91983
  *
91821
- * @param node The node to visit.
91984
+ * @param parent The class containing the elements to visit.
91822
91985
  */
91823
- function classElementVisitor(node) {
91824
- return saveStateAndInvoke(node, classElementVisitorWorker);
91986
+ function getClassElementVisitor(parent) {
91987
+ return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
91825
91988
  }
91826
91989
  /**
91827
91990
  * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91828
91991
  *
91829
91992
  * @param node The node to visit.
91830
91993
  */
91831
- function classElementVisitorWorker(node) {
91994
+ function classElementVisitorWorker(node, parent) {
91832
91995
  switch (node.kind) {
91833
91996
  case 171 /* Constructor */:
91834
91997
  return visitConstructor(node);
91835
91998
  case 167 /* PropertyDeclaration */:
91836
91999
  // Property declarations are not TypeScript syntax, but they must be visited
91837
92000
  // for the decorator transformation.
91838
- return visitPropertyDeclaration(node);
91839
- case 176 /* IndexSignature */:
92001
+ return visitPropertyDeclaration(node, parent);
91840
92002
  case 172 /* GetAccessor */:
92003
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92004
+ return visitGetAccessor(node, parent);
91841
92005
  case 173 /* SetAccessor */:
92006
+ // Set Accessors can have TypeScript modifiers and type annotations.
92007
+ return visitSetAccessor(node, parent);
91842
92008
  case 169 /* MethodDeclaration */:
92009
+ // TypeScript method declarations may have decorators, modifiers
92010
+ // or type annotations.
92011
+ return visitMethodDeclaration(node, parent);
91843
92012
  case 170 /* ClassStaticBlockDeclaration */:
91844
- // Fallback to the default visit behavior.
91845
- return visitorWorker(node);
92013
+ return ts.visitEachChild(node, visitor, context);
91846
92014
  case 234 /* SemicolonClassElement */:
91847
92015
  return node;
92016
+ case 176 /* IndexSignature */:
92017
+ // Index signatures are elided
92018
+ return;
92019
+ default:
92020
+ return ts.Debug.failBadSyntaxKind(node);
92021
+ }
92022
+ }
92023
+ function getObjectLiteralElementVisitor(parent) {
92024
+ return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
92025
+ }
92026
+ function objectLiteralElementVisitorWorker(node, parent) {
92027
+ switch (node.kind) {
92028
+ case 296 /* PropertyAssignment */:
92029
+ case 297 /* ShorthandPropertyAssignment */:
92030
+ case 298 /* SpreadAssignment */:
92031
+ return visitor(node);
92032
+ case 172 /* GetAccessor */:
92033
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92034
+ return visitGetAccessor(node, parent);
92035
+ case 173 /* SetAccessor */:
92036
+ // Set Accessors can have TypeScript modifiers and type annotations.
92037
+ return visitSetAccessor(node, parent);
92038
+ case 169 /* MethodDeclaration */:
92039
+ // TypeScript method declarations may have decorators, modifiers
92040
+ // or type annotations.
92041
+ return visitMethodDeclaration(node, parent);
91848
92042
  default:
91849
92043
  return ts.Debug.failBadSyntaxKind(node);
91850
92044
  }
@@ -91917,22 +92111,14 @@ var ts;
91917
92111
  // TypeScript type nodes are elided.
91918
92112
  // falls through
91919
92113
  case 176 /* IndexSignature */:
91920
- // TypeScript index signatures are elided.
91921
- // falls through
91922
- case 165 /* Decorator */:
91923
- // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
92114
+ // TypeScript index signatures are elided.
91924
92115
  return undefined;
91925
92116
  case 259 /* TypeAliasDeclaration */:
91926
92117
  // TypeScript type-only declarations are elided.
91927
92118
  return factory.createNotEmittedStatement(node);
91928
- case 167 /* PropertyDeclaration */:
91929
- // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
91930
- return visitPropertyDeclaration(node);
91931
92119
  case 264 /* NamespaceExportDeclaration */:
91932
92120
  // TypeScript namespace export declarations are elided.
91933
92121
  return undefined;
91934
- case 171 /* Constructor */:
91935
- return visitConstructor(node);
91936
92122
  case 258 /* InterfaceDeclaration */:
91937
92123
  // TypeScript interfaces are elided, but some comments may be preserved.
91938
92124
  // See the implementation of `getLeadingComments` in comments.ts for more details.
@@ -91966,16 +92152,15 @@ var ts;
91966
92152
  case 228 /* ExpressionWithTypeArguments */:
91967
92153
  // TypeScript supports type arguments on an expression in an `extends` heritage clause.
91968
92154
  return visitExpressionWithTypeArguments(node);
92155
+ case 205 /* ObjectLiteralExpression */:
92156
+ return visitObjectLiteralExpression(node);
92157
+ case 171 /* Constructor */:
92158
+ case 167 /* PropertyDeclaration */:
91969
92159
  case 169 /* MethodDeclaration */:
91970
- // TypeScript method declarations may have decorators, modifiers
91971
- // or type annotations.
91972
- return visitMethodDeclaration(node);
91973
92160
  case 172 /* GetAccessor */:
91974
- // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
91975
- return visitGetAccessor(node);
91976
92161
  case 173 /* SetAccessor */:
91977
- // Set Accessors can have TypeScript modifiers and type annotations.
91978
- return visitSetAccessor(node);
92162
+ case 170 /* ClassStaticBlockDeclaration */:
92163
+ return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
91979
92164
  case 256 /* FunctionDeclaration */:
91980
92165
  // Typescript function declarations can have modifiers, decorators, and type annotations.
91981
92166
  return visitFunctionDeclaration(node);
@@ -92041,6 +92226,9 @@ var ts;
92041
92226
  !ts.isJsonSourceFile(node);
92042
92227
  return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
92043
92228
  }
92229
+ function visitObjectLiteralExpression(node) {
92230
+ return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
92231
+ }
92044
92232
  function getClassFacts(node, staticProperties) {
92045
92233
  var facts = 0 /* None */;
92046
92234
  if (ts.some(staticProperties))
@@ -92063,7 +92251,7 @@ var ts;
92063
92251
  return facts;
92064
92252
  }
92065
92253
  function hasTypeScriptClassSyntax(node) {
92066
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
92254
+ return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
92067
92255
  }
92068
92256
  function isClassLikeDeclarationWithTypeScriptSyntax(node) {
92069
92257
  return ts.some(node.decorators)
@@ -92073,7 +92261,9 @@ var ts;
92073
92261
  }
92074
92262
  function visitClassDeclaration(node) {
92075
92263
  if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
92076
- return ts.visitEachChild(node, visitor, context);
92264
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92265
+ ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
92266
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92077
92267
  }
92078
92268
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
92079
92269
  var facts = getClassFacts(node, staticProperties);
@@ -92081,14 +92271,25 @@ var ts;
92081
92271
  context.startLexicalEnvironment();
92082
92272
  }
92083
92273
  var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
92084
- var classStatement = facts & 2 /* HasConstructorDecorators */
92085
- ? createClassDeclarationHeadWithDecorators(node, name)
92086
- : createClassDeclarationHeadWithoutDecorators(node, name, facts);
92274
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92275
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92276
+ // we do not emit modifiers on the declaration if we are emitting an IIFE
92277
+ var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92278
+ ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92279
+ : ts.elideNodes(factory, node.modifiers); // preserve positions, if available
92280
+ // ${modifiers} class ${name} ${heritageClauses} {
92281
+ // ${members}
92282
+ // }
92283
+ var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
92284
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92285
+ // To better align with the old emitter, we should not emit a trailing source map
92286
+ // entry if the class has static properties.
92287
+ var emitFlags = ts.getEmitFlags(node);
92288
+ if (facts & 1 /* HasStaticInitializedProperties */) {
92289
+ emitFlags |= 32 /* NoTrailingSourceMap */;
92290
+ }
92291
+ ts.setEmitFlags(classStatement, emitFlags);
92087
92292
  var statements = [classStatement];
92088
- // Write any decorators of the node.
92089
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
92090
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
92091
- addConstructorDecorationStatement(statements, node);
92092
92293
  if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
92093
92294
  // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
92094
92295
  // 'es2015' transformer can properly nest static initializers and decorators. The result
@@ -92148,164 +92349,14 @@ var ts;
92148
92349
  }
92149
92350
  return ts.singleOrMany(statements);
92150
92351
  }
92151
- /**
92152
- * Transforms a non-decorated class declaration and appends the resulting statements.
92153
- *
92154
- * @param node A ClassDeclaration node.
92155
- * @param name The name of the class.
92156
- * @param facts Precomputed facts about the class.
92157
- */
92158
- function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
92159
- // ${modifiers} class ${name} ${heritageClauses} {
92160
- // ${members}
92161
- // }
92162
- // we do not emit modifiers on the declaration if we are emitting an IIFE
92163
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92164
- ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92165
- : undefined;
92166
- var classDeclaration = factory.createClassDeclaration(
92167
- /*decorators*/ undefined, modifiers, name,
92168
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92169
- // To better align with the old emitter, we should not emit a trailing source map
92170
- // entry if the class has static properties.
92171
- var emitFlags = ts.getEmitFlags(node);
92172
- if (facts & 1 /* HasStaticInitializedProperties */) {
92173
- emitFlags |= 32 /* NoTrailingSourceMap */;
92174
- }
92175
- ts.setTextRange(classDeclaration, node);
92176
- ts.setOriginalNode(classDeclaration, node);
92177
- ts.setEmitFlags(classDeclaration, emitFlags);
92178
- return classDeclaration;
92179
- }
92180
- /**
92181
- * Transforms a decorated class declaration and appends the resulting statements. If
92182
- * the class requires an alias to avoid issues with double-binding, the alias is returned.
92183
- */
92184
- function createClassDeclarationHeadWithDecorators(node, name) {
92185
- // When we emit an ES6 class that has a class decorator, we must tailor the
92186
- // emit to certain specific cases.
92187
- //
92188
- // In the simplest case, we emit the class declaration as a let declaration, and
92189
- // evaluate decorators after the close of the class body:
92190
- //
92191
- // [Example 1]
92192
- // ---------------------------------------------------------------------
92193
- // TypeScript | Javascript
92194
- // ---------------------------------------------------------------------
92195
- // @dec | let C = class C {
92196
- // class C { | }
92197
- // } | C = __decorate([dec], C);
92198
- // ---------------------------------------------------------------------
92199
- // @dec | let C = class C {
92200
- // export class C { | }
92201
- // } | C = __decorate([dec], C);
92202
- // | export { C };
92203
- // ---------------------------------------------------------------------
92204
- //
92205
- // If a class declaration contains a reference to itself *inside* of the class body,
92206
- // this introduces two bindings to the class: One outside of the class body, and one
92207
- // inside of the class body. If we apply decorators as in [Example 1] above, there
92208
- // is the possibility that the decorator `dec` will return a new value for the
92209
- // constructor, which would result in the binding inside of the class no longer
92210
- // pointing to the same reference as the binding outside of the class.
92211
- //
92212
- // As a result, we must instead rewrite all references to the class *inside* of the
92213
- // class body to instead point to a local temporary alias for the class:
92214
- //
92215
- // [Example 2]
92216
- // ---------------------------------------------------------------------
92217
- // TypeScript | Javascript
92218
- // ---------------------------------------------------------------------
92219
- // @dec | let C = C_1 = class C {
92220
- // class C { | static x() { return C_1.y; }
92221
- // static x() { return C.y; } | }
92222
- // static y = 1; | C.y = 1;
92223
- // } | C = C_1 = __decorate([dec], C);
92224
- // | var C_1;
92225
- // ---------------------------------------------------------------------
92226
- // @dec | let C = class C {
92227
- // export class C { | static x() { return C_1.y; }
92228
- // static x() { return C.y; } | }
92229
- // static y = 1; | C.y = 1;
92230
- // } | C = C_1 = __decorate([dec], C);
92231
- // | export { C };
92232
- // | var C_1;
92233
- // ---------------------------------------------------------------------
92234
- //
92235
- // If a class declaration is the default export of a module, we instead emit
92236
- // the export after the decorated declaration:
92237
- //
92238
- // [Example 3]
92239
- // ---------------------------------------------------------------------
92240
- // TypeScript | Javascript
92241
- // ---------------------------------------------------------------------
92242
- // @dec | let default_1 = class {
92243
- // export default class { | }
92244
- // } | default_1 = __decorate([dec], default_1);
92245
- // | export default default_1;
92246
- // ---------------------------------------------------------------------
92247
- // @dec | let C = class C {
92248
- // export default class C { | }
92249
- // } | C = __decorate([dec], C);
92250
- // | export default C;
92251
- // ---------------------------------------------------------------------
92252
- //
92253
- // If the class declaration is the default export and a reference to itself
92254
- // inside of the class body, we must emit both an alias for the class *and*
92255
- // move the export after the declaration:
92256
- //
92257
- // [Example 4]
92258
- // ---------------------------------------------------------------------
92259
- // TypeScript | Javascript
92260
- // ---------------------------------------------------------------------
92261
- // @dec | let C = class C {
92262
- // export default class C { | static x() { return C_1.y; }
92263
- // static x() { return C.y; } | }
92264
- // static y = 1; | C.y = 1;
92265
- // } | C = C_1 = __decorate([dec], C);
92266
- // | export default C;
92267
- // | var C_1;
92268
- // ---------------------------------------------------------------------
92269
- //
92270
- var location = ts.moveRangePastDecorators(node);
92271
- var classAlias = getClassAliasIfNeeded(node);
92272
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92273
- // without any block-scoped variable collision handling
92274
- var declName = languageVersion <= 2 /* ES2015 */ ?
92275
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92276
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92277
- // ... = class ${name} ${heritageClauses} {
92278
- // ${members}
92279
- // }
92280
- var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
92281
- var members = transformClassMembers(node);
92282
- var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
92283
- ts.setOriginalNode(classExpression, node);
92284
- ts.setTextRange(classExpression, location);
92285
- // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
92286
- // or decoratedClassAlias if the class contain self-reference.
92287
- var statement = factory.createVariableStatement(
92288
- /*modifiers*/ undefined, factory.createVariableDeclarationList([
92289
- factory.createVariableDeclaration(declName,
92290
- /*exclamationToken*/ undefined,
92291
- /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
92292
- ], 1 /* Let */));
92293
- ts.setOriginalNode(statement, node);
92294
- ts.setTextRange(statement, location);
92295
- ts.setCommentRange(statement, node);
92296
- return statement;
92297
- }
92298
92352
  function visitClassExpression(node) {
92299
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
92300
- return ts.visitEachChild(node, visitor, context);
92301
- }
92302
- var classExpression = factory.createClassExpression(
92303
- /*decorators*/ undefined,
92353
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92354
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92355
+ return factory.updateClassExpression(node, decorators,
92304
92356
  /*modifiers*/ undefined, node.name,
92305
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92306
- ts.setOriginalNode(classExpression, node);
92307
- ts.setTextRange(classExpression, node);
92308
- return classExpression;
92357
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
92358
+ transformClassMembers(node) :
92359
+ ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92309
92360
  }
92310
92361
  /**
92311
92362
  * Transforms the members of a class.
@@ -92330,48 +92381,9 @@ var ts;
92330
92381
  }
92331
92382
  }
92332
92383
  }
92333
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
92384
+ ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92334
92385
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
92335
92386
  }
92336
- /**
92337
- * Gets either the static or instance members of a class that are decorated, or have
92338
- * parameters that are decorated.
92339
- *
92340
- * @param node The class containing the member.
92341
- * @param isStatic A value indicating whether to retrieve static or instance members of
92342
- * the class.
92343
- */
92344
- function getDecoratedClassElements(node, isStatic) {
92345
- return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
92346
- }
92347
- /**
92348
- * Determines whether a class member is a static member of a class that is decorated, or
92349
- * has parameters that are decorated.
92350
- *
92351
- * @param member The class member.
92352
- */
92353
- function isStaticDecoratedClassElement(member, parent) {
92354
- return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
92355
- }
92356
- /**
92357
- * Determines whether a class member is an instance member of a class that is decorated,
92358
- * or has parameters that are decorated.
92359
- *
92360
- * @param member The class member.
92361
- */
92362
- function isInstanceDecoratedClassElement(member, parent) {
92363
- return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
92364
- }
92365
- /**
92366
- * Determines whether a class member is either a static or an instance member of a class
92367
- * that is decorated, or has parameters that are decorated.
92368
- *
92369
- * @param member The class member.
92370
- */
92371
- function isDecoratedClassElement(member, isStaticElement, parent) {
92372
- return ts.nodeOrChildIsDecorated(member, parent)
92373
- && isStaticElement === ts.isStatic(member);
92374
- }
92375
92387
  /**
92376
92388
  * Gets an array of arrays of decorators for the parameters of a function-like node.
92377
92389
  * The offset into the result array should correspond to the offset of the parameter.
@@ -92417,14 +92429,14 @@ var ts;
92417
92429
  /**
92418
92430
  * Gets an AllDecorators object containing the decorators for the member and its parameters.
92419
92431
  *
92420
- * @param node The class node that contains the member.
92432
+ * @param parent The class node that contains the member.
92421
92433
  * @param member The class member.
92422
92434
  */
92423
- function getAllDecoratorsOfClassElement(node, member) {
92435
+ function getAllDecoratorsOfClassElement(member, parent) {
92424
92436
  switch (member.kind) {
92425
92437
  case 172 /* GetAccessor */:
92426
92438
  case 173 /* SetAccessor */:
92427
- return getAllDecoratorsOfAccessors(node, member);
92439
+ return getAllDecoratorsOfAccessors(parent, member);
92428
92440
  case 169 /* MethodDeclaration */:
92429
92441
  return getAllDecoratorsOfMethod(member);
92430
92442
  case 167 /* PropertyDeclaration */:
@@ -92493,209 +92505,82 @@ var ts;
92493
92505
  if (!allDecorators) {
92494
92506
  return undefined;
92495
92507
  }
92496
- var decoratorExpressions = [];
92497
- ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
92498
- ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
92499
- addTypeMetadata(node, container, decoratorExpressions);
92500
- return decoratorExpressions;
92501
- }
92502
- /**
92503
- * Generates statements used to apply decorators to either the static or instance members
92504
- * of a class.
92505
- *
92506
- * @param node The class node.
92507
- * @param isStatic A value indicating whether to generate statements for static or
92508
- * instance members.
92509
- */
92510
- function addClassElementDecorationStatements(statements, node, isStatic) {
92511
- ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
92512
- }
92513
- /**
92514
- * Generates expressions used to apply decorators to either the static or instance members
92515
- * of a class.
92516
- *
92517
- * @param node The class node.
92518
- * @param isStatic A value indicating whether to generate expressions for static or
92519
- * instance members.
92520
- */
92521
- function generateClassElementDecorationExpressions(node, isStatic) {
92522
- var members = getDecoratedClassElements(node, isStatic);
92523
- var expressions;
92524
- for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
92525
- var member = members_8[_i];
92526
- var expression = generateClassElementDecorationExpression(node, member);
92527
- if (expression) {
92528
- if (!expressions) {
92529
- expressions = [expression];
92530
- }
92531
- else {
92532
- expressions.push(expression);
92533
- }
92534
- }
92535
- }
92536
- return expressions;
92537
- }
92538
- /**
92539
- * Generates an expression used to evaluate class element decorators at runtime.
92540
- *
92541
- * @param node The class node that contains the member.
92542
- * @param member The class member.
92543
- */
92544
- function generateClassElementDecorationExpression(node, member) {
92545
- var allDecorators = getAllDecoratorsOfClassElement(node, member);
92546
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
92547
- if (!decoratorExpressions) {
92548
- return undefined;
92549
- }
92550
- // Emit the call to __decorate. Given the following:
92551
- //
92552
- // class C {
92553
- // @dec method(@dec2 x) {}
92554
- // @dec get accessor() {}
92555
- // @dec prop;
92556
- // }
92557
- //
92558
- // The emit for a method is:
92559
- //
92560
- // __decorate([
92561
- // dec,
92562
- // __param(0, dec2),
92563
- // __metadata("design:type", Function),
92564
- // __metadata("design:paramtypes", [Object]),
92565
- // __metadata("design:returntype", void 0)
92566
- // ], C.prototype, "method", null);
92567
- //
92568
- // The emit for an accessor is:
92569
- //
92570
- // __decorate([
92571
- // dec
92572
- // ], C.prototype, "accessor", null);
92573
- //
92574
- // The emit for a property is:
92575
- //
92576
- // __decorate([
92577
- // dec
92578
- // ], C.prototype, "prop");
92579
- //
92580
- var prefix = getClassMemberPrefix(node, member);
92581
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
92582
- var descriptor = languageVersion > 0 /* ES3 */
92583
- ? member.kind === 167 /* PropertyDeclaration */
92584
- // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
92585
- // should not invoke `Object.getOwnPropertyDescriptor`.
92586
- ? factory.createVoidZero()
92587
- // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
92588
- // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
92589
- : factory.createNull()
92590
- : undefined;
92591
- var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
92592
- ts.setTextRange(helper, ts.moveRangePastDecorators(member));
92593
- ts.setEmitFlags(helper, 1536 /* NoComments */);
92594
- return helper;
92595
- }
92596
- /**
92597
- * Generates a __decorate helper call for a class constructor.
92598
- *
92599
- * @param node The class node.
92600
- */
92601
- function addConstructorDecorationStatement(statements, node) {
92602
- var expression = generateConstructorDecorationExpression(node);
92603
- if (expression) {
92604
- statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
92605
- }
92606
- }
92607
- /**
92608
- * Generates a __decorate helper call for a class constructor.
92609
- *
92610
- * @param node The class node.
92611
- */
92612
- function generateConstructorDecorationExpression(node) {
92613
- var allDecorators = getAllDecoratorsOfConstructor(node);
92614
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92615
- if (!decoratorExpressions) {
92616
- return undefined;
92617
- }
92618
- var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
92619
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92620
- // without any block-scoped variable collision handling
92621
- var localName = languageVersion <= 2 /* ES2015 */ ?
92622
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92623
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92624
- var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
92625
- var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
92626
- ts.setEmitFlags(expression, 1536 /* NoComments */);
92627
- ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
92628
- return expression;
92629
- }
92630
- /**
92631
- * Transforms a decorator into an expression.
92632
- *
92633
- * @param decorator The decorator node.
92634
- */
92635
- function transformDecorator(decorator) {
92636
- return ts.visitNode(decorator.expression, visitor, ts.isExpression);
92508
+ var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
92509
+ var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
92510
+ var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
92511
+ var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
92512
+ ts.setTextRange(result, decorators);
92513
+ return result;
92637
92514
  }
92638
92515
  /**
92639
- * Transforms the decorators of a parameter.
92516
+ * Transforms the decorators of a parameter into decorators of the class/method.
92640
92517
  *
92641
- * @param decorators The decorators for the parameter at the provided offset.
92518
+ * @param parameterDecorators The decorators for the parameter at the provided offset.
92642
92519
  * @param parameterOffset The offset of the parameter.
92643
92520
  */
92644
- function transformDecoratorsOfParameter(decorators, parameterOffset) {
92645
- var expressions;
92646
- if (decorators) {
92647
- expressions = [];
92648
- for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
92649
- var decorator = decorators_1[_i];
92650
- var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
92651
- ts.setTextRange(helper, decorator.expression);
92521
+ function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
92522
+ if (parameterDecorators) {
92523
+ var decorators = [];
92524
+ for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
92525
+ var parameterDecorator = parameterDecorators_1[_i];
92526
+ var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
92527
+ var helper = emitHelpers().createParamHelper(expression, parameterOffset);
92528
+ ts.setTextRange(helper, parameterDecorator.expression);
92652
92529
  ts.setEmitFlags(helper, 1536 /* NoComments */);
92653
- expressions.push(helper);
92530
+ var decorator = factory.createDecorator(helper);
92531
+ ts.setTextRange(decorator, parameterDecorator.expression);
92532
+ ts.setEmitFlags(decorator, 1536 /* NoComments */);
92533
+ decorators.push(decorator);
92654
92534
  }
92535
+ return decorators;
92655
92536
  }
92656
- return expressions;
92657
92537
  }
92658
92538
  /**
92659
- * Adds optional type metadata for a declaration.
92539
+ * Gets optional type metadata for a declaration.
92660
92540
  *
92661
92541
  * @param node The declaration node.
92662
- * @param decoratorExpressions The destination array to which to add new decorator expressions.
92663
92542
  */
92664
- function addTypeMetadata(node, container, decoratorExpressions) {
92665
- if (USE_NEW_TYPE_METADATA_FORMAT) {
92666
- addNewTypeMetadata(node, container, decoratorExpressions);
92667
- }
92668
- else {
92669
- addOldTypeMetadata(node, container, decoratorExpressions);
92670
- }
92543
+ function getTypeMetadata(node, container) {
92544
+ return USE_NEW_TYPE_METADATA_FORMAT ?
92545
+ getNewTypeMetadata(node, container) :
92546
+ getOldTypeMetadata(node, container);
92671
92547
  }
92672
- function addOldTypeMetadata(node, container, decoratorExpressions) {
92673
- if (compilerOptions.emitDecoratorMetadata) {
92548
+ function getOldTypeMetadata(node, container) {
92549
+ if (typeSerializer) {
92550
+ var decorators = void 0;
92674
92551
  if (shouldAddTypeMetadata(node)) {
92675
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
92552
+ var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92553
+ decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
92676
92554
  }
92677
92555
  if (shouldAddParamTypesMetadata(node)) {
92678
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
92556
+ var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
92557
+ decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
92679
92558
  }
92680
92559
  if (shouldAddReturnTypeMetadata(node)) {
92681
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
92560
+ var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92561
+ decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
92682
92562
  }
92563
+ return decorators;
92683
92564
  }
92684
92565
  }
92685
- function addNewTypeMetadata(node, container, decoratorExpressions) {
92686
- if (compilerOptions.emitDecoratorMetadata) {
92566
+ function getNewTypeMetadata(node, container) {
92567
+ if (typeSerializer) {
92687
92568
  var properties = void 0;
92688
92569
  if (shouldAddTypeMetadata(node)) {
92689
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
92570
+ var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92571
+ properties = ts.append(properties, typeProperty);
92690
92572
  }
92691
92573
  if (shouldAddParamTypesMetadata(node)) {
92692
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
92574
+ 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)));
92575
+ properties = ts.append(properties, paramTypeProperty);
92693
92576
  }
92694
92577
  if (shouldAddReturnTypeMetadata(node)) {
92695
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
92578
+ var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92579
+ properties = ts.append(properties, returnTypeProperty);
92696
92580
  }
92697
92581
  if (properties) {
92698
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
92582
+ var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
92583
+ return [factory.createDecorator(typeInfoMetadata)];
92699
92584
  }
92700
92585
  }
92701
92586
  }
@@ -92742,347 +92627,6 @@ var ts;
92742
92627
  }
92743
92628
  return false;
92744
92629
  }
92745
- function getAccessorTypeNode(node) {
92746
- var accessors = resolver.getAllAccessorDeclarations(node);
92747
- return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
92748
- || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
92749
- }
92750
- /**
92751
- * Serializes the type of a node for use with decorator type metadata.
92752
- *
92753
- * @param node The node that should have its type serialized.
92754
- */
92755
- function serializeTypeOfNode(node) {
92756
- switch (node.kind) {
92757
- case 167 /* PropertyDeclaration */:
92758
- case 164 /* Parameter */:
92759
- return serializeTypeNode(node.type);
92760
- case 173 /* SetAccessor */:
92761
- case 172 /* GetAccessor */:
92762
- return serializeTypeNode(getAccessorTypeNode(node));
92763
- case 257 /* ClassDeclaration */:
92764
- case 226 /* ClassExpression */:
92765
- case 169 /* MethodDeclaration */:
92766
- return factory.createIdentifier("Function");
92767
- default:
92768
- return factory.createVoidZero();
92769
- }
92770
- }
92771
- /**
92772
- * Serializes the types of the parameters of a node for use with decorator type metadata.
92773
- *
92774
- * @param node The node that should have its parameter types serialized.
92775
- */
92776
- function serializeParameterTypesOfNode(node, container) {
92777
- var valueDeclaration = ts.isClassLike(node)
92778
- ? ts.getFirstConstructorWithBody(node)
92779
- : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
92780
- ? node
92781
- : undefined;
92782
- var expressions = [];
92783
- if (valueDeclaration) {
92784
- var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
92785
- var numParameters = parameters.length;
92786
- for (var i = 0; i < numParameters; i++) {
92787
- var parameter = parameters[i];
92788
- if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
92789
- continue;
92790
- }
92791
- if (parameter.dotDotDotToken) {
92792
- expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
92793
- }
92794
- else {
92795
- expressions.push(serializeTypeOfNode(parameter));
92796
- }
92797
- }
92798
- }
92799
- return factory.createArrayLiteralExpression(expressions);
92800
- }
92801
- function getParametersOfDecoratedDeclaration(node, container) {
92802
- if (container && node.kind === 172 /* GetAccessor */) {
92803
- var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
92804
- if (setAccessor) {
92805
- return setAccessor.parameters;
92806
- }
92807
- }
92808
- return node.parameters;
92809
- }
92810
- /**
92811
- * Serializes the return type of a node for use with decorator type metadata.
92812
- *
92813
- * @param node The node that should have its return type serialized.
92814
- */
92815
- function serializeReturnTypeOfNode(node) {
92816
- if (ts.isFunctionLike(node) && node.type) {
92817
- return serializeTypeNode(node.type);
92818
- }
92819
- else if (ts.isAsyncFunction(node)) {
92820
- return factory.createIdentifier("Promise");
92821
- }
92822
- return factory.createVoidZero();
92823
- }
92824
- /**
92825
- * Serializes a type node for use with decorator type metadata.
92826
- *
92827
- * Types are serialized in the following fashion:
92828
- * - Void types point to "undefined" (e.g. "void 0")
92829
- * - Function and Constructor types point to the global "Function" constructor.
92830
- * - Interface types with a call or construct signature types point to the global
92831
- * "Function" constructor.
92832
- * - Array and Tuple types point to the global "Array" constructor.
92833
- * - Type predicates and booleans point to the global "Boolean" constructor.
92834
- * - String literal types and strings point to the global "String" constructor.
92835
- * - Enum and number types point to the global "Number" constructor.
92836
- * - Symbol types point to the global "Symbol" constructor.
92837
- * - Type references to classes (or class-like variables) point to the constructor for the class.
92838
- * - Anything else points to the global "Object" constructor.
92839
- *
92840
- * @param node The type node to serialize.
92841
- */
92842
- function serializeTypeNode(node) {
92843
- if (node === undefined) {
92844
- return factory.createIdentifier("Object");
92845
- }
92846
- switch (node.kind) {
92847
- case 114 /* VoidKeyword */:
92848
- case 153 /* UndefinedKeyword */:
92849
- case 143 /* NeverKeyword */:
92850
- return factory.createVoidZero();
92851
- case 191 /* ParenthesizedType */:
92852
- return serializeTypeNode(node.type);
92853
- case 179 /* FunctionType */:
92854
- case 180 /* ConstructorType */:
92855
- return factory.createIdentifier("Function");
92856
- case 183 /* ArrayType */:
92857
- case 184 /* TupleType */:
92858
- return factory.createIdentifier("Array");
92859
- case 177 /* TypePredicate */:
92860
- case 133 /* BooleanKeyword */:
92861
- return factory.createIdentifier("Boolean");
92862
- case 198 /* TemplateLiteralType */:
92863
- case 150 /* StringKeyword */:
92864
- return factory.createIdentifier("String");
92865
- case 148 /* ObjectKeyword */:
92866
- return factory.createIdentifier("Object");
92867
- case 196 /* LiteralType */:
92868
- switch (node.literal.kind) {
92869
- case 10 /* StringLiteral */:
92870
- case 14 /* NoSubstitutionTemplateLiteral */:
92871
- return factory.createIdentifier("String");
92872
- case 219 /* PrefixUnaryExpression */:
92873
- case 8 /* NumericLiteral */:
92874
- return factory.createIdentifier("Number");
92875
- case 9 /* BigIntLiteral */:
92876
- return getGlobalBigIntNameWithFallback();
92877
- case 110 /* TrueKeyword */:
92878
- case 95 /* FalseKeyword */:
92879
- return factory.createIdentifier("Boolean");
92880
- case 104 /* NullKeyword */:
92881
- return factory.createVoidZero();
92882
- default:
92883
- return ts.Debug.failBadSyntaxKind(node.literal);
92884
- }
92885
- case 147 /* NumberKeyword */:
92886
- return factory.createIdentifier("Number");
92887
- case 158 /* BigIntKeyword */:
92888
- return getGlobalBigIntNameWithFallback();
92889
- case 151 /* SymbolKeyword */:
92890
- return languageVersion < 2 /* ES2015 */
92891
- ? getGlobalSymbolNameWithFallback()
92892
- : factory.createIdentifier("Symbol");
92893
- case 178 /* TypeReference */:
92894
- return serializeTypeReferenceNode(node);
92895
- case 188 /* IntersectionType */:
92896
- case 187 /* UnionType */:
92897
- return serializeTypeList(node.types);
92898
- case 189 /* ConditionalType */:
92899
- return serializeTypeList([node.trueType, node.falseType]);
92900
- case 193 /* TypeOperator */:
92901
- if (node.operator === 145 /* ReadonlyKeyword */) {
92902
- return serializeTypeNode(node.type);
92903
- }
92904
- break;
92905
- case 181 /* TypeQuery */:
92906
- case 194 /* IndexedAccessType */:
92907
- case 195 /* MappedType */:
92908
- case 182 /* TypeLiteral */:
92909
- case 130 /* AnyKeyword */:
92910
- case 155 /* UnknownKeyword */:
92911
- case 192 /* ThisType */:
92912
- case 200 /* ImportType */:
92913
- break;
92914
- // handle JSDoc types from an invalid parse
92915
- case 312 /* JSDocAllType */:
92916
- case 313 /* JSDocUnknownType */:
92917
- case 317 /* JSDocFunctionType */:
92918
- case 318 /* JSDocVariadicType */:
92919
- case 319 /* JSDocNamepathType */:
92920
- break;
92921
- case 314 /* JSDocNullableType */:
92922
- case 315 /* JSDocNonNullableType */:
92923
- case 316 /* JSDocOptionalType */:
92924
- return serializeTypeNode(node.type);
92925
- default:
92926
- return ts.Debug.failBadSyntaxKind(node);
92927
- }
92928
- return factory.createIdentifier("Object");
92929
- }
92930
- function serializeTypeList(types) {
92931
- // Note when updating logic here also update getEntityNameForDecoratorMetadata
92932
- // so that aliases can be marked as referenced
92933
- var serializedUnion;
92934
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
92935
- var typeNode = types_22[_i];
92936
- while (typeNode.kind === 191 /* ParenthesizedType */) {
92937
- typeNode = typeNode.type; // Skip parens if need be
92938
- }
92939
- if (typeNode.kind === 143 /* NeverKeyword */) {
92940
- continue; // Always elide `never` from the union/intersection if possible
92941
- }
92942
- if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
92943
- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
92944
- }
92945
- var serializedIndividual = serializeTypeNode(typeNode);
92946
- if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
92947
- // One of the individual is global object, return immediately
92948
- return serializedIndividual;
92949
- }
92950
- // If there exists union that is not void 0 expression, check if the the common type is identifier.
92951
- // anything more complex and we will just default to Object
92952
- else if (serializedUnion) {
92953
- // Different types
92954
- if (!ts.isIdentifier(serializedUnion) ||
92955
- !ts.isIdentifier(serializedIndividual) ||
92956
- serializedUnion.escapedText !== serializedIndividual.escapedText) {
92957
- return factory.createIdentifier("Object");
92958
- }
92959
- }
92960
- else {
92961
- // Initialize the union type
92962
- serializedUnion = serializedIndividual;
92963
- }
92964
- }
92965
- // If we were able to find common type, use it
92966
- return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
92967
- }
92968
- /**
92969
- * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
92970
- * decorator type metadata.
92971
- *
92972
- * @param node The type reference node.
92973
- */
92974
- function serializeTypeReferenceNode(node) {
92975
- var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
92976
- switch (kind) {
92977
- case ts.TypeReferenceSerializationKind.Unknown:
92978
- // From conditional type type reference that cannot be resolved is Similar to any or unknown
92979
- if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
92980
- return factory.createIdentifier("Object");
92981
- }
92982
- var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
92983
- var temp = factory.createTempVariable(hoistVariableDeclaration);
92984
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
92985
- /*questionToken*/ undefined, temp,
92986
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
92987
- case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
92988
- return serializeEntityNameAsExpression(node.typeName);
92989
- case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
92990
- return factory.createVoidZero();
92991
- case ts.TypeReferenceSerializationKind.BigIntLikeType:
92992
- return getGlobalBigIntNameWithFallback();
92993
- case ts.TypeReferenceSerializationKind.BooleanType:
92994
- return factory.createIdentifier("Boolean");
92995
- case ts.TypeReferenceSerializationKind.NumberLikeType:
92996
- return factory.createIdentifier("Number");
92997
- case ts.TypeReferenceSerializationKind.StringLikeType:
92998
- return factory.createIdentifier("String");
92999
- case ts.TypeReferenceSerializationKind.ArrayLikeType:
93000
- return factory.createIdentifier("Array");
93001
- case ts.TypeReferenceSerializationKind.ESSymbolType:
93002
- return languageVersion < 2 /* ES2015 */
93003
- ? getGlobalSymbolNameWithFallback()
93004
- : factory.createIdentifier("Symbol");
93005
- case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
93006
- return factory.createIdentifier("Function");
93007
- case ts.TypeReferenceSerializationKind.Promise:
93008
- return factory.createIdentifier("Promise");
93009
- case ts.TypeReferenceSerializationKind.ObjectType:
93010
- return factory.createIdentifier("Object");
93011
- default:
93012
- return ts.Debug.assertNever(kind);
93013
- }
93014
- }
93015
- function createCheckedValue(left, right) {
93016
- return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
93017
- }
93018
- /**
93019
- * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
93020
- *
93021
- * @param node The entity name to serialize.
93022
- */
93023
- function serializeEntityNameAsExpressionFallback(node) {
93024
- if (node.kind === 79 /* Identifier */) {
93025
- // A -> typeof A !== undefined && A
93026
- var copied = serializeEntityNameAsExpression(node);
93027
- return createCheckedValue(copied, copied);
93028
- }
93029
- if (node.left.kind === 79 /* Identifier */) {
93030
- // A.B -> typeof A !== undefined && A.B
93031
- return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
93032
- }
93033
- // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
93034
- var left = serializeEntityNameAsExpressionFallback(node.left);
93035
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93036
- return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
93037
- }
93038
- /**
93039
- * Serializes an entity name as an expression for decorator type metadata.
93040
- *
93041
- * @param node The entity name to serialize.
93042
- */
93043
- function serializeEntityNameAsExpression(node) {
93044
- switch (node.kind) {
93045
- case 79 /* Identifier */:
93046
- // Create a clone of the name with a new parent, and treat it as if it were
93047
- // a source tree node for the purposes of the checker.
93048
- var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
93049
- name.original = undefined;
93050
- ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
93051
- return name;
93052
- case 161 /* QualifiedName */:
93053
- return serializeQualifiedNameAsExpression(node);
93054
- }
93055
- }
93056
- /**
93057
- * Serializes an qualified name as an expression for decorator type metadata.
93058
- *
93059
- * @param node The qualified name to serialize.
93060
- * @param useFallback A value indicating whether to use logical operators to test for the
93061
- * qualified name at runtime.
93062
- */
93063
- function serializeQualifiedNameAsExpression(node) {
93064
- return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
93065
- }
93066
- /**
93067
- * Gets an expression that points to the global "Symbol" constructor at runtime if it is
93068
- * available.
93069
- */
93070
- function getGlobalSymbolNameWithFallback() {
93071
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
93072
- /*questionToken*/ undefined, factory.createIdentifier("Symbol"),
93073
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93074
- }
93075
- /**
93076
- * Gets an expression that points to the global "BigInt" constructor at runtime if it is
93077
- * available.
93078
- */
93079
- function getGlobalBigIntNameWithFallback() {
93080
- return languageVersion < 99 /* ESNext */
93081
- ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
93082
- /*questionToken*/ undefined, factory.createIdentifier("BigInt"),
93083
- /*colonToken*/ undefined, factory.createIdentifier("Object"))
93084
- : factory.createIdentifier("BigInt");
93085
- }
93086
92630
  /**
93087
92631
  * Gets an expression that represents a property name (for decorated properties or enums).
93088
92632
  * For a computed property, a name is generated for the node.
@@ -93167,21 +92711,23 @@ var ts;
93167
92711
  function shouldEmitFunctionLikeDeclaration(node) {
93168
92712
  return !ts.nodeIsMissing(node.body);
93169
92713
  }
93170
- function visitPropertyDeclaration(node) {
93171
- if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92714
+ function visitPropertyDeclaration(node, parent) {
92715
+ var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
92716
+ if (isAmbient && !ts.some(node.decorators)) {
93172
92717
  return undefined;
93173
92718
  }
93174
- var updated = factory.updatePropertyDeclaration(node,
93175
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
92719
+ var allDecorators = getAllDecoratorsOfClassElement(node, parent);
92720
+ var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
92721
+ // Preserve a `declare x` property with decorators to be handled by the decorators transform
92722
+ if (isAmbient) {
92723
+ return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
92724
+ /*questionOrExclamationToken*/ undefined,
92725
+ /*type*/ undefined,
92726
+ /*initializer*/ undefined);
92727
+ }
92728
+ return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
93176
92729
  /*questionOrExclamationToken*/ undefined,
93177
92730
  /*type*/ undefined, ts.visitNode(node.initializer, visitor));
93178
- if (updated !== node) {
93179
- // While we emit the source map for the node after skipping decorators and modifiers,
93180
- // we need to emit the comments for the original range.
93181
- ts.setCommentRange(updated, node);
93182
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93183
- }
93184
- return updated;
93185
92731
  }
93186
92732
  function visitConstructor(node) {
93187
92733
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93189,7 +92735,7 @@ var ts;
93189
92735
  }
93190
92736
  return factory.updateConstructorDeclaration(node,
93191
92737
  /*decorators*/ undefined,
93192
- /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
92738
+ /*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
93193
92739
  }
93194
92740
  function transformConstructorBody(body, constructor) {
93195
92741
  var parametersWithPropertyAssignments = constructor &&
@@ -93253,22 +92799,19 @@ var ts;
93253
92799
  ts.setEmitFlags(localName, 1536 /* NoComments */);
93254
92800
  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))));
93255
92801
  }
93256
- function visitMethodDeclaration(node) {
92802
+ function visitMethodDeclaration(node, parent) {
92803
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92804
+ return node;
92805
+ }
93257
92806
  if (!shouldEmitFunctionLikeDeclaration(node)) {
93258
92807
  return undefined;
93259
92808
  }
93260
- var updated = factory.updateMethodDeclaration(node,
93261
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
92809
+ var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
92810
+ var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
92811
+ return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93262
92812
  /*questionToken*/ undefined,
93263
92813
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
93264
92814
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
93265
- if (updated !== node) {
93266
- // While we emit the source map for the node after skipping decorators and modifiers,
93267
- // we need to emit the comments for the original range.
93268
- ts.setCommentRange(updated, node);
93269
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93270
- }
93271
- return updated;
93272
92815
  }
93273
92816
  /**
93274
92817
  * Determines whether to emit an accessor declaration. We should not emit the
@@ -93279,34 +92822,30 @@ var ts;
93279
92822
  function shouldEmitAccessorDeclaration(node) {
93280
92823
  return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
93281
92824
  }
93282
- function visitGetAccessor(node) {
92825
+ function visitGetAccessor(node, parent) {
92826
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92827
+ return node;
92828
+ }
93283
92829
  if (!shouldEmitAccessorDeclaration(node)) {
93284
92830
  return undefined;
93285
92831
  }
93286
- var updated = factory.updateGetAccessorDeclaration(node,
93287
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
92832
+ var decorators = ts.isClassLike(parent) ?
92833
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92834
+ undefined;
92835
+ return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93288
92836
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93289
- if (updated !== node) {
93290
- // While we emit the source map for the node after skipping decorators and modifiers,
93291
- // we need to emit the comments for the original range.
93292
- ts.setCommentRange(updated, node);
93293
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93294
- }
93295
- return updated;
93296
92837
  }
93297
- function visitSetAccessor(node) {
92838
+ function visitSetAccessor(node, parent) {
92839
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92840
+ return node;
92841
+ }
93298
92842
  if (!shouldEmitAccessorDeclaration(node)) {
93299
92843
  return undefined;
93300
92844
  }
93301
- var updated = factory.updateSetAccessorDeclaration(node,
93302
- /*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([]));
93303
- if (updated !== node) {
93304
- // While we emit the source map for the node after skipping decorators and modifiers,
93305
- // we need to emit the comments for the original range.
93306
- ts.setCommentRange(updated, node);
93307
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93308
- }
93309
- return updated;
92845
+ var decorators = ts.isClassLike(parent) ?
92846
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92847
+ undefined;
92848
+ 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([]));
93310
92849
  }
93311
92850
  function visitFunctionDeclaration(node) {
93312
92851
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93342,9 +92881,9 @@ var ts;
93342
92881
  if (ts.parameterIsThisKeyword(node)) {
93343
92882
  return undefined;
93344
92883
  }
93345
- var updated = factory.updateParameterDeclaration(node,
93346
- /*decorators*/ undefined,
93347
- /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
92884
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92885
+ ts.elideNodes(factory, node.modifiers), // preserve positions, if available
92886
+ node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93348
92887
  /*questionToken*/ undefined,
93349
92888
  /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
93350
92889
  if (updated !== node) {
@@ -94040,12 +93579,6 @@ var ts;
94040
93579
  return isExternalModuleExport(node)
94041
93580
  && ts.hasSyntacticModifier(node, 512 /* Default */);
94042
93581
  }
94043
- /**
94044
- * Creates a statement for the provided expression. This is used in calls to `map`.
94045
- */
94046
- function expressionToStatement(expression) {
94047
- return factory.createExpressionStatement(expression);
94048
- }
94049
93582
  function addExportMemberAssignment(statements, node) {
94050
93583
  var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
94051
93584
  ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
@@ -94077,44 +93610,12 @@ var ts;
94077
93610
  function getNamespaceContainerName(node) {
94078
93611
  return factory.getGeneratedNameForNode(node);
94079
93612
  }
94080
- /**
94081
- * Gets a local alias for a class declaration if it is a decorated class with an internal
94082
- * reference to the static side of the class. This is necessary to avoid issues with
94083
- * double-binding semantics for the class name.
94084
- */
94085
- function getClassAliasIfNeeded(node) {
94086
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
94087
- enableSubstitutionForClassAliases();
94088
- var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
94089
- classAliases[ts.getOriginalNodeId(node)] = classAlias;
94090
- hoistVariableDeclaration(classAlias);
94091
- return classAlias;
94092
- }
94093
- }
94094
- function getClassPrototype(node) {
94095
- return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
94096
- }
94097
- function getClassMemberPrefix(node, member) {
94098
- return ts.isStatic(member)
94099
- ? factory.getDeclarationName(node)
94100
- : getClassPrototype(node);
94101
- }
94102
93613
  function enableSubstitutionForNonQualifiedEnumMembers() {
94103
93614
  if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
94104
93615
  enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
94105
93616
  context.enableSubstitution(79 /* Identifier */);
94106
93617
  }
94107
93618
  }
94108
- function enableSubstitutionForClassAliases() {
94109
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
94110
- enabledSubstitutions |= 1 /* ClassAliases */;
94111
- // We need to enable substitutions for identifiers. This allows us to
94112
- // substitute class names inside of a class declaration.
94113
- context.enableSubstitution(79 /* Identifier */);
94114
- // Keep track of class aliases.
94115
- classAliases = [];
94116
- }
94117
- }
94118
93619
  function enableSubstitutionForNamespaceExports() {
94119
93620
  if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
94120
93621
  enabledSubstitutions |= 2 /* NamespaceExports */;
@@ -94199,32 +93700,9 @@ var ts;
94199
93700
  return node;
94200
93701
  }
94201
93702
  function substituteExpressionIdentifier(node) {
94202
- return trySubstituteClassAlias(node)
94203
- || trySubstituteNamespaceExportedName(node)
93703
+ return trySubstituteNamespaceExportedName(node)
94204
93704
  || node;
94205
93705
  }
94206
- function trySubstituteClassAlias(node) {
94207
- if (enabledSubstitutions & 1 /* ClassAliases */) {
94208
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
94209
- // Due to the emit for class decorators, any reference to the class from inside of the class body
94210
- // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
94211
- // behavior of class names in ES6.
94212
- // Also, when emitting statics for class expressions, we must substitute a class alias for
94213
- // constructor references in static property initializers.
94214
- var declaration = resolver.getReferencedValueDeclaration(node);
94215
- if (declaration) {
94216
- var classAlias = classAliases[declaration.id]; // TODO: GH#18217
94217
- if (classAlias) {
94218
- var clone_2 = factory.cloneNode(classAlias);
94219
- ts.setSourceMapRange(clone_2, node);
94220
- ts.setCommentRange(clone_2, node);
94221
- return clone_2;
94222
- }
94223
- }
94224
- }
94225
- }
94226
- return undefined;
94227
- }
94228
93706
  function trySubstituteNamespaceExportedName(node) {
94229
93707
  // If this is explicitly a local name, do not substitute.
94230
93708
  if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
@@ -94362,7 +93840,7 @@ var ts;
94362
93840
  return visited;
94363
93841
  }
94364
93842
  function visitorWorker(node, valueIsDiscarded) {
94365
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
93843
+ if (node.transformFlags & 16777216 /* ContainsClassFields */) {
94366
93844
  switch (node.kind) {
94367
93845
  case 226 /* ClassExpression */:
94368
93846
  case 257 /* ClassDeclaration */:
@@ -94377,8 +93855,8 @@ var ts;
94377
93855
  return visitClassStaticBlockDeclaration(node);
94378
93856
  }
94379
93857
  }
94380
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
94381
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
93858
+ if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
93859
+ node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
94382
93860
  shouldTransformSuperInStaticInitializers &&
94383
93861
  currentStaticPropertyDeclarationOrStaticBlock &&
94384
93862
  currentClassLexicalEnvironment) {
@@ -94952,13 +94430,13 @@ var ts;
94952
94430
  facts |= 2 /* NeedsClassConstructorReference */;
94953
94431
  }
94954
94432
  if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
94955
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
94433
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
94956
94434
  facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
94957
94435
  if (!(facts & 1 /* ClassWasDecorated */)) {
94958
94436
  facts |= 2 /* NeedsClassConstructorReference */;
94959
94437
  }
94960
94438
  }
94961
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
94439
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
94962
94440
  if (!(facts & 1 /* ClassWasDecorated */)) {
94963
94441
  facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
94964
94442
  }
@@ -95543,10 +95021,10 @@ var ts;
95543
95021
  if (declaration) {
95544
95022
  var classAlias = classAliases[declaration.id]; // TODO: GH#18217
95545
95023
  if (classAlias) {
95546
- var clone_3 = factory.cloneNode(classAlias);
95547
- ts.setSourceMapRange(clone_3, node);
95548
- ts.setCommentRange(clone_3, node);
95549
- return clone_3;
95024
+ var clone_2 = factory.cloneNode(classAlias);
95025
+ ts.setSourceMapRange(clone_2, node);
95026
+ ts.setCommentRange(clone_2, node);
95027
+ return clone_2;
95550
95028
  }
95551
95029
  }
95552
95030
  }
@@ -95908,6 +95386,965 @@ var ts;
95908
95386
  })(ts || (ts = {}));
95909
95387
  /*@internal*/
95910
95388
  var ts;
95389
+ (function (ts) {
95390
+ function createRuntimeTypeSerializer(context) {
95391
+ var hoistVariableDeclaration = context.hoistVariableDeclaration;
95392
+ var resolver = context.getEmitResolver();
95393
+ var compilerOptions = context.getCompilerOptions();
95394
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95395
+ var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
95396
+ var currentLexicalScope;
95397
+ var currentNameScope;
95398
+ return {
95399
+ serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
95400
+ serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
95401
+ serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
95402
+ serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
95403
+ };
95404
+ function setSerializerContextAnd(serializerContext, cb, node, arg) {
95405
+ var savedCurrentLexicalScope = currentLexicalScope;
95406
+ var savedCurrentNameScope = currentNameScope;
95407
+ currentLexicalScope = serializerContext.currentLexicalScope;
95408
+ currentNameScope = serializerContext.currentNameScope;
95409
+ var result = arg === undefined ? cb(node) : cb(node, arg);
95410
+ currentLexicalScope = savedCurrentLexicalScope;
95411
+ currentNameScope = savedCurrentNameScope;
95412
+ return result;
95413
+ }
95414
+ function getAccessorTypeNode(node) {
95415
+ var accessors = resolver.getAllAccessorDeclarations(node);
95416
+ return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
95417
+ || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
95418
+ }
95419
+ /**
95420
+ * Serializes the type of a node for use with decorator type metadata.
95421
+ * @param node The node that should have its type serialized.
95422
+ */
95423
+ function serializeTypeOfNode(node) {
95424
+ switch (node.kind) {
95425
+ case 167 /* PropertyDeclaration */:
95426
+ case 164 /* Parameter */:
95427
+ return serializeTypeNode(node.type);
95428
+ case 173 /* SetAccessor */:
95429
+ case 172 /* GetAccessor */:
95430
+ return serializeTypeNode(getAccessorTypeNode(node));
95431
+ case 257 /* ClassDeclaration */:
95432
+ case 226 /* ClassExpression */:
95433
+ case 169 /* MethodDeclaration */:
95434
+ return ts.factory.createIdentifier("Function");
95435
+ default:
95436
+ return ts.factory.createVoidZero();
95437
+ }
95438
+ }
95439
+ /**
95440
+ * Serializes the type of a node for use with decorator type metadata.
95441
+ * @param node The node that should have its type serialized.
95442
+ */
95443
+ function serializeParameterTypesOfNode(node, container) {
95444
+ var valueDeclaration = ts.isClassLike(node)
95445
+ ? ts.getFirstConstructorWithBody(node)
95446
+ : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
95447
+ ? node
95448
+ : undefined;
95449
+ var expressions = [];
95450
+ if (valueDeclaration) {
95451
+ var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
95452
+ var numParameters = parameters.length;
95453
+ for (var i = 0; i < numParameters; i++) {
95454
+ var parameter = parameters[i];
95455
+ if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
95456
+ continue;
95457
+ }
95458
+ if (parameter.dotDotDotToken) {
95459
+ expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
95460
+ }
95461
+ else {
95462
+ expressions.push(serializeTypeOfNode(parameter));
95463
+ }
95464
+ }
95465
+ }
95466
+ return ts.factory.createArrayLiteralExpression(expressions);
95467
+ }
95468
+ function getParametersOfDecoratedDeclaration(node, container) {
95469
+ if (container && node.kind === 172 /* GetAccessor */) {
95470
+ var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
95471
+ if (setAccessor) {
95472
+ return setAccessor.parameters;
95473
+ }
95474
+ }
95475
+ return node.parameters;
95476
+ }
95477
+ /**
95478
+ * Serializes the return type of a node for use with decorator type metadata.
95479
+ * @param node The node that should have its return type serialized.
95480
+ */
95481
+ function serializeReturnTypeOfNode(node) {
95482
+ if (ts.isFunctionLike(node) && node.type) {
95483
+ return serializeTypeNode(node.type);
95484
+ }
95485
+ else if (ts.isAsyncFunction(node)) {
95486
+ return ts.factory.createIdentifier("Promise");
95487
+ }
95488
+ return ts.factory.createVoidZero();
95489
+ }
95490
+ /**
95491
+ * Serializes a type node for use with decorator type metadata.
95492
+ *
95493
+ * Types are serialized in the following fashion:
95494
+ * - Void types point to "undefined" (e.g. "void 0")
95495
+ * - Function and Constructor types point to the global "Function" constructor.
95496
+ * - Interface types with a call or construct signature types point to the global
95497
+ * "Function" constructor.
95498
+ * - Array and Tuple types point to the global "Array" constructor.
95499
+ * - Type predicates and booleans point to the global "Boolean" constructor.
95500
+ * - String literal types and strings point to the global "String" constructor.
95501
+ * - Enum and number types point to the global "Number" constructor.
95502
+ * - Symbol types point to the global "Symbol" constructor.
95503
+ * - Type references to classes (or class-like variables) point to the constructor for the class.
95504
+ * - Anything else points to the global "Object" constructor.
95505
+ *
95506
+ * @param node The type node to serialize.
95507
+ */
95508
+ function serializeTypeNode(node) {
95509
+ if (node === undefined) {
95510
+ return ts.factory.createIdentifier("Object");
95511
+ }
95512
+ node = ts.skipTypeParentheses(node);
95513
+ switch (node.kind) {
95514
+ case 114 /* VoidKeyword */:
95515
+ case 153 /* UndefinedKeyword */:
95516
+ case 143 /* NeverKeyword */:
95517
+ return ts.factory.createVoidZero();
95518
+ case 179 /* FunctionType */:
95519
+ case 180 /* ConstructorType */:
95520
+ return ts.factory.createIdentifier("Function");
95521
+ case 183 /* ArrayType */:
95522
+ case 184 /* TupleType */:
95523
+ return ts.factory.createIdentifier("Array");
95524
+ case 177 /* TypePredicate */:
95525
+ return node.assertsModifier ?
95526
+ ts.factory.createVoidZero() :
95527
+ ts.factory.createIdentifier("Boolean");
95528
+ case 133 /* BooleanKeyword */:
95529
+ return ts.factory.createIdentifier("Boolean");
95530
+ case 198 /* TemplateLiteralType */:
95531
+ case 150 /* StringKeyword */:
95532
+ return ts.factory.createIdentifier("String");
95533
+ case 148 /* ObjectKeyword */:
95534
+ return ts.factory.createIdentifier("Object");
95535
+ case 196 /* LiteralType */:
95536
+ return serializeLiteralOfLiteralTypeNode(node.literal);
95537
+ case 147 /* NumberKeyword */:
95538
+ return ts.factory.createIdentifier("Number");
95539
+ case 158 /* BigIntKeyword */:
95540
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95541
+ case 151 /* SymbolKeyword */:
95542
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95543
+ case 178 /* TypeReference */:
95544
+ return serializeTypeReferenceNode(node);
95545
+ case 188 /* IntersectionType */:
95546
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
95547
+ case 187 /* UnionType */:
95548
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
95549
+ case 189 /* ConditionalType */:
95550
+ return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
95551
+ case 193 /* TypeOperator */:
95552
+ if (node.operator === 145 /* ReadonlyKeyword */) {
95553
+ return serializeTypeNode(node.type);
95554
+ }
95555
+ break;
95556
+ case 181 /* TypeQuery */:
95557
+ case 194 /* IndexedAccessType */:
95558
+ case 195 /* MappedType */:
95559
+ case 182 /* TypeLiteral */:
95560
+ case 130 /* AnyKeyword */:
95561
+ case 155 /* UnknownKeyword */:
95562
+ case 192 /* ThisType */:
95563
+ case 200 /* ImportType */:
95564
+ break;
95565
+ // handle JSDoc types from an invalid parse
95566
+ case 312 /* JSDocAllType */:
95567
+ case 313 /* JSDocUnknownType */:
95568
+ case 317 /* JSDocFunctionType */:
95569
+ case 318 /* JSDocVariadicType */:
95570
+ case 319 /* JSDocNamepathType */:
95571
+ break;
95572
+ case 314 /* JSDocNullableType */:
95573
+ case 315 /* JSDocNonNullableType */:
95574
+ case 316 /* JSDocOptionalType */:
95575
+ return serializeTypeNode(node.type);
95576
+ default:
95577
+ return ts.Debug.failBadSyntaxKind(node);
95578
+ }
95579
+ return ts.factory.createIdentifier("Object");
95580
+ }
95581
+ function serializeLiteralOfLiteralTypeNode(node) {
95582
+ switch (node.kind) {
95583
+ case 10 /* StringLiteral */:
95584
+ case 14 /* NoSubstitutionTemplateLiteral */:
95585
+ return ts.factory.createIdentifier("String");
95586
+ case 219 /* PrefixUnaryExpression */: {
95587
+ var operand = node.operand;
95588
+ switch (operand.kind) {
95589
+ case 8 /* NumericLiteral */:
95590
+ case 9 /* BigIntLiteral */:
95591
+ return serializeLiteralOfLiteralTypeNode(operand);
95592
+ default:
95593
+ return ts.Debug.failBadSyntaxKind(operand);
95594
+ }
95595
+ }
95596
+ case 8 /* NumericLiteral */:
95597
+ return ts.factory.createIdentifier("Number");
95598
+ case 9 /* BigIntLiteral */:
95599
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95600
+ case 110 /* TrueKeyword */:
95601
+ case 95 /* FalseKeyword */:
95602
+ return ts.factory.createIdentifier("Boolean");
95603
+ case 104 /* NullKeyword */:
95604
+ return ts.factory.createVoidZero();
95605
+ default:
95606
+ return ts.Debug.failBadSyntaxKind(node);
95607
+ }
95608
+ }
95609
+ function serializeUnionOrIntersectionConstituents(types, isIntersection) {
95610
+ // Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
95611
+ var serializedType;
95612
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
95613
+ var typeNode = types_22[_i];
95614
+ typeNode = ts.skipTypeParentheses(typeNode);
95615
+ if (typeNode.kind === 143 /* NeverKeyword */) {
95616
+ if (isIntersection)
95617
+ return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
95618
+ continue; // Elide `never` in a union
95619
+ }
95620
+ if (typeNode.kind === 155 /* UnknownKeyword */) {
95621
+ if (!isIntersection)
95622
+ return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
95623
+ continue; // Elide `unknown` in an intersection
95624
+ }
95625
+ if (typeNode.kind === 130 /* AnyKeyword */) {
95626
+ return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
95627
+ }
95628
+ if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
95629
+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
95630
+ }
95631
+ var serializedConstituent = serializeTypeNode(typeNode);
95632
+ if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
95633
+ // One of the individual is global object, return immediately
95634
+ return serializedConstituent;
95635
+ }
95636
+ // If there exists union that is not `void 0` expression, check if the the common type is identifier.
95637
+ // anything more complex and we will just default to Object
95638
+ if (serializedType) {
95639
+ // Different types
95640
+ if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
95641
+ return ts.factory.createIdentifier("Object");
95642
+ }
95643
+ }
95644
+ else {
95645
+ // Initialize the union type
95646
+ serializedType = serializedConstituent;
95647
+ }
95648
+ }
95649
+ // If we were able to find common type, use it
95650
+ return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
95651
+ }
95652
+ function equateSerializedTypeNodes(left, right) {
95653
+ return (
95654
+ // temp vars used in fallback
95655
+ ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
95656
+ // entity names
95657
+ ts.isIdentifier(left) ? ts.isIdentifier(right)
95658
+ && left.escapedText === right.escapedText :
95659
+ ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
95660
+ && equateSerializedTypeNodes(left.expression, right.expression)
95661
+ && equateSerializedTypeNodes(left.name, right.name) :
95662
+ // `void 0`
95663
+ ts.isVoidExpression(left) ? ts.isVoidExpression(right)
95664
+ && ts.isNumericLiteral(left.expression) && left.expression.text === "0"
95665
+ && ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
95666
+ // `"undefined"` or `"function"` in `typeof` checks
95667
+ ts.isStringLiteral(left) ? ts.isStringLiteral(right)
95668
+ && left.text === right.text :
95669
+ // used in `typeof` checks for fallback
95670
+ ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
95671
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95672
+ // parens in `typeof` checks with temps
95673
+ ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
95674
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95675
+ // conditionals used in fallback
95676
+ ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
95677
+ && equateSerializedTypeNodes(left.condition, right.condition)
95678
+ && equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
95679
+ && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
95680
+ // logical binary and assignments used in fallback
95681
+ ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
95682
+ && left.operatorToken.kind === right.operatorToken.kind
95683
+ && equateSerializedTypeNodes(left.left, right.left)
95684
+ && equateSerializedTypeNodes(left.right, right.right) :
95685
+ false);
95686
+ }
95687
+ /**
95688
+ * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
95689
+ * @param node The type reference node.
95690
+ */
95691
+ function serializeTypeReferenceNode(node) {
95692
+ var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
95693
+ switch (kind) {
95694
+ case ts.TypeReferenceSerializationKind.Unknown:
95695
+ // From conditional type type reference that cannot be resolved is Similar to any or unknown
95696
+ if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
95697
+ return ts.factory.createIdentifier("Object");
95698
+ }
95699
+ var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
95700
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95701
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
95702
+ /*questionToken*/ undefined, temp,
95703
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95704
+ case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
95705
+ return serializeEntityNameAsExpression(node.typeName);
95706
+ case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
95707
+ return ts.factory.createVoidZero();
95708
+ case ts.TypeReferenceSerializationKind.BigIntLikeType:
95709
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95710
+ case ts.TypeReferenceSerializationKind.BooleanType:
95711
+ return ts.factory.createIdentifier("Boolean");
95712
+ case ts.TypeReferenceSerializationKind.NumberLikeType:
95713
+ return ts.factory.createIdentifier("Number");
95714
+ case ts.TypeReferenceSerializationKind.StringLikeType:
95715
+ return ts.factory.createIdentifier("String");
95716
+ case ts.TypeReferenceSerializationKind.ArrayLikeType:
95717
+ return ts.factory.createIdentifier("Array");
95718
+ case ts.TypeReferenceSerializationKind.ESSymbolType:
95719
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95720
+ case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
95721
+ return ts.factory.createIdentifier("Function");
95722
+ case ts.TypeReferenceSerializationKind.Promise:
95723
+ return ts.factory.createIdentifier("Promise");
95724
+ case ts.TypeReferenceSerializationKind.ObjectType:
95725
+ return ts.factory.createIdentifier("Object");
95726
+ default:
95727
+ return ts.Debug.assertNever(kind);
95728
+ }
95729
+ }
95730
+ /**
95731
+ * Produces an expression that results in `right` if `left` is not undefined at runtime:
95732
+ *
95733
+ * ```
95734
+ * typeof left !== "undefined" && right
95735
+ * ```
95736
+ *
95737
+ * We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
95738
+ * It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
95739
+ * further checked by any containing expression.
95740
+ */
95741
+ function createCheckedValue(left, right) {
95742
+ return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
95743
+ }
95744
+ /**
95745
+ * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
95746
+ * @param node The entity name to serialize.
95747
+ */
95748
+ function serializeEntityNameAsExpressionFallback(node) {
95749
+ if (node.kind === 79 /* Identifier */) {
95750
+ // A -> typeof A !== "undefined" && A
95751
+ var copied = serializeEntityNameAsExpression(node);
95752
+ return createCheckedValue(copied, copied);
95753
+ }
95754
+ if (node.left.kind === 79 /* Identifier */) {
95755
+ // A.B -> typeof A !== "undefined" && A.B
95756
+ return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
95757
+ }
95758
+ // A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
95759
+ var left = serializeEntityNameAsExpressionFallback(node.left);
95760
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95761
+ 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));
95762
+ }
95763
+ /**
95764
+ * Serializes an entity name as an expression for decorator type metadata.
95765
+ * @param node The entity name to serialize.
95766
+ */
95767
+ function serializeEntityNameAsExpression(node) {
95768
+ switch (node.kind) {
95769
+ case 79 /* Identifier */:
95770
+ // Create a clone of the name with a new parent, and treat it as if it were
95771
+ // a source tree node for the purposes of the checker.
95772
+ var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
95773
+ name.original = undefined;
95774
+ ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
95775
+ return name;
95776
+ case 161 /* QualifiedName */:
95777
+ return serializeQualifiedNameAsExpression(node);
95778
+ }
95779
+ }
95780
+ /**
95781
+ * Serializes an qualified name as an expression for decorator type metadata.
95782
+ * @param node The qualified name to serialize.
95783
+ */
95784
+ function serializeQualifiedNameAsExpression(node) {
95785
+ return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
95786
+ }
95787
+ function getGlobalConstructorWithFallback(name) {
95788
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
95789
+ /*questionToken*/ undefined, ts.factory.createIdentifier(name),
95790
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95791
+ }
95792
+ function getGlobalConstructor(name, minLanguageVersion) {
95793
+ return languageVersion < minLanguageVersion ?
95794
+ getGlobalConstructorWithFallback(name) :
95795
+ ts.factory.createIdentifier(name);
95796
+ }
95797
+ }
95798
+ ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
95799
+ })(ts || (ts = {}));
95800
+ /*@internal*/
95801
+ var ts;
95802
+ (function (ts) {
95803
+ function transformLegacyDecorators(context) {
95804
+ var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
95805
+ var resolver = context.getEmitResolver();
95806
+ var compilerOptions = context.getCompilerOptions();
95807
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95808
+ // Save the previous transformation hooks.
95809
+ var previousOnSubstituteNode = context.onSubstituteNode;
95810
+ // Set new transformation hooks.
95811
+ context.onSubstituteNode = onSubstituteNode;
95812
+ /**
95813
+ * A map that keeps track of aliases created for classes with decorators to avoid issues
95814
+ * with the double-binding behavior of classes.
95815
+ */
95816
+ var classAliases;
95817
+ return ts.chainBundle(context, transformSourceFile);
95818
+ function transformSourceFile(node) {
95819
+ var visited = ts.visitEachChild(node, visitor, context);
95820
+ ts.addEmitHelpers(visited, context.readEmitHelpers());
95821
+ return visited;
95822
+ }
95823
+ function visitor(node) {
95824
+ if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
95825
+ return node;
95826
+ }
95827
+ switch (node.kind) {
95828
+ case 165 /* Decorator */:
95829
+ // Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
95830
+ return undefined;
95831
+ case 257 /* ClassDeclaration */:
95832
+ return visitClassDeclaration(node);
95833
+ case 226 /* ClassExpression */:
95834
+ return visitClassExpression(node);
95835
+ case 171 /* Constructor */:
95836
+ return visitConstructorDeclaration(node);
95837
+ case 169 /* MethodDeclaration */:
95838
+ return visitMethodDeclaration(node);
95839
+ case 173 /* SetAccessor */:
95840
+ return visitSetAccessorDeclaration(node);
95841
+ case 172 /* GetAccessor */:
95842
+ return visitGetAccessorDeclaration(node);
95843
+ case 170 /* ClassStaticBlockDeclaration */:
95844
+ return visitClassStaticBlockDeclaration(node);
95845
+ case 167 /* PropertyDeclaration */:
95846
+ return visitPropertyDeclaration(node);
95847
+ case 164 /* Parameter */:
95848
+ return visitParameterDeclaration(node);
95849
+ default:
95850
+ return ts.visitEachChild(node, visitor, context);
95851
+ }
95852
+ }
95853
+ function visitClassDeclaration(node) {
95854
+ if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
95855
+ return ts.visitEachChild(node, visitor, context);
95856
+ var classStatement = ts.some(node.decorators) ?
95857
+ createClassDeclarationHeadWithDecorators(node, node.name) :
95858
+ createClassDeclarationHeadWithoutDecorators(node, node.name);
95859
+ var statements = [classStatement];
95860
+ // Write any decorators of the node.
95861
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
95862
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
95863
+ addConstructorDecorationStatement(statements, node);
95864
+ if (statements.length > 1) {
95865
+ // Add a DeclarationMarker as a marker for the end of the declaration
95866
+ statements.push(factory.createEndOfDeclarationMarker(node));
95867
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
95868
+ }
95869
+ return ts.singleOrMany(statements);
95870
+ }
95871
+ /**
95872
+ * Transforms a non-decorated class declaration.
95873
+ *
95874
+ * @param node A ClassDeclaration node.
95875
+ * @param name The name of the class.
95876
+ */
95877
+ function createClassDeclarationHeadWithoutDecorators(node, name) {
95878
+ // ${modifiers} class ${name} ${heritageClauses} {
95879
+ // ${members}
95880
+ // }
95881
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
95882
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
95883
+ }
95884
+ /**
95885
+ * Transforms a decorated class declaration and appends the resulting statements. If
95886
+ * the class requires an alias to avoid issues with double-binding, the alias is returned.
95887
+ */
95888
+ function createClassDeclarationHeadWithDecorators(node, name) {
95889
+ // When we emit an ES6 class that has a class decorator, we must tailor the
95890
+ // emit to certain specific cases.
95891
+ //
95892
+ // In the simplest case, we emit the class declaration as a let declaration, and
95893
+ // evaluate decorators after the close of the class body:
95894
+ //
95895
+ // [Example 1]
95896
+ // ---------------------------------------------------------------------
95897
+ // TypeScript | Javascript
95898
+ // ---------------------------------------------------------------------
95899
+ // @dec | let C = class C {
95900
+ // class C { | }
95901
+ // } | C = __decorate([dec], C);
95902
+ // ---------------------------------------------------------------------
95903
+ // @dec | let C = class C {
95904
+ // export class C { | }
95905
+ // } | C = __decorate([dec], C);
95906
+ // | export { C };
95907
+ // ---------------------------------------------------------------------
95908
+ //
95909
+ // If a class declaration contains a reference to itself *inside* of the class body,
95910
+ // this introduces two bindings to the class: One outside of the class body, and one
95911
+ // inside of the class body. If we apply decorators as in [Example 1] above, there
95912
+ // is the possibility that the decorator `dec` will return a new value for the
95913
+ // constructor, which would result in the binding inside of the class no longer
95914
+ // pointing to the same reference as the binding outside of the class.
95915
+ //
95916
+ // As a result, we must instead rewrite all references to the class *inside* of the
95917
+ // class body to instead point to a local temporary alias for the class:
95918
+ //
95919
+ // [Example 2]
95920
+ // ---------------------------------------------------------------------
95921
+ // TypeScript | Javascript
95922
+ // ---------------------------------------------------------------------
95923
+ // @dec | let C = C_1 = class C {
95924
+ // class C { | static x() { return C_1.y; }
95925
+ // static x() { return C.y; } | }
95926
+ // static y = 1; | C.y = 1;
95927
+ // } | C = C_1 = __decorate([dec], C);
95928
+ // | var C_1;
95929
+ // ---------------------------------------------------------------------
95930
+ // @dec | let C = class C {
95931
+ // export class C { | static x() { return C_1.y; }
95932
+ // static x() { return C.y; } | }
95933
+ // static y = 1; | C.y = 1;
95934
+ // } | C = C_1 = __decorate([dec], C);
95935
+ // | export { C };
95936
+ // | var C_1;
95937
+ // ---------------------------------------------------------------------
95938
+ //
95939
+ // If a class declaration is the default export of a module, we instead emit
95940
+ // the export after the decorated declaration:
95941
+ //
95942
+ // [Example 3]
95943
+ // ---------------------------------------------------------------------
95944
+ // TypeScript | Javascript
95945
+ // ---------------------------------------------------------------------
95946
+ // @dec | let default_1 = class {
95947
+ // export default class { | }
95948
+ // } | default_1 = __decorate([dec], default_1);
95949
+ // | export default default_1;
95950
+ // ---------------------------------------------------------------------
95951
+ // @dec | let C = class C {
95952
+ // export default class C { | }
95953
+ // } | C = __decorate([dec], C);
95954
+ // | export default C;
95955
+ // ---------------------------------------------------------------------
95956
+ //
95957
+ // If the class declaration is the default export and a reference to itself
95958
+ // inside of the class body, we must emit both an alias for the class *and*
95959
+ // move the export after the declaration:
95960
+ //
95961
+ // [Example 4]
95962
+ // ---------------------------------------------------------------------
95963
+ // TypeScript | Javascript
95964
+ // ---------------------------------------------------------------------
95965
+ // @dec | let C = class C {
95966
+ // export default class C { | static x() { return C_1.y; }
95967
+ // static x() { return C.y; } | }
95968
+ // static y = 1; | C.y = 1;
95969
+ // } | C = C_1 = __decorate([dec], C);
95970
+ // | export default C;
95971
+ // | var C_1;
95972
+ // ---------------------------------------------------------------------
95973
+ //
95974
+ var location = ts.moveRangePastModifiers(node);
95975
+ var classAlias = getClassAliasIfNeeded(node);
95976
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
95977
+ // without any block-scoped variable collision handling
95978
+ var declName = languageVersion <= 2 /* ES2015 */ ?
95979
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
95980
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
95981
+ // ... = class ${name} ${heritageClauses} {
95982
+ // ${members}
95983
+ // }
95984
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
95985
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
95986
+ var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
95987
+ ts.setOriginalNode(classExpression, node);
95988
+ ts.setTextRange(classExpression, location);
95989
+ // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
95990
+ // or decoratedClassAlias if the class contain self-reference.
95991
+ var statement = factory.createVariableStatement(
95992
+ /*modifiers*/ undefined, factory.createVariableDeclarationList([
95993
+ factory.createVariableDeclaration(declName,
95994
+ /*exclamationToken*/ undefined,
95995
+ /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
95996
+ ], 1 /* Let */));
95997
+ ts.setOriginalNode(statement, node);
95998
+ ts.setTextRange(statement, location);
95999
+ ts.setCommentRange(statement, node);
96000
+ return statement;
96001
+ }
96002
+ function visitClassExpression(node) {
96003
+ // Legacy decorators were not supported on class expressions
96004
+ return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
96005
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96006
+ }
96007
+ function visitConstructorDeclaration(node) {
96008
+ return factory.updateConstructorDeclaration(node,
96009
+ /*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
96010
+ }
96011
+ function finishClassElement(updated, original) {
96012
+ if (updated !== original) {
96013
+ // While we emit the source map for the node after skipping decorators and modifiers,
96014
+ // we need to emit the comments for the original range.
96015
+ ts.setCommentRange(updated, original);
96016
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
96017
+ }
96018
+ return updated;
96019
+ }
96020
+ function visitMethodDeclaration(node) {
96021
+ return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
96022
+ /*questionToken*/ undefined,
96023
+ /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96024
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96025
+ }
96026
+ function visitGetAccessorDeclaration(node) {
96027
+ 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),
96028
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96029
+ }
96030
+ function visitSetAccessorDeclaration(node) {
96031
+ 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);
96032
+ }
96033
+ function visitClassStaticBlockDeclaration(node) {
96034
+ return factory.updateClassStaticBlockDeclaration(node,
96035
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
96036
+ }
96037
+ function visitPropertyDeclaration(node) {
96038
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
96039
+ return undefined;
96040
+ }
96041
+ return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
96042
+ /*questionOrExclamationToken*/ undefined,
96043
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
96044
+ }
96045
+ function visitParameterDeclaration(node) {
96046
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
96047
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
96048
+ /*questionToken*/ undefined,
96049
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
96050
+ if (updated !== node) {
96051
+ // While we emit the source map for the node after skipping decorators and modifiers,
96052
+ // we need to emit the comments for the original range.
96053
+ ts.setCommentRange(updated, node);
96054
+ ts.setTextRange(updated, ts.moveRangePastModifiers(node));
96055
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
96056
+ ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
96057
+ }
96058
+ return updated;
96059
+ }
96060
+ /**
96061
+ * Transforms all of the decorators for a declaration into an array of expressions.
96062
+ *
96063
+ * @param allDecorators An object containing all of the decorators for the declaration.
96064
+ */
96065
+ function transformAllDecoratorsOfDeclaration(allDecorators) {
96066
+ if (!allDecorators) {
96067
+ return undefined;
96068
+ }
96069
+ var decoratorExpressions = [];
96070
+ ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
96071
+ ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
96072
+ return decoratorExpressions;
96073
+ }
96074
+ /**
96075
+ * Generates statements used to apply decorators to either the static or instance members
96076
+ * of a class.
96077
+ *
96078
+ * @param node The class node.
96079
+ * @param isStatic A value indicating whether to generate statements for static or
96080
+ * instance members.
96081
+ */
96082
+ function addClassElementDecorationStatements(statements, node, isStatic) {
96083
+ ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
96084
+ }
96085
+ /**
96086
+ * Determines whether a class member is either a static or an instance member of a class
96087
+ * that is decorated, or has parameters that are decorated.
96088
+ *
96089
+ * @param member The class member.
96090
+ */
96091
+ function isDecoratedClassElement(member, isStaticElement, parent) {
96092
+ return ts.nodeOrChildIsDecorated(member, parent)
96093
+ && isStaticElement === ts.isStatic(member);
96094
+ }
96095
+ /**
96096
+ * Gets either the static or instance members of a class that are decorated, or have
96097
+ * parameters that are decorated.
96098
+ *
96099
+ * @param node The class containing the member.
96100
+ * @param isStatic A value indicating whether to retrieve static or instance members of
96101
+ * the class.
96102
+ */
96103
+ function getDecoratedClassElements(node, isStatic) {
96104
+ return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
96105
+ }
96106
+ /**
96107
+ * Generates expressions used to apply decorators to either the static or instance members
96108
+ * of a class.
96109
+ *
96110
+ * @param node The class node.
96111
+ * @param isStatic A value indicating whether to generate expressions for static or
96112
+ * instance members.
96113
+ */
96114
+ function generateClassElementDecorationExpressions(node, isStatic) {
96115
+ var members = getDecoratedClassElements(node, isStatic);
96116
+ var expressions;
96117
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
96118
+ var member = members_8[_i];
96119
+ expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
96120
+ }
96121
+ return expressions;
96122
+ }
96123
+ /**
96124
+ * Generates an expression used to evaluate class element decorators at runtime.
96125
+ *
96126
+ * @param node The class node that contains the member.
96127
+ * @param member The class member.
96128
+ */
96129
+ function generateClassElementDecorationExpression(node, member) {
96130
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96131
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96132
+ if (!decoratorExpressions) {
96133
+ return undefined;
96134
+ }
96135
+ // Emit the call to __decorate. Given the following:
96136
+ //
96137
+ // class C {
96138
+ // @dec method(@dec2 x) {}
96139
+ // @dec get accessor() {}
96140
+ // @dec prop;
96141
+ // }
96142
+ //
96143
+ // The emit for a method is:
96144
+ //
96145
+ // __decorate([
96146
+ // dec,
96147
+ // __param(0, dec2),
96148
+ // __metadata("design:type", Function),
96149
+ // __metadata("design:paramtypes", [Object]),
96150
+ // __metadata("design:returntype", void 0)
96151
+ // ], C.prototype, "method", null);
96152
+ //
96153
+ // The emit for an accessor is:
96154
+ //
96155
+ // __decorate([
96156
+ // dec
96157
+ // ], C.prototype, "accessor", null);
96158
+ //
96159
+ // The emit for a property is:
96160
+ //
96161
+ // __decorate([
96162
+ // dec
96163
+ // ], C.prototype, "prop");
96164
+ //
96165
+ var prefix = getClassMemberPrefix(node, member);
96166
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
96167
+ var descriptor = languageVersion > 0 /* ES3 */
96168
+ ? member.kind === 167 /* PropertyDeclaration */
96169
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
96170
+ // should not invoke `Object.getOwnPropertyDescriptor`.
96171
+ ? factory.createVoidZero()
96172
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
96173
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
96174
+ : factory.createNull()
96175
+ : undefined;
96176
+ var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
96177
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96178
+ ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
96179
+ return helper;
96180
+ }
96181
+ /**
96182
+ * Generates a __decorate helper call for a class constructor.
96183
+ *
96184
+ * @param node The class node.
96185
+ */
96186
+ function addConstructorDecorationStatement(statements, node) {
96187
+ var expression = generateConstructorDecorationExpression(node);
96188
+ if (expression) {
96189
+ statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
96190
+ }
96191
+ }
96192
+ /**
96193
+ * Generates a __decorate helper call for a class constructor.
96194
+ *
96195
+ * @param node The class node.
96196
+ */
96197
+ function generateConstructorDecorationExpression(node) {
96198
+ var allDecorators = ts.getAllDecoratorsOfClass(node);
96199
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96200
+ if (!decoratorExpressions) {
96201
+ return undefined;
96202
+ }
96203
+ var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
96204
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96205
+ // without any block-scoped variable collision handling
96206
+ var localName = languageVersion <= 2 /* ES2015 */ ?
96207
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96208
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96209
+ var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
96210
+ var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
96211
+ ts.setEmitFlags(expression, 1536 /* NoComments */);
96212
+ ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
96213
+ return expression;
96214
+ }
96215
+ /**
96216
+ * Transforms a decorator into an expression.
96217
+ *
96218
+ * @param decorator The decorator node.
96219
+ */
96220
+ function transformDecorator(decorator) {
96221
+ return ts.visitNode(decorator.expression, visitor, ts.isExpression);
96222
+ }
96223
+ /**
96224
+ * Transforms the decorators of a parameter.
96225
+ *
96226
+ * @param decorators The decorators for the parameter at the provided offset.
96227
+ * @param parameterOffset The offset of the parameter.
96228
+ */
96229
+ function transformDecoratorsOfParameter(decorators, parameterOffset) {
96230
+ var expressions;
96231
+ if (decorators) {
96232
+ expressions = [];
96233
+ for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
96234
+ var decorator = decorators_1[_i];
96235
+ var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
96236
+ ts.setTextRange(helper, decorator.expression);
96237
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96238
+ expressions.push(helper);
96239
+ }
96240
+ }
96241
+ return expressions;
96242
+ }
96243
+ /**
96244
+ * Gets an expression that represents a property name (for decorated properties or enums).
96245
+ * For a computed property, a name is generated for the node.
96246
+ *
96247
+ * @param member The member whose name should be converted into an expression.
96248
+ */
96249
+ function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
96250
+ var name = member.name;
96251
+ if (ts.isPrivateIdentifier(name)) {
96252
+ return factory.createIdentifier("");
96253
+ }
96254
+ else if (ts.isComputedPropertyName(name)) {
96255
+ return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
96256
+ ? factory.getGeneratedNameForNode(name)
96257
+ : name.expression;
96258
+ }
96259
+ else if (ts.isIdentifier(name)) {
96260
+ return factory.createStringLiteral(ts.idText(name));
96261
+ }
96262
+ else {
96263
+ return factory.cloneNode(name);
96264
+ }
96265
+ }
96266
+ function enableSubstitutionForClassAliases() {
96267
+ if (!classAliases) {
96268
+ // We need to enable substitutions for identifiers. This allows us to
96269
+ // substitute class names inside of a class declaration.
96270
+ context.enableSubstitution(79 /* Identifier */);
96271
+ // Keep track of class aliases.
96272
+ classAliases = [];
96273
+ }
96274
+ }
96275
+ /**
96276
+ * Gets a local alias for a class declaration if it is a decorated class with an internal
96277
+ * reference to the static side of the class. This is necessary to avoid issues with
96278
+ * double-binding semantics for the class name.
96279
+ */
96280
+ function getClassAliasIfNeeded(node) {
96281
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
96282
+ enableSubstitutionForClassAliases();
96283
+ var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
96284
+ classAliases[ts.getOriginalNodeId(node)] = classAlias;
96285
+ hoistVariableDeclaration(classAlias);
96286
+ return classAlias;
96287
+ }
96288
+ }
96289
+ function getClassPrototype(node) {
96290
+ return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
96291
+ }
96292
+ function getClassMemberPrefix(node, member) {
96293
+ return ts.isStatic(member)
96294
+ ? factory.getDeclarationName(node)
96295
+ : getClassPrototype(node);
96296
+ }
96297
+ /**
96298
+ * Hooks node substitutions.
96299
+ *
96300
+ * @param hint A hint as to the intended usage of the node.
96301
+ * @param node The node to substitute.
96302
+ */
96303
+ function onSubstituteNode(hint, node) {
96304
+ node = previousOnSubstituteNode(hint, node);
96305
+ if (hint === 1 /* Expression */) {
96306
+ return substituteExpression(node);
96307
+ }
96308
+ return node;
96309
+ }
96310
+ function substituteExpression(node) {
96311
+ switch (node.kind) {
96312
+ case 79 /* Identifier */:
96313
+ return substituteExpressionIdentifier(node);
96314
+ }
96315
+ return node;
96316
+ }
96317
+ function substituteExpressionIdentifier(node) {
96318
+ var _a;
96319
+ return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
96320
+ }
96321
+ function trySubstituteClassAlias(node) {
96322
+ if (classAliases) {
96323
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
96324
+ // Due to the emit for class decorators, any reference to the class from inside of the class body
96325
+ // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
96326
+ // behavior of class names in ES6.
96327
+ // Also, when emitting statics for class expressions, we must substitute a class alias for
96328
+ // constructor references in static property initializers.
96329
+ var declaration = resolver.getReferencedValueDeclaration(node);
96330
+ if (declaration) {
96331
+ var classAlias = classAliases[declaration.id]; // TODO: GH#18217
96332
+ if (classAlias) {
96333
+ var clone_3 = factory.cloneNode(classAlias);
96334
+ ts.setSourceMapRange(clone_3, node);
96335
+ ts.setCommentRange(clone_3, node);
96336
+ return clone_3;
96337
+ }
96338
+ }
96339
+ }
96340
+ }
96341
+ return undefined;
96342
+ }
96343
+ }
96344
+ ts.transformLegacyDecorators = transformLegacyDecorators;
96345
+ })(ts || (ts = {}));
96346
+ /*@internal*/
96347
+ var ts;
95911
96348
  (function (ts) {
95912
96349
  var ES2017SubstitutionFlags;
95913
96350
  (function (ES2017SubstitutionFlags) {
@@ -96756,7 +97193,7 @@ var ts;
96756
97193
  return objects;
96757
97194
  }
96758
97195
  function visitObjectLiteralExpression(node) {
96759
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97196
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96760
97197
  // spread elements emit like so:
96761
97198
  // non-spread elements are chunked together into object literals, and then all are passed to __assign:
96762
97199
  // { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -96829,7 +97266,7 @@ var ts;
96829
97266
  * expression of an `ExpressionStatement`).
96830
97267
  */
96831
97268
  function visitBinaryExpression(node, expressionResultIsUnused) {
96832
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97269
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96833
97270
  return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
96834
97271
  }
96835
97272
  if (node.operatorToken.kind === 27 /* CommaToken */) {
@@ -96860,7 +97297,7 @@ var ts;
96860
97297
  function visitCatchClause(node) {
96861
97298
  if (node.variableDeclaration &&
96862
97299
  ts.isBindingPattern(node.variableDeclaration.name) &&
96863
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97300
+ node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96864
97301
  var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
96865
97302
  var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
96866
97303
  var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
@@ -96901,7 +97338,7 @@ var ts;
96901
97338
  }
96902
97339
  function visitVariableDeclarationWorker(node, exportedVariableStatement) {
96903
97340
  // If we are here it is because the name contains a binding pattern with a rest somewhere in it.
96904
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97341
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96905
97342
  return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
96906
97343
  /*rval*/ undefined, exportedVariableStatement);
96907
97344
  }
@@ -96920,7 +97357,7 @@ var ts;
96920
97357
  */
96921
97358
  function visitForOfStatement(node, outermostLabeledStatement) {
96922
97359
  var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
96923
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97360
+ if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96924
97361
  node = transformForOfStatementWithObjectRest(node);
96925
97362
  }
96926
97363
  var result = node.awaitModifier ?
@@ -97033,7 +97470,7 @@ var ts;
97033
97470
  /*type*/ undefined,
97034
97471
  /*initializer*/ undefined);
97035
97472
  }
97036
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97473
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97037
97474
  // Binding patterns are converted into a generated name and are
97038
97475
  // evaluated inside the function body.
97039
97476
  return factory.updateParameterDeclaration(node,
@@ -97051,7 +97488,7 @@ var ts;
97051
97488
  if (parameters) {
97052
97489
  parameters.add(parameter);
97053
97490
  }
97054
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97491
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97055
97492
  parameters = new ts.Set();
97056
97493
  }
97057
97494
  }
@@ -97274,7 +97711,7 @@ var ts;
97274
97711
  statements = ts.append(statements, statement);
97275
97712
  }
97276
97713
  }
97277
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97714
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97278
97715
  containsPrecedingObjectRestOrSpread = true;
97279
97716
  var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
97280
97717
  /*doNotRecordTempVariablesInLine*/ false,
@@ -98646,7 +99083,7 @@ var ts;
98646
99083
  && !node.expression;
98647
99084
  }
98648
99085
  function isOrMayContainReturnCompletion(node) {
98649
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
99086
+ return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
98650
99087
  && (ts.isReturnStatement(node)
98651
99088
  || ts.isIfStatement(node)
98652
99089
  || ts.isWithStatement(node)
@@ -99210,7 +99647,7 @@ var ts;
99210
99647
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
99211
99648
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
99212
99649
  if (isDerivedClass || superCallExpression) {
99213
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
99650
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
99214
99651
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
99215
99652
  // following representation:
99216
99653
  //
@@ -99755,7 +100192,7 @@ var ts;
99755
100192
  * @param node An ArrowFunction node.
99756
100193
  */
99757
100194
  function visitArrowFunction(node) {
99758
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100195
+ if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
99759
100196
  hierarchyFacts |= 65536 /* CapturedLexicalThis */;
99760
100197
  }
99761
100198
  var savedConvertedLoopState = convertedLoopState;
@@ -100041,7 +100478,7 @@ var ts;
100041
100478
  * @param node A VariableDeclarationList node.
100042
100479
  */
100043
100480
  function visitVariableDeclarationList(node) {
100044
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
100481
+ if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
100045
100482
  if (node.flags & 3 /* BlockScoped */) {
100046
100483
  enableSubstitutionsForBlockScopedBindings();
100047
100484
  }
@@ -100054,7 +100491,7 @@ var ts;
100054
100491
  ts.setCommentRange(declarationList, node);
100055
100492
  // If the first or last declaration is a binding pattern, we need to modify
100056
100493
  // the source map range for the declaration list.
100057
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
100494
+ if (node.transformFlags & 524288 /* ContainsBindingPattern */
100058
100495
  && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
100059
100496
  ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
100060
100497
  }
@@ -100378,7 +100815,7 @@ var ts;
100378
100815
  var numInitialProperties = -1, hasComputed = false;
100379
100816
  for (var i = 0; i < properties.length; i++) {
100380
100817
  var property = properties[i];
100381
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
100818
+ if ((property.transformFlags & 1048576 /* ContainsYield */ &&
100382
100819
  hierarchyFacts & 4 /* AsyncFunctionBody */)
100383
100820
  || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
100384
100821
  numInitialProperties = i;
@@ -100651,7 +101088,7 @@ var ts;
100651
101088
  */
100652
101089
  function createFunctionForInitializerOfForStatement(node, currentState) {
100653
101090
  var functionName = factory.createUniqueName("_loop_init");
100654
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
101091
+ var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
100655
101092
  var emitFlags = 0 /* None */;
100656
101093
  if (currentState.containsLexicalThis)
100657
101094
  emitFlags |= 8 /* CapturesThis */;
@@ -100766,7 +101203,7 @@ var ts;
100766
101203
  var loopBody = factory.createBlock(statements, /*multiLine*/ true);
100767
101204
  if (ts.isBlock(statement))
100768
101205
  ts.setOriginalNode(loopBody, statement);
100769
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
101206
+ var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
100770
101207
  var emitFlags = 524288 /* ReuseTempVariableScope */;
100771
101208
  if (currentState.containsLexicalThis)
100772
101209
  emitFlags |= 8 /* CapturesThis */;
@@ -101248,7 +101685,7 @@ var ts;
101248
101685
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
101249
101686
  // We are here either because SuperKeyword was used somewhere in the expression, or
101250
101687
  // because we contain a SpreadElementExpression.
101251
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
101688
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
101252
101689
  node.expression.kind === 106 /* SuperKeyword */ ||
101253
101690
  ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
101254
101691
  var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
@@ -101256,7 +101693,7 @@ var ts;
101256
101693
  ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
101257
101694
  }
101258
101695
  var resultingCall = void 0;
101259
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
101696
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
101260
101697
  // [source]
101261
101698
  // f(...a, b)
101262
101699
  // x.m(...a, b)
@@ -102098,10 +102535,10 @@ var ts;
102098
102535
  case 247 /* ReturnStatement */:
102099
102536
  return visitReturnStatement(node);
102100
102537
  default:
102101
- if (node.transformFlags & 524288 /* ContainsYield */) {
102538
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102102
102539
  return visitJavaScriptContainingYield(node);
102103
102540
  }
102104
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
102541
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
102105
102542
  return ts.visitEachChild(node, visitor, context);
102106
102543
  }
102107
102544
  else {
@@ -102306,7 +102743,7 @@ var ts;
102306
102743
  * @param node The node to visit.
102307
102744
  */
102308
102745
  function visitVariableStatement(node) {
102309
- if (node.transformFlags & 524288 /* ContainsYield */) {
102746
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102310
102747
  transformAndEmitVariableDeclarationList(node.declarationList);
102311
102748
  return undefined;
102312
102749
  }
@@ -103364,7 +103801,7 @@ var ts;
103364
103801
  }
103365
103802
  }
103366
103803
  function containsYield(node) {
103367
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
103804
+ return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
103368
103805
  }
103369
103806
  function countInitialNodesWithoutYield(nodes) {
103370
103807
  var numNodes = nodes.length;
@@ -104413,7 +104850,7 @@ var ts;
104413
104850
  function transformSourceFile(node) {
104414
104851
  if (node.isDeclarationFile ||
104415
104852
  !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104416
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
104853
+ node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
104417
104854
  (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104418
104855
  return node;
104419
104856
  }
@@ -104750,7 +105187,7 @@ var ts;
104750
105187
  function visitorWorker(node, valueIsDiscarded) {
104751
105188
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
104752
105189
  // as export/import statements are only transformed at the top level of a file.
104753
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
105190
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
104754
105191
  return node;
104755
105192
  }
104756
105193
  switch (node.kind) {
@@ -104901,7 +105338,7 @@ var ts;
104901
105338
  var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
104902
105339
  // 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.
104903
105340
  var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
104904
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
105341
+ var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
104905
105342
  switch (compilerOptions.module) {
104906
105343
  case ts.ModuleKind.AMD:
104907
105344
  return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -105888,7 +106325,7 @@ var ts;
105888
106325
  * @param node The SourceFile node.
105889
106326
  */
105890
106327
  function transformSourceFile(node) {
105891
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
106328
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
105892
106329
  return node;
105893
106330
  }
105894
106331
  var id = ts.getOriginalNodeId(node);
@@ -106057,7 +106494,7 @@ var ts;
106057
106494
  // - Temporary variables will appear at the top rather than at the bottom of the file
106058
106495
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
106059
106496
  var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
106060
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
106497
+ var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
106061
106498
  factory.createModifiersFromModifierFlags(256 /* Async */) :
106062
106499
  undefined;
106063
106500
  var moduleObject = factory.createObjectLiteralExpression([
@@ -106966,7 +107403,7 @@ var ts;
106966
107403
  * @param node The node to visit.
106967
107404
  */
106968
107405
  function visitorWorker(node, valueIsDiscarded) {
106969
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
107406
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
106970
107407
  return node;
106971
107408
  }
106972
107409
  switch (node.kind) {
@@ -108134,7 +108571,8 @@ var ts;
108134
108571
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108135
108572
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108136
108573
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108137
- reportNonSerializableProperty: reportNonSerializableProperty
108574
+ reportNonSerializableProperty: reportNonSerializableProperty,
108575
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108138
108576
  };
108139
108577
  var errorNameNode;
108140
108578
  var errorFallbackNode;
@@ -108261,6 +108699,11 @@ var ts;
108261
108699
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108262
108700
  }
108263
108701
  }
108702
+ function reportImportTypeNodeResolutionModeOverride() {
108703
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108704
+ 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));
108705
+ }
108706
+ }
108264
108707
  function transformDeclarationsForJS(sourceFile, bundled) {
108265
108708
  var oldDiag = getSymbolAccessibilityDiagnostic;
108266
108709
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108711,7 +109154,7 @@ var ts;
108711
109154
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108712
109155
  if (mode !== undefined) {
108713
109156
  if (!ts.isNightly()) {
108714
- 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));
109157
+ 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));
108715
109158
  }
108716
109159
  return assertClause;
108717
109160
  }
@@ -109503,6 +109946,7 @@ var ts;
109503
109946
  var transformers = [];
109504
109947
  ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
109505
109948
  transformers.push(ts.transformTypeScript);
109949
+ transformers.push(ts.transformLegacyDecorators);
109506
109950
  transformers.push(ts.transformClassFields);
109507
109951
  if (ts.getJSXTransformEnabled(compilerOptions)) {
109508
109952
  transformers.push(ts.transformJsx);
@@ -116220,12 +116664,14 @@ var ts;
116220
116664
  }
116221
116665
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116222
116666
  ;
116223
- /* @internal */
116667
+ /**
116668
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116669
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116670
+ */
116224
116671
  function getModeForFileReference(ref, containingFileMode) {
116225
116672
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116226
116673
  }
116227
116674
  ts.getModeForFileReference = getModeForFileReference;
116228
- /* @internal */
116229
116675
  function getModeForResolutionAtIndex(file, index) {
116230
116676
  if (file.impliedNodeFormat === undefined)
116231
116677
  return undefined;
@@ -116246,7 +116692,15 @@ var ts;
116246
116692
  return false;
116247
116693
  }
116248
116694
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116249
- /* @internal */
116695
+ /**
116696
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116697
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116698
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116699
+ * `moduleResolution` is `node16`+.
116700
+ * @param file The file the import or import-like reference is contained within
116701
+ * @param usage The module reference string
116702
+ * @returns The final resolution mode of the import
116703
+ */
116250
116704
  function getModeForUsageLocation(file, usage) {
116251
116705
  var _a, _b;
116252
116706
  if (file.impliedNodeFormat === undefined)
@@ -118482,7 +118936,7 @@ var ts;
118482
118936
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118483
118937
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118484
118938
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118485
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118939
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118486
118940
  }
118487
118941
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118488
118942
  }
@@ -125792,7 +126246,7 @@ var ts;
125792
126246
  * @param typeAcquisition is used to customize the typing acquisition process
125793
126247
  * @param compilerOptions are used as a source for typing inference
125794
126248
  */
125795
- function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
126249
+ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
125796
126250
  if (!typeAcquisition || !typeAcquisition.enable) {
125797
126251
  return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
125798
126252
  }
@@ -125810,12 +126264,14 @@ var ts;
125810
126264
  addInferredTypings(typeAcquisition.include, "Explicitly included types");
125811
126265
  var exclude = typeAcquisition.exclude || [];
125812
126266
  // Directories to search for package.json, bower.json and other typing information
125813
- var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
125814
- possibleSearchDirs.add(projectRootPath);
125815
- possibleSearchDirs.forEach(function (searchDir) {
125816
- getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
125817
- getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
125818
- });
126267
+ if (!compilerOptions.types) {
126268
+ var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
126269
+ possibleSearchDirs.add(projectRootPath);
126270
+ possibleSearchDirs.forEach(function (searchDir) {
126271
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
126272
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
126273
+ });
126274
+ }
125819
126275
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
125820
126276
  getTypingNamesFromSourceFileNames(fileNames);
125821
126277
  }
@@ -126191,7 +126647,7 @@ var ts;
126191
126647
  if (this.safeList === undefined) {
126192
126648
  this.initializeSafeList();
126193
126649
  }
126194
- var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry);
126650
+ var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry, req.compilerOptions);
126195
126651
  if (this.log.isEnabled()) {
126196
126652
  this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult));
126197
126653
  }