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.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220601";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220604";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5572,21 +5572,22 @@ var ts;
5572
5572
  TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 4096] = "ContainsDestructuringAssignment";
5573
5573
  // Markers
5574
5574
  // - Flags used to indicate that a subtree contains a specific transformation.
5575
- TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax";
5576
- TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis";
5577
- TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread";
5578
- TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread";
5579
- TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName";
5580
- TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding";
5581
- TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern";
5582
- TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield";
5583
- TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait";
5584
- TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion";
5585
- TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport";
5586
- TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields";
5587
- TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait";
5588
- TransformFlags[TransformFlags["ContainsLexicalSuper"] = 33554432] = "ContainsLexicalSuper";
5589
- TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 67108864] = "ContainsUpdateExpressionForIdentifier";
5575
+ TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 8192] = "ContainsTypeScriptClassSyntax";
5576
+ TransformFlags[TransformFlags["ContainsLexicalThis"] = 16384] = "ContainsLexicalThis";
5577
+ TransformFlags[TransformFlags["ContainsRestOrSpread"] = 32768] = "ContainsRestOrSpread";
5578
+ TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 65536] = "ContainsObjectRestOrSpread";
5579
+ TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 131072] = "ContainsComputedPropertyName";
5580
+ TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 262144] = "ContainsBlockScopedBinding";
5581
+ TransformFlags[TransformFlags["ContainsBindingPattern"] = 524288] = "ContainsBindingPattern";
5582
+ TransformFlags[TransformFlags["ContainsYield"] = 1048576] = "ContainsYield";
5583
+ TransformFlags[TransformFlags["ContainsAwait"] = 2097152] = "ContainsAwait";
5584
+ TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 4194304] = "ContainsHoistedDeclarationOrCompletion";
5585
+ TransformFlags[TransformFlags["ContainsDynamicImport"] = 8388608] = "ContainsDynamicImport";
5586
+ TransformFlags[TransformFlags["ContainsClassFields"] = 16777216] = "ContainsClassFields";
5587
+ TransformFlags[TransformFlags["ContainsDecorators"] = 33554432] = "ContainsDecorators";
5588
+ TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait";
5589
+ TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper";
5590
+ TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier";
5590
5591
  // Please leave this as 1 << 29.
5591
5592
  // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
5592
5593
  // It is a good reminder of how much room we have left
@@ -5612,24 +5613,24 @@ var ts;
5612
5613
  TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes";
5613
5614
  TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes";
5614
5615
  TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes";
5615
- TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes";
5616
- TransformFlags[TransformFlags["FunctionExcludes"] = 591310848] = "FunctionExcludes";
5617
- TransformFlags[TransformFlags["ConstructorExcludes"] = 591306752] = "ConstructorExcludes";
5618
- TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 574529536] = "MethodOrAccessorExcludes";
5619
- TransformFlags[TransformFlags["PropertyExcludes"] = 570433536] = "PropertyExcludes";
5620
- TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes";
5621
- TransformFlags[TransformFlags["ModuleExcludes"] = 589443072] = "ModuleExcludes";
5616
+ TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes";
5617
+ TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes";
5618
+ TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes";
5619
+ TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes";
5620
+ TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes";
5621
+ TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes";
5622
+ TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes";
5622
5623
  TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes";
5623
- TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes";
5624
- TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes";
5625
- TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes";
5624
+ TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes";
5625
+ TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes";
5626
+ TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes";
5626
5627
  TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes";
5627
- TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes";
5628
- TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes";
5629
- TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 33562624] = "ContainsLexicalThisOrSuper";
5628
+ TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes";
5629
+ TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes";
5630
+ TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper";
5630
5631
  // Propagating flags
5631
5632
  // - Bitmasks for flags that should propagate from a child
5632
- TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 33562624] = "PropertyNamePropagatingFlags";
5633
+ TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 134234112] = "PropertyNamePropagatingFlags";
5633
5634
  // Masks
5634
5635
  // - Additional bitmasks
5635
5636
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
@@ -8202,6 +8203,7 @@ var ts;
8202
8203
  Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
8203
8204
  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."),
8204
8205
  _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."),
8206
+ 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}()'?"),
8205
8207
  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."),
8206
8208
  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."),
8207
8209
  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."),
@@ -8398,7 +8400,7 @@ var ts;
8398
8400
  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."),
8399
8401
  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"),
8400
8402
  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"),
8401
- 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`."),
8403
+ 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`."),
8402
8404
  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`."),
8403
8405
  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."),
8404
8406
  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."),
@@ -8906,6 +8908,7 @@ var ts;
8906
8908
  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."),
8907
8909
  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."),
8908
8910
  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"),
8911
+ 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'."),
8909
8912
  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}'."),
8910
8913
  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}'."),
8911
8914
  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}'."),
@@ -9013,7 +9016,7 @@ var ts;
9013
9016
  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}'."),
9014
9017
  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}'?"),
9015
9018
  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'."),
9016
- 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'."),
9019
+ 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'."),
9017
9020
  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."),
9018
9021
  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."),
9019
9022
  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}'."),
@@ -16054,6 +16057,8 @@ var ts;
16054
16057
  case 218 /* AwaitExpression */:
16055
16058
  case 231 /* MetaProperty */:
16056
16059
  return true;
16060
+ case 228 /* ExpressionWithTypeArguments */:
16061
+ return !ts.isHeritageClause(node.parent);
16057
16062
  case 161 /* QualifiedName */:
16058
16063
  while (node.parent.kind === 161 /* QualifiedName */) {
16059
16064
  node = node.parent;
@@ -16997,6 +17002,12 @@ var ts;
16997
17002
  return [child, node];
16998
17003
  }
16999
17004
  ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
17005
+ function skipTypeParentheses(node) {
17006
+ while (ts.isParenthesizedTypeNode(node))
17007
+ node = node.type;
17008
+ return node;
17009
+ }
17010
+ ts.skipTypeParentheses = skipTypeParentheses;
17000
17011
  function skipParentheses(node, excludeJSDocTypeAssertions) {
17001
17012
  var flags = excludeJSDocTypeAssertions ?
17002
17013
  1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ :
@@ -19231,7 +19242,7 @@ var ts;
19231
19242
  * Moves the start position of a range past any decorators.
19232
19243
  */
19233
19244
  function moveRangePastDecorators(node) {
19234
- return node.decorators && node.decorators.length > 0
19245
+ return node.decorators && !positionIsSynthesized(node.decorators.end)
19235
19246
  ? moveRangePos(node, node.decorators.end)
19236
19247
  : node;
19237
19248
  }
@@ -19240,7 +19251,7 @@ var ts;
19240
19251
  * Moves the start position of a range past any decorators or modifiers.
19241
19252
  */
19242
19253
  function moveRangePastModifiers(node) {
19243
- return node.modifiers && node.modifiers.length > 0
19254
+ return node.modifiers && !positionIsSynthesized(node.modifiers.end)
19244
19255
  ? moveRangePos(node, node.modifiers.end)
19245
19256
  : moveRangePastDecorators(node);
19246
19257
  }
@@ -22670,7 +22681,7 @@ var ts;
22670
22681
  function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
22671
22682
  var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
22672
22683
  node.body = body;
22673
- node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */;
22684
+ node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */;
22674
22685
  if (!body)
22675
22686
  node.transformFlags |= 1 /* ContainsTypeScript */;
22676
22687
  return node;
@@ -22798,7 +22809,7 @@ var ts;
22798
22809
  node.typeArguments = createNodeArray(typeArguments);
22799
22810
  }
22800
22811
  if (node.originalKeywordKind === 132 /* AwaitKeyword */) {
22801
- node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */;
22812
+ node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */;
22802
22813
  }
22803
22814
  return node;
22804
22815
  }
@@ -22850,7 +22861,7 @@ var ts;
22850
22861
  ts.Debug.fail("First character of private identifier must be #: " + text);
22851
22862
  var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */);
22852
22863
  node.escapedText = ts.escapeLeadingUnderscores(text);
22853
- node.transformFlags |= 8388608 /* ContainsClassFields */;
22864
+ node.transformFlags |= 16777216 /* ContainsClassFields */;
22854
22865
  return node;
22855
22866
  }
22856
22867
  //
@@ -22897,14 +22908,14 @@ var ts;
22897
22908
  transformFlags = 1 /* ContainsTypeScript */;
22898
22909
  break;
22899
22910
  case 106 /* SuperKeyword */:
22900
- transformFlags = 1024 /* ContainsES2015 */ | 33554432 /* ContainsLexicalSuper */;
22911
+ transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */;
22901
22912
  break;
22902
22913
  case 124 /* StaticKeyword */:
22903
22914
  transformFlags = 1024 /* ContainsES2015 */;
22904
22915
  break;
22905
22916
  case 108 /* ThisKeyword */:
22906
22917
  // 'this' indicates a lexical 'this'
22907
- transformFlags = 8192 /* ContainsLexicalThis */;
22918
+ transformFlags = 16384 /* ContainsLexicalThis */;
22908
22919
  break;
22909
22920
  }
22910
22921
  if (transformFlags) {
@@ -23002,7 +23013,7 @@ var ts;
23002
23013
  node.transformFlags |=
23003
23014
  propagateChildFlags(node.expression) |
23004
23015
  1024 /* ContainsES2015 */ |
23005
- 65536 /* ContainsComputedPropertyName */;
23016
+ 131072 /* ContainsComputedPropertyName */;
23006
23017
  return node;
23007
23018
  }
23008
23019
  // @api
@@ -23068,7 +23079,7 @@ var ts;
23068
23079
  if (questionToken)
23069
23080
  node.transformFlags |= 1 /* ContainsTypeScript */;
23070
23081
  if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */)
23071
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23082
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23072
23083
  if (initializer || dotDotDotToken)
23073
23084
  node.transformFlags |= 1024 /* ContainsES2015 */;
23074
23085
  }
@@ -23093,7 +23104,8 @@ var ts;
23093
23104
  node.transformFlags |=
23094
23105
  propagateChildFlags(node.expression) |
23095
23106
  1 /* ContainsTypeScript */ |
23096
- 4096 /* ContainsTypeScriptClassSyntax */;
23107
+ 8192 /* ContainsTypeScriptClassSyntax */ |
23108
+ 33554432 /* ContainsDecorators */;
23097
23109
  return node;
23098
23110
  }
23099
23111
  // @api
@@ -23131,9 +23143,9 @@ var ts;
23131
23143
  node.transformFlags |=
23132
23144
  propagateChildFlags(node.questionToken) |
23133
23145
  propagateChildFlags(node.exclamationToken) |
23134
- 8388608 /* ContainsClassFields */;
23146
+ 16777216 /* ContainsClassFields */;
23135
23147
  if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
23136
- node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */;
23148
+ node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */;
23137
23149
  }
23138
23150
  if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) {
23139
23151
  node.transformFlags |= 1 /* ContainsTypeScript */;
@@ -23216,7 +23228,7 @@ var ts;
23216
23228
  /*name*/ undefined,
23217
23229
  /*typeParameters*/ undefined);
23218
23230
  node.body = body;
23219
- node.transformFlags = propagateChildFlags(body) | 8388608 /* ContainsClassFields */;
23231
+ node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */;
23220
23232
  return node;
23221
23233
  }
23222
23234
  // @api
@@ -23740,11 +23752,11 @@ var ts;
23740
23752
  node.transformFlags |=
23741
23753
  propagateChildrenFlags(node.elements) |
23742
23754
  1024 /* ContainsES2015 */ |
23743
- 262144 /* ContainsBindingPattern */;
23744
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
23755
+ 524288 /* ContainsBindingPattern */;
23756
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
23745
23757
  node.transformFlags |=
23746
23758
  128 /* ContainsES2018 */ |
23747
- 32768 /* ContainsObjectRestOrSpread */;
23759
+ 65536 /* ContainsObjectRestOrSpread */;
23748
23760
  }
23749
23761
  return node;
23750
23762
  }
@@ -23761,7 +23773,7 @@ var ts;
23761
23773
  node.transformFlags |=
23762
23774
  propagateChildrenFlags(node.elements) |
23763
23775
  1024 /* ContainsES2015 */ |
23764
- 262144 /* ContainsBindingPattern */;
23776
+ 524288 /* ContainsBindingPattern */;
23765
23777
  return node;
23766
23778
  }
23767
23779
  // @api
@@ -23786,7 +23798,7 @@ var ts;
23786
23798
  propagateChildFlags(node.propertyName);
23787
23799
  }
23788
23800
  if (dotDotDotToken)
23789
- node.transformFlags |= 16384 /* ContainsRestOrSpread */;
23801
+ node.transformFlags |= 32768 /* ContainsRestOrSpread */;
23790
23802
  return node;
23791
23803
  }
23792
23804
  // @api
@@ -23961,10 +23973,10 @@ var ts;
23961
23973
  node.transformFlags |= 1 /* ContainsTypeScript */;
23962
23974
  }
23963
23975
  if (ts.isImportKeyword(node.expression)) {
23964
- node.transformFlags |= 4194304 /* ContainsDynamicImport */;
23976
+ node.transformFlags |= 8388608 /* ContainsDynamicImport */;
23965
23977
  }
23966
23978
  else if (ts.isSuperProperty(node.expression)) {
23967
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
23979
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
23968
23980
  }
23969
23981
  return node;
23970
23982
  }
@@ -23997,7 +24009,7 @@ var ts;
23997
24009
  node.transformFlags |= 1 /* ContainsTypeScript */;
23998
24010
  }
23999
24011
  if (ts.isSuperProperty(node.expression)) {
24000
- node.transformFlags |= 8192 /* ContainsLexicalThis */;
24012
+ node.transformFlags |= 16384 /* ContainsLexicalThis */;
24001
24013
  }
24002
24014
  return node;
24003
24015
  }
@@ -24137,7 +24149,7 @@ var ts;
24137
24149
  propagateChildFlags(node.equalsGreaterThanToken) |
24138
24150
  1024 /* ContainsES2015 */;
24139
24151
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24140
- node.transformFlags |= 256 /* ContainsES2017 */ | 8192 /* ContainsLexicalThis */;
24152
+ node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */;
24141
24153
  }
24142
24154
  return node;
24143
24155
  }
@@ -24199,7 +24211,7 @@ var ts;
24199
24211
  propagateChildFlags(node.expression) |
24200
24212
  256 /* ContainsES2017 */ |
24201
24213
  128 /* ContainsES2018 */ |
24202
- 1048576 /* ContainsAwait */;
24214
+ 2097152 /* ContainsAwait */;
24203
24215
  return node;
24204
24216
  }
24205
24217
  // @api
@@ -24220,7 +24232,7 @@ var ts;
24220
24232
  ts.isIdentifier(node.operand) &&
24221
24233
  !ts.isGeneratedIdentifier(node.operand) &&
24222
24234
  !ts.isLocalName(node.operand)) {
24223
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24235
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24224
24236
  }
24225
24237
  return node;
24226
24238
  }
@@ -24241,7 +24253,7 @@ var ts;
24241
24253
  if (ts.isIdentifier(node.operand) &&
24242
24254
  !ts.isGeneratedIdentifier(node.operand) &&
24243
24255
  !ts.isLocalName(node.operand)) {
24244
- node.transformFlags |= 67108864 /* ContainsUpdateExpressionForIdentifier */;
24256
+ node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */;
24245
24257
  }
24246
24258
  return node;
24247
24259
  }
@@ -24290,8 +24302,8 @@ var ts;
24290
24302
  return node;
24291
24303
  }
24292
24304
  function propagateAssignmentPatternFlags(node) {
24293
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */)
24294
- return 32768 /* ContainsObjectRestOrSpread */;
24305
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */)
24306
+ return 65536 /* ContainsObjectRestOrSpread */;
24295
24307
  if (node.transformFlags & 128 /* ContainsES2018 */) {
24296
24308
  // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c'
24297
24309
  // will not be correctly interpreted by the ES2018 transformer
@@ -24299,8 +24311,8 @@ var ts;
24299
24311
  var element = _a[_i];
24300
24312
  var target = ts.getTargetOfBindingOrAssignmentElement(element);
24301
24313
  if (target && ts.isAssignmentPattern(target)) {
24302
- if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
24303
- return 32768 /* ContainsObjectRestOrSpread */;
24314
+ if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
24315
+ return 65536 /* ContainsObjectRestOrSpread */;
24304
24316
  }
24305
24317
  if (target.transformFlags & 128 /* ContainsES2018 */) {
24306
24318
  var flags_1 = propagateAssignmentPatternFlags(target);
@@ -24426,7 +24438,7 @@ var ts;
24426
24438
  propagateChildFlags(node.asteriskToken) |
24427
24439
  1024 /* ContainsES2015 */ |
24428
24440
  128 /* ContainsES2018 */ |
24429
- 524288 /* ContainsYield */;
24441
+ 1048576 /* ContainsYield */;
24430
24442
  return node;
24431
24443
  }
24432
24444
  // @api
@@ -24443,7 +24455,7 @@ var ts;
24443
24455
  node.transformFlags |=
24444
24456
  propagateChildFlags(node.expression) |
24445
24457
  1024 /* ContainsES2015 */ |
24446
- 16384 /* ContainsRestOrSpread */;
24458
+ 32768 /* ContainsRestOrSpread */;
24447
24459
  return node;
24448
24460
  }
24449
24461
  // @api
@@ -24776,7 +24788,7 @@ var ts;
24776
24788
  node.label = asName(label);
24777
24789
  node.transformFlags |=
24778
24790
  propagateChildFlags(node.label) |
24779
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24791
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24780
24792
  return node;
24781
24793
  }
24782
24794
  // @api
@@ -24791,7 +24803,7 @@ var ts;
24791
24803
  node.label = asName(label);
24792
24804
  node.transformFlags |=
24793
24805
  propagateChildFlags(node.label) |
24794
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24806
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24795
24807
  return node;
24796
24808
  }
24797
24809
  // @api
@@ -24808,7 +24820,7 @@ var ts;
24808
24820
  node.transformFlags |=
24809
24821
  propagateChildFlags(node.expression) |
24810
24822
  128 /* ContainsES2018 */ |
24811
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24823
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24812
24824
  return node;
24813
24825
  }
24814
24826
  // @api
@@ -24934,11 +24946,11 @@ var ts;
24934
24946
  node.declarations = createNodeArray(declarations);
24935
24947
  node.transformFlags |=
24936
24948
  propagateChildrenFlags(node.declarations) |
24937
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24949
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24938
24950
  if (flags & 3 /* BlockScoped */) {
24939
24951
  node.transformFlags |=
24940
24952
  1024 /* ContainsES2015 */ |
24941
- 131072 /* ContainsBlockScopedBinding */;
24953
+ 262144 /* ContainsBlockScopedBinding */;
24942
24954
  }
24943
24955
  return node;
24944
24956
  }
@@ -24958,7 +24970,7 @@ var ts;
24958
24970
  else {
24959
24971
  node.transformFlags |=
24960
24972
  propagateChildFlags(node.asteriskToken) |
24961
- 2097152 /* ContainsHoistedDeclarationOrCompletion */;
24973
+ 4194304 /* ContainsHoistedDeclarationOrCompletion */;
24962
24974
  if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) {
24963
24975
  if (node.asteriskToken) {
24964
24976
  node.transformFlags |= 128 /* ContainsES2018 */;
@@ -24994,7 +25006,7 @@ var ts;
24994
25006
  }
24995
25007
  else {
24996
25008
  node.transformFlags |= 1024 /* ContainsES2015 */;
24997
- if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) {
25009
+ if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) {
24998
25010
  node.transformFlags |= 1 /* ContainsTypeScript */;
24999
25011
  }
25000
25012
  }
@@ -25053,7 +25065,7 @@ var ts;
25053
25065
  node.transformFlags |=
25054
25066
  propagateChildrenFlags(node.members) |
25055
25067
  1 /* ContainsTypeScript */;
25056
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25068
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await`
25057
25069
  return node;
25058
25070
  }
25059
25071
  // @api
@@ -25081,7 +25093,7 @@ var ts;
25081
25093
  propagateChildFlags(node.body) |
25082
25094
  1 /* ContainsTypeScript */;
25083
25095
  }
25084
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25096
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`.
25085
25097
  return node;
25086
25098
  }
25087
25099
  // @api
@@ -25141,7 +25153,7 @@ var ts;
25141
25153
  node.transformFlags |= propagateChildFlags(node.moduleReference);
25142
25154
  if (!ts.isExternalModuleReference(node.moduleReference))
25143
25155
  node.transformFlags |= 1 /* ContainsTypeScript */;
25144
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25156
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context
25145
25157
  return node;
25146
25158
  }
25147
25159
  // @api
@@ -25163,7 +25175,7 @@ var ts;
25163
25175
  node.transformFlags |=
25164
25176
  propagateChildFlags(node.importClause) |
25165
25177
  propagateChildFlags(node.moduleSpecifier);
25166
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25178
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25167
25179
  return node;
25168
25180
  }
25169
25181
  // @api
@@ -25188,7 +25200,7 @@ var ts;
25188
25200
  if (isTypeOnly) {
25189
25201
  node.transformFlags |= 1 /* ContainsTypeScript */;
25190
25202
  }
25191
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25203
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25192
25204
  return node;
25193
25205
  }
25194
25206
  // @api
@@ -25248,7 +25260,7 @@ var ts;
25248
25260
  var node = createBaseNode(268 /* NamespaceImport */);
25249
25261
  node.name = name;
25250
25262
  node.transformFlags |= propagateChildFlags(node.name);
25251
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25263
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25252
25264
  return node;
25253
25265
  }
25254
25266
  // @api
@@ -25264,7 +25276,7 @@ var ts;
25264
25276
  node.transformFlags |=
25265
25277
  propagateChildFlags(node.name) |
25266
25278
  4 /* ContainsESNext */;
25267
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25279
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25268
25280
  return node;
25269
25281
  }
25270
25282
  // @api
@@ -25278,7 +25290,7 @@ var ts;
25278
25290
  var node = createBaseNode(269 /* NamedImports */);
25279
25291
  node.elements = createNodeArray(elements);
25280
25292
  node.transformFlags |= propagateChildrenFlags(node.elements);
25281
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25293
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25282
25294
  return node;
25283
25295
  }
25284
25296
  // @api
@@ -25296,7 +25308,7 @@ var ts;
25296
25308
  node.transformFlags |=
25297
25309
  propagateChildFlags(node.propertyName) |
25298
25310
  propagateChildFlags(node.name);
25299
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25311
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25300
25312
  return node;
25301
25313
  }
25302
25314
  // @api
@@ -25315,7 +25327,7 @@ var ts;
25315
25327
  ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression)
25316
25328
  : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
25317
25329
  node.transformFlags |= propagateChildFlags(node.expression);
25318
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25330
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25319
25331
  return node;
25320
25332
  }
25321
25333
  // @api
@@ -25336,7 +25348,7 @@ var ts;
25336
25348
  node.transformFlags |=
25337
25349
  propagateChildFlags(node.exportClause) |
25338
25350
  propagateChildFlags(node.moduleSpecifier);
25339
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25351
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25340
25352
  return node;
25341
25353
  }
25342
25354
  // @api
@@ -25355,7 +25367,7 @@ var ts;
25355
25367
  var node = createBaseNode(273 /* NamedExports */);
25356
25368
  node.elements = createNodeArray(elements);
25357
25369
  node.transformFlags |= propagateChildrenFlags(node.elements);
25358
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25370
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25359
25371
  return node;
25360
25372
  }
25361
25373
  // @api
@@ -25373,7 +25385,7 @@ var ts;
25373
25385
  node.transformFlags |=
25374
25386
  propagateChildFlags(node.propertyName) |
25375
25387
  propagateChildFlags(node.name);
25376
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25388
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25377
25389
  return node;
25378
25390
  }
25379
25391
  // @api
@@ -25399,7 +25411,7 @@ var ts;
25399
25411
  var node = createBaseNode(277 /* ExternalModuleReference */);
25400
25412
  node.expression = expression;
25401
25413
  node.transformFlags |= propagateChildFlags(node.expression);
25402
- node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25414
+ node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context
25403
25415
  return node;
25404
25416
  }
25405
25417
  // @api
@@ -26173,7 +26185,7 @@ var ts;
26173
26185
  node.transformFlags |=
26174
26186
  propagateChildFlags(node.expression) |
26175
26187
  128 /* ContainsES2018 */ |
26176
- 32768 /* ContainsObjectRestOrSpread */;
26188
+ 65536 /* ContainsObjectRestOrSpread */;
26177
26189
  return node;
26178
26190
  }
26179
26191
  // @api
@@ -27130,10 +27142,10 @@ var ts;
27130
27142
  }
27131
27143
  function propagateIdentifierNameFlags(node) {
27132
27144
  // An IdentifierName is allowed to be `await`
27133
- return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */;
27145
+ return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
27134
27146
  }
27135
27147
  function propagatePropertyNameFlagsOfChild(node, transformFlags) {
27136
- return transformFlags | (node.transformFlags & 33562624 /* PropertyNamePropagatingFlags */);
27148
+ return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */);
27137
27149
  }
27138
27150
  function propagateChildFlags(child) {
27139
27151
  if (!child)
@@ -27164,29 +27176,29 @@ var ts;
27164
27176
  case 208 /* CallExpression */:
27165
27177
  case 209 /* NewExpression */:
27166
27178
  case 204 /* ArrayLiteralExpression */:
27167
- return 536887296 /* ArrayLiteralOrCallOrNewExcludes */;
27179
+ return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
27168
27180
  case 261 /* ModuleDeclaration */:
27169
- return 589443072 /* ModuleExcludes */;
27181
+ return 742678528 /* ModuleExcludes */;
27170
27182
  case 164 /* Parameter */:
27171
27183
  return 536870912 /* ParameterExcludes */;
27172
27184
  case 214 /* ArrowFunction */:
27173
- return 557748224 /* ArrowFunctionExcludes */;
27185
+ return 612179968 /* ArrowFunctionExcludes */;
27174
27186
  case 213 /* FunctionExpression */:
27175
27187
  case 256 /* FunctionDeclaration */:
27176
- return 591310848 /* FunctionExcludes */;
27188
+ return 746414080 /* FunctionExcludes */;
27177
27189
  case 255 /* VariableDeclarationList */:
27178
- return 537165824 /* VariableDeclarationListExcludes */;
27190
+ return 537460736 /* VariableDeclarationListExcludes */;
27179
27191
  case 257 /* ClassDeclaration */:
27180
27192
  case 226 /* ClassExpression */:
27181
- return 536940544 /* ClassExcludes */;
27193
+ return 537010176 /* ClassExcludes */;
27182
27194
  case 171 /* Constructor */:
27183
- return 591306752 /* ConstructorExcludes */;
27195
+ return 746405888 /* ConstructorExcludes */;
27184
27196
  case 167 /* PropertyDeclaration */:
27185
- return 570433536 /* PropertyExcludes */;
27197
+ return 671105024 /* PropertyExcludes */;
27186
27198
  case 169 /* MethodDeclaration */:
27187
27199
  case 172 /* GetAccessor */:
27188
27200
  case 173 /* SetAccessor */:
27189
- return 574529536 /* MethodOrAccessorExcludes */;
27201
+ return 679297024 /* MethodOrAccessorExcludes */;
27190
27202
  case 130 /* AnyKeyword */:
27191
27203
  case 147 /* NumberKeyword */:
27192
27204
  case 158 /* BigIntKeyword */:
@@ -27206,12 +27218,12 @@ var ts;
27206
27218
  case 259 /* TypeAliasDeclaration */:
27207
27219
  return -2 /* TypeExcludes */;
27208
27220
  case 205 /* ObjectLiteralExpression */:
27209
- return 536973312 /* ObjectLiteralExcludes */;
27221
+ return 537075712 /* ObjectLiteralExcludes */;
27210
27222
  case 292 /* CatchClause */:
27211
- return 536903680 /* CatchClauseExcludes */;
27223
+ return 536936448 /* CatchClauseExcludes */;
27212
27224
  case 201 /* ObjectBindingPattern */:
27213
27225
  case 202 /* ArrayBindingPattern */:
27214
- return 536887296 /* BindingPatternExcludes */;
27226
+ return 536903680 /* BindingPatternExcludes */;
27215
27227
  case 211 /* TypeAssertionExpression */:
27216
27228
  case 229 /* AsExpression */:
27217
27229
  case 350 /* PartiallyEmittedExpression */:
@@ -29087,6 +29099,10 @@ var ts;
29087
29099
  return node.kind === 267 /* ImportClause */;
29088
29100
  }
29089
29101
  ts.isImportClause = isImportClause;
29102
+ function isImportTypeAssertionContainer(node) {
29103
+ return node.kind === 295 /* ImportTypeAssertionContainer */;
29104
+ }
29105
+ ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer;
29090
29106
  function isAssertClause(node) {
29091
29107
  return node.kind === 293 /* AssertClause */;
29092
29108
  }
@@ -30441,6 +30457,14 @@ var ts;
30441
30457
  }
30442
30458
  }
30443
30459
  ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline;
30460
+ function elideNodes(factory, nodes) {
30461
+ if (nodes === undefined)
30462
+ return undefined;
30463
+ if (nodes.length === 0)
30464
+ return nodes;
30465
+ return ts.setTextRange(factory.createNodeArray([], nodes.hasTrailingComma), nodes);
30466
+ }
30467
+ ts.elideNodes = elideNodes;
30444
30468
  })(ts || (ts = {}));
30445
30469
  var ts;
30446
30470
  (function (ts) {
@@ -31612,7 +31636,7 @@ var ts;
31612
31636
  return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
31613
31637
  function containsPossibleTopLevelAwait(node) {
31614
31638
  return !(node.flags & 32768 /* AwaitContext */)
31615
- && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */);
31639
+ && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */);
31616
31640
  }
31617
31641
  function findNextStatementWithAwait(statements, start) {
31618
31642
  for (var i = start; i < statements.length; i++) {
@@ -31653,7 +31677,7 @@ var ts;
31653
31677
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31654
31678
  setFields(sourceFile);
31655
31679
  // If we parsed this as an external module, it may contain top-level await
31656
- if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31680
+ if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) {
31657
31681
  sourceFile = reparseTopLevelAwait(sourceFile);
31658
31682
  setFields(sourceFile);
31659
31683
  }
@@ -35659,6 +35683,9 @@ var ts;
35659
35683
  typeArguments = expression.typeArguments;
35660
35684
  expression = expression.expression;
35661
35685
  }
35686
+ if (token() === 28 /* QuestionDotToken */) {
35687
+ parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression));
35688
+ }
35662
35689
  var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35663
35690
  return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35664
35691
  }
@@ -43850,13 +43877,36 @@ var ts;
43850
43877
  }
43851
43878
  return toSearchResult(/*value*/ undefined);
43852
43879
  }
43880
+ /**
43881
+ * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
43882
+ * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
43883
+ */
43884
+ function comparePatternKeys(a, b) {
43885
+ var aPatternIndex = a.indexOf("*");
43886
+ var bPatternIndex = b.indexOf("*");
43887
+ var baseLenA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
43888
+ var baseLenB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
43889
+ if (baseLenA > baseLenB)
43890
+ return -1;
43891
+ if (baseLenB > baseLenA)
43892
+ return 1;
43893
+ if (aPatternIndex === -1)
43894
+ return 1;
43895
+ if (bPatternIndex === -1)
43896
+ return -1;
43897
+ if (a.length > b.length)
43898
+ return -1;
43899
+ if (b.length > a.length)
43900
+ return 1;
43901
+ return 0;
43902
+ }
43853
43903
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
43854
43904
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
43855
43905
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
43856
43906
  var target = lookupTable[moduleName];
43857
43907
  return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
43858
43908
  }
43859
- 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; });
43909
+ var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
43860
43910
  for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
43861
43911
  var potentialTarget = expandingKeys_1[_i];
43862
43912
  if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
@@ -53435,6 +53485,7 @@ var ts;
53435
53485
  return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
53436
53486
  }
53437
53487
  function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
53488
+ var _a, _b, _c, _d;
53438
53489
  var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
53439
53490
  var isTypeOf = meaning === 111551 /* Value */;
53440
53491
  if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
@@ -53452,6 +53503,7 @@ var ts;
53452
53503
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53453
53504
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral("import"))
53454
53505
  ])));
53506
+ (_b = (_a = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _b === void 0 ? void 0 : _b.call(_a);
53455
53507
  }
53456
53508
  }
53457
53509
  if (!specifier) {
@@ -53471,6 +53523,7 @@ var ts;
53471
53523
  assertion = ts.factory.createImportTypeAssertionContainer(ts.factory.createAssertClause(ts.factory.createNodeArray([
53472
53524
  ts.factory.createAssertEntry(ts.factory.createStringLiteral("resolution-mode"), ts.factory.createStringLiteral(swappedMode === ts.ModuleKind.ESNext ? "import" : "require"))
53473
53525
  ])));
53526
+ (_d = (_c = context.tracker).reportImportTypeNodeResolutionModeOverride) === null || _d === void 0 ? void 0 : _d.call(_c);
53474
53527
  }
53475
53528
  }
53476
53529
  if (!assertion) {
@@ -58959,7 +59012,7 @@ var ts;
58959
59012
  var objectType;
58960
59013
  return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
58961
59014
  !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
58962
- !objectType.declaration.questionToken && !objectType.declaration.nameType);
59015
+ !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType);
58963
59016
  }
58964
59017
  /**
58965
59018
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
@@ -78786,6 +78839,10 @@ var ts;
78786
78839
  if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) {
78787
78840
  checkBinaryExpression(target, checkMode);
78788
78841
  target = target.left;
78842
+ // A default value is specified, so remove undefined from the final type.
78843
+ if (strictNullChecks) {
78844
+ sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */);
78845
+ }
78789
78846
  }
78790
78847
  if (target.kind === 205 /* ObjectLiteralExpression */) {
78791
78848
  return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
@@ -80876,8 +80933,11 @@ var ts;
80876
80933
  if (node.assertions) {
80877
80934
  var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
80878
80935
  if (override) {
80936
+ if (!ts.isNightly()) {
80937
+ 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);
80938
+ }
80879
80939
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
80880
- grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80940
+ grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
80881
80941
  }
80882
80942
  }
80883
80943
  }
@@ -85283,10 +85343,10 @@ var ts;
85283
85343
  var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
85284
85344
  if (validForTypeAssertions && override) {
85285
85345
  if (!ts.isNightly()) {
85286
- 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);
85346
+ 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);
85287
85347
  }
85288
85348
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
85289
- return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85349
+ return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
85290
85350
  }
85291
85351
  return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
85292
85352
  }
@@ -91015,6 +91075,124 @@ var ts;
91015
91075
  return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
91016
91076
  }
91017
91077
  ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName;
91078
+ /**
91079
+ * Gets an array of arrays of decorators for the parameters of a function-like node.
91080
+ * The offset into the result array should correspond to the offset of the parameter.
91081
+ *
91082
+ * @param node The function-like node.
91083
+ */
91084
+ function getDecoratorsOfParameters(node) {
91085
+ var decorators;
91086
+ if (node) {
91087
+ var parameters = node.parameters;
91088
+ var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
91089
+ var firstParameterOffset = firstParameterIsThis ? 1 : 0;
91090
+ var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
91091
+ for (var i = 0; i < numParameters; i++) {
91092
+ var parameter = parameters[i + firstParameterOffset];
91093
+ if (decorators || parameter.decorators) {
91094
+ if (!decorators) {
91095
+ decorators = new Array(numParameters);
91096
+ }
91097
+ decorators[i] = parameter.decorators;
91098
+ }
91099
+ }
91100
+ }
91101
+ return decorators;
91102
+ }
91103
+ /**
91104
+ * Gets an AllDecorators object containing the decorators for the class and the decorators for the
91105
+ * parameters of the constructor of the class.
91106
+ *
91107
+ * @param node The class node.
91108
+ */
91109
+ function getAllDecoratorsOfClass(node) {
91110
+ var decorators = node.decorators;
91111
+ var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
91112
+ if (!decorators && !parameters) {
91113
+ return undefined;
91114
+ }
91115
+ return {
91116
+ decorators: decorators,
91117
+ parameters: parameters
91118
+ };
91119
+ }
91120
+ ts.getAllDecoratorsOfClass = getAllDecoratorsOfClass;
91121
+ /**
91122
+ * Gets an AllDecorators object containing the decorators for the member and its parameters.
91123
+ *
91124
+ * @param parent The class node that contains the member.
91125
+ * @param member The class member.
91126
+ */
91127
+ function getAllDecoratorsOfClassElement(member, parent) {
91128
+ switch (member.kind) {
91129
+ case 172 /* GetAccessor */:
91130
+ case 173 /* SetAccessor */:
91131
+ return getAllDecoratorsOfAccessors(member, parent);
91132
+ case 169 /* MethodDeclaration */:
91133
+ return getAllDecoratorsOfMethod(member);
91134
+ case 167 /* PropertyDeclaration */:
91135
+ return getAllDecoratorsOfProperty(member);
91136
+ default:
91137
+ return undefined;
91138
+ }
91139
+ }
91140
+ ts.getAllDecoratorsOfClassElement = getAllDecoratorsOfClassElement;
91141
+ /**
91142
+ * Gets an AllDecorators object containing the decorators for the accessor and its parameters.
91143
+ *
91144
+ * @param parent The class node that contains the accessor.
91145
+ * @param accessor The class accessor member.
91146
+ */
91147
+ function getAllDecoratorsOfAccessors(accessor, parent) {
91148
+ if (!accessor.body) {
91149
+ return undefined;
91150
+ }
91151
+ var _a = ts.getAllAccessorDeclarations(parent.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
91152
+ var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
91153
+ if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
91154
+ return undefined;
91155
+ }
91156
+ var decorators = firstAccessorWithDecorators.decorators;
91157
+ var parameters = getDecoratorsOfParameters(setAccessor);
91158
+ if (!decorators && !parameters) {
91159
+ return undefined;
91160
+ }
91161
+ return {
91162
+ decorators: decorators,
91163
+ parameters: parameters,
91164
+ getDecorators: getAccessor === null || getAccessor === void 0 ? void 0 : getAccessor.decorators,
91165
+ setDecorators: setAccessor === null || setAccessor === void 0 ? void 0 : setAccessor.decorators
91166
+ };
91167
+ }
91168
+ /**
91169
+ * Gets an AllDecorators object containing the decorators for the method and its parameters.
91170
+ *
91171
+ * @param method The class method member.
91172
+ */
91173
+ function getAllDecoratorsOfMethod(method) {
91174
+ if (!method.body) {
91175
+ return undefined;
91176
+ }
91177
+ var decorators = method.decorators;
91178
+ var parameters = getDecoratorsOfParameters(method);
91179
+ if (!decorators && !parameters) {
91180
+ return undefined;
91181
+ }
91182
+ return { decorators: decorators, parameters: parameters };
91183
+ }
91184
+ /**
91185
+ * Gets an AllDecorators object containing the decorators for the property.
91186
+ *
91187
+ * @param property The class property member.
91188
+ */
91189
+ function getAllDecoratorsOfProperty(property) {
91190
+ var decorators = property.decorators;
91191
+ if (!decorators) {
91192
+ return undefined;
91193
+ }
91194
+ return { decorators: decorators };
91195
+ }
91018
91196
  })(ts || (ts = {}));
91019
91197
  /*@internal*/
91020
91198
  var ts;
@@ -91288,8 +91466,8 @@ var ts;
91288
91466
  if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
91289
91467
  var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
91290
91468
  if (flattenContext.level >= 1 /* ObjectRest */
91291
- && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91292
- && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */))
91469
+ && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91470
+ && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
91293
91471
  && !ts.isComputedPropertyName(propertyName)) {
91294
91472
  bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
91295
91473
  }
@@ -91355,7 +91533,7 @@ var ts;
91355
91533
  if (flattenContext.level >= 1 /* ObjectRest */) {
91356
91534
  // If an array pattern contains an ObjectRest, we must cache the result so that we
91357
91535
  // can perform the ObjectRest destructuring in a different declaration
91358
- if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91536
+ if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
91359
91537
  flattenContext.hasTransformedPriorElement = true;
91360
91538
  var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
91361
91539
  if (flattenContext.hoistTempVariables) {
@@ -91577,8 +91755,6 @@ var ts;
91577
91755
  var USE_NEW_TYPE_METADATA_FORMAT = false;
91578
91756
  var TypeScriptSubstitutionFlags;
91579
91757
  (function (TypeScriptSubstitutionFlags) {
91580
- /** Enables substitutions for decorated classes. */
91581
- TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
91582
91758
  /** Enables substitutions for namespace exports. */
91583
91759
  TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
91584
91760
  /* Enables substitutions for unqualified enum members */
@@ -91604,9 +91780,9 @@ var ts;
91604
91780
  var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
91605
91781
  var resolver = context.getEmitResolver();
91606
91782
  var compilerOptions = context.getCompilerOptions();
91607
- var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
91608
91783
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
91609
91784
  var moduleKind = ts.getEmitModuleKind(compilerOptions);
91785
+ var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
91610
91786
  // Save the previous transformation hooks.
91611
91787
  var previousOnEmitNode = context.onEmitNode;
91612
91788
  var previousOnSubstituteNode = context.onSubstituteNode;
@@ -91621,7 +91797,6 @@ var ts;
91621
91797
  var currentNamespace;
91622
91798
  var currentNamespaceContainerName;
91623
91799
  var currentLexicalScope;
91624
- var currentNameScope;
91625
91800
  var currentScopeFirstDeclarationsOfName;
91626
91801
  var currentClassHasParameterProperties;
91627
91802
  /**
@@ -91629,11 +91804,6 @@ var ts;
91629
91804
  * They are persisted between each SourceFile transformation and should not be reset.
91630
91805
  */
91631
91806
  var enabledSubstitutions;
91632
- /**
91633
- * A map that keeps track of aliases created for classes with decorators to avoid issues
91634
- * with the double-binding behavior of classes.
91635
- */
91636
- var classAliases;
91637
91807
  /**
91638
91808
  * Keeps track of whether we are within any containing namespaces when performing
91639
91809
  * just-in-time substitution while printing an expression identifier.
@@ -91677,7 +91847,6 @@ var ts;
91677
91847
  function saveStateAndInvoke(node, f) {
91678
91848
  // Save state
91679
91849
  var savedCurrentScope = currentLexicalScope;
91680
- var savedCurrentNameScope = currentNameScope;
91681
91850
  var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
91682
91851
  var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
91683
91852
  // Handle state changes before visiting a node.
@@ -91688,7 +91857,6 @@ var ts;
91688
91857
  currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
91689
91858
  }
91690
91859
  currentLexicalScope = savedCurrentScope;
91691
- currentNameScope = savedCurrentNameScope;
91692
91860
  currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
91693
91861
  return visited;
91694
91862
  }
@@ -91704,7 +91872,6 @@ var ts;
91704
91872
  case 262 /* ModuleBlock */:
91705
91873
  case 235 /* Block */:
91706
91874
  currentLexicalScope = node;
91707
- currentNameScope = undefined;
91708
91875
  currentScopeFirstDeclarationsOfName = undefined;
91709
91876
  break;
91710
91877
  case 257 /* ClassDeclaration */:
@@ -91722,10 +91889,6 @@ var ts;
91722
91889
  // programs may also have an undefined name.
91723
91890
  ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
91724
91891
  }
91725
- if (ts.isClassDeclaration(node)) {
91726
- // XXX: should probably also cover interfaces and type aliases that can have type variables?
91727
- currentNameScope = node;
91728
- }
91729
91892
  break;
91730
91893
  }
91731
91894
  }
@@ -91827,35 +91990,66 @@ var ts;
91827
91990
  return node;
91828
91991
  }
91829
91992
  /**
91830
- * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91993
+ * Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
91831
91994
  *
91832
- * @param node The node to visit.
91995
+ * @param parent The class containing the elements to visit.
91833
91996
  */
91834
- function classElementVisitor(node) {
91835
- return saveStateAndInvoke(node, classElementVisitorWorker);
91997
+ function getClassElementVisitor(parent) {
91998
+ return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
91836
91999
  }
91837
92000
  /**
91838
92001
  * Specialized visitor that visits the immediate children of a class with TypeScript syntax.
91839
92002
  *
91840
92003
  * @param node The node to visit.
91841
92004
  */
91842
- function classElementVisitorWorker(node) {
92005
+ function classElementVisitorWorker(node, parent) {
91843
92006
  switch (node.kind) {
91844
92007
  case 171 /* Constructor */:
91845
92008
  return visitConstructor(node);
91846
92009
  case 167 /* PropertyDeclaration */:
91847
92010
  // Property declarations are not TypeScript syntax, but they must be visited
91848
92011
  // for the decorator transformation.
91849
- return visitPropertyDeclaration(node);
91850
- case 176 /* IndexSignature */:
92012
+ return visitPropertyDeclaration(node, parent);
91851
92013
  case 172 /* GetAccessor */:
92014
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92015
+ return visitGetAccessor(node, parent);
91852
92016
  case 173 /* SetAccessor */:
92017
+ // Set Accessors can have TypeScript modifiers and type annotations.
92018
+ return visitSetAccessor(node, parent);
91853
92019
  case 169 /* MethodDeclaration */:
92020
+ // TypeScript method declarations may have decorators, modifiers
92021
+ // or type annotations.
92022
+ return visitMethodDeclaration(node, parent);
91854
92023
  case 170 /* ClassStaticBlockDeclaration */:
91855
- // Fallback to the default visit behavior.
91856
- return visitorWorker(node);
92024
+ return ts.visitEachChild(node, visitor, context);
91857
92025
  case 234 /* SemicolonClassElement */:
91858
92026
  return node;
92027
+ case 176 /* IndexSignature */:
92028
+ // Index signatures are elided
92029
+ return;
92030
+ default:
92031
+ return ts.Debug.failBadSyntaxKind(node);
92032
+ }
92033
+ }
92034
+ function getObjectLiteralElementVisitor(parent) {
92035
+ return function (node) { return saveStateAndInvoke(node, function (n) { return objectLiteralElementVisitorWorker(n, parent); }); };
92036
+ }
92037
+ function objectLiteralElementVisitorWorker(node, parent) {
92038
+ switch (node.kind) {
92039
+ case 296 /* PropertyAssignment */:
92040
+ case 297 /* ShorthandPropertyAssignment */:
92041
+ case 298 /* SpreadAssignment */:
92042
+ return visitor(node);
92043
+ case 172 /* GetAccessor */:
92044
+ // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
92045
+ return visitGetAccessor(node, parent);
92046
+ case 173 /* SetAccessor */:
92047
+ // Set Accessors can have TypeScript modifiers and type annotations.
92048
+ return visitSetAccessor(node, parent);
92049
+ case 169 /* MethodDeclaration */:
92050
+ // TypeScript method declarations may have decorators, modifiers
92051
+ // or type annotations.
92052
+ return visitMethodDeclaration(node, parent);
91859
92053
  default:
91860
92054
  return ts.Debug.failBadSyntaxKind(node);
91861
92055
  }
@@ -91928,22 +92122,14 @@ var ts;
91928
92122
  // TypeScript type nodes are elided.
91929
92123
  // falls through
91930
92124
  case 176 /* IndexSignature */:
91931
- // TypeScript index signatures are elided.
91932
- // falls through
91933
- case 165 /* Decorator */:
91934
- // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
92125
+ // TypeScript index signatures are elided.
91935
92126
  return undefined;
91936
92127
  case 259 /* TypeAliasDeclaration */:
91937
92128
  // TypeScript type-only declarations are elided.
91938
92129
  return factory.createNotEmittedStatement(node);
91939
- case 167 /* PropertyDeclaration */:
91940
- // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
91941
- return visitPropertyDeclaration(node);
91942
92130
  case 264 /* NamespaceExportDeclaration */:
91943
92131
  // TypeScript namespace export declarations are elided.
91944
92132
  return undefined;
91945
- case 171 /* Constructor */:
91946
- return visitConstructor(node);
91947
92133
  case 258 /* InterfaceDeclaration */:
91948
92134
  // TypeScript interfaces are elided, but some comments may be preserved.
91949
92135
  // See the implementation of `getLeadingComments` in comments.ts for more details.
@@ -91977,16 +92163,15 @@ var ts;
91977
92163
  case 228 /* ExpressionWithTypeArguments */:
91978
92164
  // TypeScript supports type arguments on an expression in an `extends` heritage clause.
91979
92165
  return visitExpressionWithTypeArguments(node);
92166
+ case 205 /* ObjectLiteralExpression */:
92167
+ return visitObjectLiteralExpression(node);
92168
+ case 171 /* Constructor */:
92169
+ case 167 /* PropertyDeclaration */:
91980
92170
  case 169 /* MethodDeclaration */:
91981
- // TypeScript method declarations may have decorators, modifiers
91982
- // or type annotations.
91983
- return visitMethodDeclaration(node);
91984
92171
  case 172 /* GetAccessor */:
91985
- // Get Accessors can have TypeScript modifiers, decorators, and type annotations.
91986
- return visitGetAccessor(node);
91987
92172
  case 173 /* SetAccessor */:
91988
- // Set Accessors can have TypeScript modifiers and type annotations.
91989
- return visitSetAccessor(node);
92173
+ case 170 /* ClassStaticBlockDeclaration */:
92174
+ return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
91990
92175
  case 256 /* FunctionDeclaration */:
91991
92176
  // Typescript function declarations can have modifiers, decorators, and type annotations.
91992
92177
  return visitFunctionDeclaration(node);
@@ -92052,6 +92237,9 @@ var ts;
92052
92237
  !ts.isJsonSourceFile(node);
92053
92238
  return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
92054
92239
  }
92240
+ function visitObjectLiteralExpression(node) {
92241
+ return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
92242
+ }
92055
92243
  function getClassFacts(node, staticProperties) {
92056
92244
  var facts = 0 /* None */;
92057
92245
  if (ts.some(staticProperties))
@@ -92074,7 +92262,7 @@ var ts;
92074
92262
  return facts;
92075
92263
  }
92076
92264
  function hasTypeScriptClassSyntax(node) {
92077
- return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */);
92265
+ return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
92078
92266
  }
92079
92267
  function isClassLikeDeclarationWithTypeScriptSyntax(node) {
92080
92268
  return ts.some(node.decorators)
@@ -92084,7 +92272,9 @@ var ts;
92084
92272
  }
92085
92273
  function visitClassDeclaration(node) {
92086
92274
  if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
92087
- return ts.visitEachChild(node, visitor, context);
92275
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92276
+ ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name,
92277
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92088
92278
  }
92089
92279
  var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
92090
92280
  var facts = getClassFacts(node, staticProperties);
@@ -92092,14 +92282,25 @@ var ts;
92092
92282
  context.startLexicalEnvironment();
92093
92283
  }
92094
92284
  var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
92095
- var classStatement = facts & 2 /* HasConstructorDecorators */
92096
- ? createClassDeclarationHeadWithDecorators(node, name)
92097
- : createClassDeclarationHeadWithoutDecorators(node, name, facts);
92285
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92286
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92287
+ // we do not emit modifiers on the declaration if we are emitting an IIFE
92288
+ var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92289
+ ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92290
+ : ts.elideNodes(factory, node.modifiers); // preserve positions, if available
92291
+ // ${modifiers} class ${name} ${heritageClauses} {
92292
+ // ${members}
92293
+ // }
92294
+ var classStatement = factory.updateClassDeclaration(node, decorators, modifiers, name,
92295
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92296
+ // To better align with the old emitter, we should not emit a trailing source map
92297
+ // entry if the class has static properties.
92298
+ var emitFlags = ts.getEmitFlags(node);
92299
+ if (facts & 1 /* HasStaticInitializedProperties */) {
92300
+ emitFlags |= 32 /* NoTrailingSourceMap */;
92301
+ }
92302
+ ts.setEmitFlags(classStatement, emitFlags);
92098
92303
  var statements = [classStatement];
92099
- // Write any decorators of the node.
92100
- addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
92101
- addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
92102
- addConstructorDecorationStatement(statements, node);
92103
92304
  if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
92104
92305
  // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
92105
92306
  // 'es2015' transformer can properly nest static initializers and decorators. The result
@@ -92159,164 +92360,14 @@ var ts;
92159
92360
  }
92160
92361
  return ts.singleOrMany(statements);
92161
92362
  }
92162
- /**
92163
- * Transforms a non-decorated class declaration and appends the resulting statements.
92164
- *
92165
- * @param node A ClassDeclaration node.
92166
- * @param name The name of the class.
92167
- * @param facts Precomputed facts about the class.
92168
- */
92169
- function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
92170
- // ${modifiers} class ${name} ${heritageClauses} {
92171
- // ${members}
92172
- // }
92173
- // we do not emit modifiers on the declaration if we are emitting an IIFE
92174
- var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
92175
- ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
92176
- : undefined;
92177
- var classDeclaration = factory.createClassDeclaration(
92178
- /*decorators*/ undefined, modifiers, name,
92179
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92180
- // To better align with the old emitter, we should not emit a trailing source map
92181
- // entry if the class has static properties.
92182
- var emitFlags = ts.getEmitFlags(node);
92183
- if (facts & 1 /* HasStaticInitializedProperties */) {
92184
- emitFlags |= 32 /* NoTrailingSourceMap */;
92185
- }
92186
- ts.setTextRange(classDeclaration, node);
92187
- ts.setOriginalNode(classDeclaration, node);
92188
- ts.setEmitFlags(classDeclaration, emitFlags);
92189
- return classDeclaration;
92190
- }
92191
- /**
92192
- * Transforms a decorated class declaration and appends the resulting statements. If
92193
- * the class requires an alias to avoid issues with double-binding, the alias is returned.
92194
- */
92195
- function createClassDeclarationHeadWithDecorators(node, name) {
92196
- // When we emit an ES6 class that has a class decorator, we must tailor the
92197
- // emit to certain specific cases.
92198
- //
92199
- // In the simplest case, we emit the class declaration as a let declaration, and
92200
- // evaluate decorators after the close of the class body:
92201
- //
92202
- // [Example 1]
92203
- // ---------------------------------------------------------------------
92204
- // TypeScript | Javascript
92205
- // ---------------------------------------------------------------------
92206
- // @dec | let C = class C {
92207
- // class C { | }
92208
- // } | C = __decorate([dec], C);
92209
- // ---------------------------------------------------------------------
92210
- // @dec | let C = class C {
92211
- // export class C { | }
92212
- // } | C = __decorate([dec], C);
92213
- // | export { C };
92214
- // ---------------------------------------------------------------------
92215
- //
92216
- // If a class declaration contains a reference to itself *inside* of the class body,
92217
- // this introduces two bindings to the class: One outside of the class body, and one
92218
- // inside of the class body. If we apply decorators as in [Example 1] above, there
92219
- // is the possibility that the decorator `dec` will return a new value for the
92220
- // constructor, which would result in the binding inside of the class no longer
92221
- // pointing to the same reference as the binding outside of the class.
92222
- //
92223
- // As a result, we must instead rewrite all references to the class *inside* of the
92224
- // class body to instead point to a local temporary alias for the class:
92225
- //
92226
- // [Example 2]
92227
- // ---------------------------------------------------------------------
92228
- // TypeScript | Javascript
92229
- // ---------------------------------------------------------------------
92230
- // @dec | let C = C_1 = class C {
92231
- // class C { | static x() { return C_1.y; }
92232
- // static x() { return C.y; } | }
92233
- // static y = 1; | C.y = 1;
92234
- // } | C = C_1 = __decorate([dec], C);
92235
- // | var C_1;
92236
- // ---------------------------------------------------------------------
92237
- // @dec | let C = class C {
92238
- // export class C { | static x() { return C_1.y; }
92239
- // static x() { return C.y; } | }
92240
- // static y = 1; | C.y = 1;
92241
- // } | C = C_1 = __decorate([dec], C);
92242
- // | export { C };
92243
- // | var C_1;
92244
- // ---------------------------------------------------------------------
92245
- //
92246
- // If a class declaration is the default export of a module, we instead emit
92247
- // the export after the decorated declaration:
92248
- //
92249
- // [Example 3]
92250
- // ---------------------------------------------------------------------
92251
- // TypeScript | Javascript
92252
- // ---------------------------------------------------------------------
92253
- // @dec | let default_1 = class {
92254
- // export default class { | }
92255
- // } | default_1 = __decorate([dec], default_1);
92256
- // | export default default_1;
92257
- // ---------------------------------------------------------------------
92258
- // @dec | let C = class C {
92259
- // export default class C { | }
92260
- // } | C = __decorate([dec], C);
92261
- // | export default C;
92262
- // ---------------------------------------------------------------------
92263
- //
92264
- // If the class declaration is the default export and a reference to itself
92265
- // inside of the class body, we must emit both an alias for the class *and*
92266
- // move the export after the declaration:
92267
- //
92268
- // [Example 4]
92269
- // ---------------------------------------------------------------------
92270
- // TypeScript | Javascript
92271
- // ---------------------------------------------------------------------
92272
- // @dec | let C = class C {
92273
- // export default class C { | static x() { return C_1.y; }
92274
- // static x() { return C.y; } | }
92275
- // static y = 1; | C.y = 1;
92276
- // } | C = C_1 = __decorate([dec], C);
92277
- // | export default C;
92278
- // | var C_1;
92279
- // ---------------------------------------------------------------------
92280
- //
92281
- var location = ts.moveRangePastDecorators(node);
92282
- var classAlias = getClassAliasIfNeeded(node);
92283
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92284
- // without any block-scoped variable collision handling
92285
- var declName = languageVersion <= 2 /* ES2015 */ ?
92286
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92287
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92288
- // ... = class ${name} ${heritageClauses} {
92289
- // ${members}
92290
- // }
92291
- var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
92292
- var members = transformClassMembers(node);
92293
- var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
92294
- ts.setOriginalNode(classExpression, node);
92295
- ts.setTextRange(classExpression, location);
92296
- // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
92297
- // or decoratedClassAlias if the class contain self-reference.
92298
- var statement = factory.createVariableStatement(
92299
- /*modifiers*/ undefined, factory.createVariableDeclarationList([
92300
- factory.createVariableDeclaration(declName,
92301
- /*exclamationToken*/ undefined,
92302
- /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
92303
- ], 1 /* Let */));
92304
- ts.setOriginalNode(statement, node);
92305
- ts.setTextRange(statement, location);
92306
- ts.setCommentRange(statement, node);
92307
- return statement;
92308
- }
92309
92363
  function visitClassExpression(node) {
92310
- if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
92311
- return ts.visitEachChild(node, visitor, context);
92312
- }
92313
- var classExpression = factory.createClassExpression(
92314
- /*decorators*/ undefined,
92364
+ var allDecorators = getAllDecoratorsOfConstructor(node);
92365
+ var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92366
+ return factory.updateClassExpression(node, decorators,
92315
92367
  /*modifiers*/ undefined, node.name,
92316
- /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
92317
- ts.setOriginalNode(classExpression, node);
92318
- ts.setTextRange(classExpression, node);
92319
- return classExpression;
92368
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), isClassLikeDeclarationWithTypeScriptSyntax(node) ?
92369
+ transformClassMembers(node) :
92370
+ ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92320
92371
  }
92321
92372
  /**
92322
92373
  * Transforms the members of a class.
@@ -92341,48 +92392,9 @@ var ts;
92341
92392
  }
92342
92393
  }
92343
92394
  }
92344
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
92395
+ ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
92345
92396
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
92346
92397
  }
92347
- /**
92348
- * Gets either the static or instance members of a class that are decorated, or have
92349
- * parameters that are decorated.
92350
- *
92351
- * @param node The class containing the member.
92352
- * @param isStatic A value indicating whether to retrieve static or instance members of
92353
- * the class.
92354
- */
92355
- function getDecoratedClassElements(node, isStatic) {
92356
- return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
92357
- }
92358
- /**
92359
- * Determines whether a class member is a static member of a class that is decorated, or
92360
- * has parameters that are decorated.
92361
- *
92362
- * @param member The class member.
92363
- */
92364
- function isStaticDecoratedClassElement(member, parent) {
92365
- return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
92366
- }
92367
- /**
92368
- * Determines whether a class member is an instance member of a class that is decorated,
92369
- * or has parameters that are decorated.
92370
- *
92371
- * @param member The class member.
92372
- */
92373
- function isInstanceDecoratedClassElement(member, parent) {
92374
- return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
92375
- }
92376
- /**
92377
- * Determines whether a class member is either a static or an instance member of a class
92378
- * that is decorated, or has parameters that are decorated.
92379
- *
92380
- * @param member The class member.
92381
- */
92382
- function isDecoratedClassElement(member, isStaticElement, parent) {
92383
- return ts.nodeOrChildIsDecorated(member, parent)
92384
- && isStaticElement === ts.isStatic(member);
92385
- }
92386
92398
  /**
92387
92399
  * Gets an array of arrays of decorators for the parameters of a function-like node.
92388
92400
  * The offset into the result array should correspond to the offset of the parameter.
@@ -92428,14 +92440,14 @@ var ts;
92428
92440
  /**
92429
92441
  * Gets an AllDecorators object containing the decorators for the member and its parameters.
92430
92442
  *
92431
- * @param node The class node that contains the member.
92443
+ * @param parent The class node that contains the member.
92432
92444
  * @param member The class member.
92433
92445
  */
92434
- function getAllDecoratorsOfClassElement(node, member) {
92446
+ function getAllDecoratorsOfClassElement(member, parent) {
92435
92447
  switch (member.kind) {
92436
92448
  case 172 /* GetAccessor */:
92437
92449
  case 173 /* SetAccessor */:
92438
- return getAllDecoratorsOfAccessors(node, member);
92450
+ return getAllDecoratorsOfAccessors(parent, member);
92439
92451
  case 169 /* MethodDeclaration */:
92440
92452
  return getAllDecoratorsOfMethod(member);
92441
92453
  case 167 /* PropertyDeclaration */:
@@ -92504,209 +92516,82 @@ var ts;
92504
92516
  if (!allDecorators) {
92505
92517
  return undefined;
92506
92518
  }
92507
- var decoratorExpressions = [];
92508
- ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
92509
- ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
92510
- addTypeMetadata(node, container, decoratorExpressions);
92511
- return decoratorExpressions;
92512
- }
92513
- /**
92514
- * Generates statements 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 statements for static or
92519
- * instance members.
92520
- */
92521
- function addClassElementDecorationStatements(statements, node, isStatic) {
92522
- ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
92523
- }
92524
- /**
92525
- * Generates expressions used to apply decorators to either the static or instance members
92526
- * of a class.
92527
- *
92528
- * @param node The class node.
92529
- * @param isStatic A value indicating whether to generate expressions for static or
92530
- * instance members.
92531
- */
92532
- function generateClassElementDecorationExpressions(node, isStatic) {
92533
- var members = getDecoratedClassElements(node, isStatic);
92534
- var expressions;
92535
- for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
92536
- var member = members_8[_i];
92537
- var expression = generateClassElementDecorationExpression(node, member);
92538
- if (expression) {
92539
- if (!expressions) {
92540
- expressions = [expression];
92541
- }
92542
- else {
92543
- expressions.push(expression);
92544
- }
92545
- }
92546
- }
92547
- return expressions;
92548
- }
92549
- /**
92550
- * Generates an expression used to evaluate class element decorators at runtime.
92551
- *
92552
- * @param node The class node that contains the member.
92553
- * @param member The class member.
92554
- */
92555
- function generateClassElementDecorationExpression(node, member) {
92556
- var allDecorators = getAllDecoratorsOfClassElement(node, member);
92557
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
92558
- if (!decoratorExpressions) {
92559
- return undefined;
92560
- }
92561
- // Emit the call to __decorate. Given the following:
92562
- //
92563
- // class C {
92564
- // @dec method(@dec2 x) {}
92565
- // @dec get accessor() {}
92566
- // @dec prop;
92567
- // }
92568
- //
92569
- // The emit for a method is:
92570
- //
92571
- // __decorate([
92572
- // dec,
92573
- // __param(0, dec2),
92574
- // __metadata("design:type", Function),
92575
- // __metadata("design:paramtypes", [Object]),
92576
- // __metadata("design:returntype", void 0)
92577
- // ], C.prototype, "method", null);
92578
- //
92579
- // The emit for an accessor is:
92580
- //
92581
- // __decorate([
92582
- // dec
92583
- // ], C.prototype, "accessor", null);
92584
- //
92585
- // The emit for a property is:
92586
- //
92587
- // __decorate([
92588
- // dec
92589
- // ], C.prototype, "prop");
92590
- //
92591
- var prefix = getClassMemberPrefix(node, member);
92592
- var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
92593
- var descriptor = languageVersion > 0 /* ES3 */
92594
- ? member.kind === 167 /* PropertyDeclaration */
92595
- // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
92596
- // should not invoke `Object.getOwnPropertyDescriptor`.
92597
- ? factory.createVoidZero()
92598
- // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
92599
- // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
92600
- : factory.createNull()
92601
- : undefined;
92602
- var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
92603
- ts.setTextRange(helper, ts.moveRangePastDecorators(member));
92604
- ts.setEmitFlags(helper, 1536 /* NoComments */);
92605
- return helper;
92606
- }
92607
- /**
92608
- * Generates a __decorate helper call for a class constructor.
92609
- *
92610
- * @param node The class node.
92611
- */
92612
- function addConstructorDecorationStatement(statements, node) {
92613
- var expression = generateConstructorDecorationExpression(node);
92614
- if (expression) {
92615
- statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
92616
- }
92617
- }
92618
- /**
92619
- * Generates a __decorate helper call for a class constructor.
92620
- *
92621
- * @param node The class node.
92622
- */
92623
- function generateConstructorDecorationExpression(node) {
92624
- var allDecorators = getAllDecoratorsOfConstructor(node);
92625
- var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
92626
- if (!decoratorExpressions) {
92627
- return undefined;
92628
- }
92629
- var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
92630
- // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
92631
- // without any block-scoped variable collision handling
92632
- var localName = languageVersion <= 2 /* ES2015 */ ?
92633
- factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
92634
- factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
92635
- var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
92636
- var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
92637
- ts.setEmitFlags(expression, 1536 /* NoComments */);
92638
- ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
92639
- return expression;
92640
- }
92641
- /**
92642
- * Transforms a decorator into an expression.
92643
- *
92644
- * @param decorator The decorator node.
92645
- */
92646
- function transformDecorator(decorator) {
92647
- return ts.visitNode(decorator.expression, visitor, ts.isExpression);
92519
+ var decorators = ts.visitNodes(allDecorators.decorators, visitor, ts.isDecorator);
92520
+ var parameterDecorators = ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter);
92521
+ var metadataDecorators = ts.some(decorators) || ts.some(parameterDecorators) ? getTypeMetadata(node, container) : undefined;
92522
+ var result = factory.createNodeArray(ts.concatenate(ts.concatenate(decorators, parameterDecorators), metadataDecorators));
92523
+ ts.setTextRange(result, decorators);
92524
+ return result;
92648
92525
  }
92649
92526
  /**
92650
- * Transforms the decorators of a parameter.
92527
+ * Transforms the decorators of a parameter into decorators of the class/method.
92651
92528
  *
92652
- * @param decorators The decorators for the parameter at the provided offset.
92529
+ * @param parameterDecorators The decorators for the parameter at the provided offset.
92653
92530
  * @param parameterOffset The offset of the parameter.
92654
92531
  */
92655
- function transformDecoratorsOfParameter(decorators, parameterOffset) {
92656
- var expressions;
92657
- if (decorators) {
92658
- expressions = [];
92659
- for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
92660
- var decorator = decorators_1[_i];
92661
- var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
92662
- ts.setTextRange(helper, decorator.expression);
92532
+ function transformDecoratorsOfParameter(parameterDecorators, parameterOffset) {
92533
+ if (parameterDecorators) {
92534
+ var decorators = [];
92535
+ for (var _i = 0, parameterDecorators_1 = parameterDecorators; _i < parameterDecorators_1.length; _i++) {
92536
+ var parameterDecorator = parameterDecorators_1[_i];
92537
+ var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression);
92538
+ var helper = emitHelpers().createParamHelper(expression, parameterOffset);
92539
+ ts.setTextRange(helper, parameterDecorator.expression);
92663
92540
  ts.setEmitFlags(helper, 1536 /* NoComments */);
92664
- expressions.push(helper);
92541
+ var decorator = factory.createDecorator(helper);
92542
+ ts.setTextRange(decorator, parameterDecorator.expression);
92543
+ ts.setEmitFlags(decorator, 1536 /* NoComments */);
92544
+ decorators.push(decorator);
92665
92545
  }
92546
+ return decorators;
92666
92547
  }
92667
- return expressions;
92668
92548
  }
92669
92549
  /**
92670
- * Adds optional type metadata for a declaration.
92550
+ * Gets optional type metadata for a declaration.
92671
92551
  *
92672
92552
  * @param node The declaration node.
92673
- * @param decoratorExpressions The destination array to which to add new decorator expressions.
92674
92553
  */
92675
- function addTypeMetadata(node, container, decoratorExpressions) {
92676
- if (USE_NEW_TYPE_METADATA_FORMAT) {
92677
- addNewTypeMetadata(node, container, decoratorExpressions);
92678
- }
92679
- else {
92680
- addOldTypeMetadata(node, container, decoratorExpressions);
92681
- }
92554
+ function getTypeMetadata(node, container) {
92555
+ return USE_NEW_TYPE_METADATA_FORMAT ?
92556
+ getNewTypeMetadata(node, container) :
92557
+ getOldTypeMetadata(node, container);
92682
92558
  }
92683
- function addOldTypeMetadata(node, container, decoratorExpressions) {
92684
- if (compilerOptions.emitDecoratorMetadata) {
92559
+ function getOldTypeMetadata(node, container) {
92560
+ if (typeSerializer) {
92561
+ var decorators = void 0;
92685
92562
  if (shouldAddTypeMetadata(node)) {
92686
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
92563
+ var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92564
+ decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
92687
92565
  }
92688
92566
  if (shouldAddParamTypesMetadata(node)) {
92689
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
92567
+ var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
92568
+ decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
92690
92569
  }
92691
92570
  if (shouldAddReturnTypeMetadata(node)) {
92692
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
92571
+ var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
92572
+ decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
92693
92573
  }
92574
+ return decorators;
92694
92575
  }
92695
92576
  }
92696
- function addNewTypeMetadata(node, container, decoratorExpressions) {
92697
- if (compilerOptions.emitDecoratorMetadata) {
92577
+ function getNewTypeMetadata(node, container) {
92578
+ if (typeSerializer) {
92698
92579
  var properties = void 0;
92699
92580
  if (shouldAddTypeMetadata(node)) {
92700
- (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node))));
92581
+ var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92582
+ properties = ts.append(properties, typeProperty);
92701
92583
  }
92702
92584
  if (shouldAddParamTypesMetadata(node)) {
92703
- (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container))));
92585
+ 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)));
92586
+ properties = ts.append(properties, paramTypeProperty);
92704
92587
  }
92705
92588
  if (shouldAddReturnTypeMetadata(node)) {
92706
- (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node))));
92589
+ var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node)));
92590
+ properties = ts.append(properties, returnTypeProperty);
92707
92591
  }
92708
92592
  if (properties) {
92709
- decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true)));
92593
+ var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
92594
+ return [factory.createDecorator(typeInfoMetadata)];
92710
92595
  }
92711
92596
  }
92712
92597
  }
@@ -92753,347 +92638,6 @@ var ts;
92753
92638
  }
92754
92639
  return false;
92755
92640
  }
92756
- function getAccessorTypeNode(node) {
92757
- var accessors = resolver.getAllAccessorDeclarations(node);
92758
- return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
92759
- || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
92760
- }
92761
- /**
92762
- * Serializes the type of a node for use with decorator type metadata.
92763
- *
92764
- * @param node The node that should have its type serialized.
92765
- */
92766
- function serializeTypeOfNode(node) {
92767
- switch (node.kind) {
92768
- case 167 /* PropertyDeclaration */:
92769
- case 164 /* Parameter */:
92770
- return serializeTypeNode(node.type);
92771
- case 173 /* SetAccessor */:
92772
- case 172 /* GetAccessor */:
92773
- return serializeTypeNode(getAccessorTypeNode(node));
92774
- case 257 /* ClassDeclaration */:
92775
- case 226 /* ClassExpression */:
92776
- case 169 /* MethodDeclaration */:
92777
- return factory.createIdentifier("Function");
92778
- default:
92779
- return factory.createVoidZero();
92780
- }
92781
- }
92782
- /**
92783
- * Serializes the types of the parameters of a node for use with decorator type metadata.
92784
- *
92785
- * @param node The node that should have its parameter types serialized.
92786
- */
92787
- function serializeParameterTypesOfNode(node, container) {
92788
- var valueDeclaration = ts.isClassLike(node)
92789
- ? ts.getFirstConstructorWithBody(node)
92790
- : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
92791
- ? node
92792
- : undefined;
92793
- var expressions = [];
92794
- if (valueDeclaration) {
92795
- var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
92796
- var numParameters = parameters.length;
92797
- for (var i = 0; i < numParameters; i++) {
92798
- var parameter = parameters[i];
92799
- if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
92800
- continue;
92801
- }
92802
- if (parameter.dotDotDotToken) {
92803
- expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
92804
- }
92805
- else {
92806
- expressions.push(serializeTypeOfNode(parameter));
92807
- }
92808
- }
92809
- }
92810
- return factory.createArrayLiteralExpression(expressions);
92811
- }
92812
- function getParametersOfDecoratedDeclaration(node, container) {
92813
- if (container && node.kind === 172 /* GetAccessor */) {
92814
- var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
92815
- if (setAccessor) {
92816
- return setAccessor.parameters;
92817
- }
92818
- }
92819
- return node.parameters;
92820
- }
92821
- /**
92822
- * Serializes the return type of a node for use with decorator type metadata.
92823
- *
92824
- * @param node The node that should have its return type serialized.
92825
- */
92826
- function serializeReturnTypeOfNode(node) {
92827
- if (ts.isFunctionLike(node) && node.type) {
92828
- return serializeTypeNode(node.type);
92829
- }
92830
- else if (ts.isAsyncFunction(node)) {
92831
- return factory.createIdentifier("Promise");
92832
- }
92833
- return factory.createVoidZero();
92834
- }
92835
- /**
92836
- * Serializes a type node for use with decorator type metadata.
92837
- *
92838
- * Types are serialized in the following fashion:
92839
- * - Void types point to "undefined" (e.g. "void 0")
92840
- * - Function and Constructor types point to the global "Function" constructor.
92841
- * - Interface types with a call or construct signature types point to the global
92842
- * "Function" constructor.
92843
- * - Array and Tuple types point to the global "Array" constructor.
92844
- * - Type predicates and booleans point to the global "Boolean" constructor.
92845
- * - String literal types and strings point to the global "String" constructor.
92846
- * - Enum and number types point to the global "Number" constructor.
92847
- * - Symbol types point to the global "Symbol" constructor.
92848
- * - Type references to classes (or class-like variables) point to the constructor for the class.
92849
- * - Anything else points to the global "Object" constructor.
92850
- *
92851
- * @param node The type node to serialize.
92852
- */
92853
- function serializeTypeNode(node) {
92854
- if (node === undefined) {
92855
- return factory.createIdentifier("Object");
92856
- }
92857
- switch (node.kind) {
92858
- case 114 /* VoidKeyword */:
92859
- case 153 /* UndefinedKeyword */:
92860
- case 143 /* NeverKeyword */:
92861
- return factory.createVoidZero();
92862
- case 191 /* ParenthesizedType */:
92863
- return serializeTypeNode(node.type);
92864
- case 179 /* FunctionType */:
92865
- case 180 /* ConstructorType */:
92866
- return factory.createIdentifier("Function");
92867
- case 183 /* ArrayType */:
92868
- case 184 /* TupleType */:
92869
- return factory.createIdentifier("Array");
92870
- case 177 /* TypePredicate */:
92871
- case 133 /* BooleanKeyword */:
92872
- return factory.createIdentifier("Boolean");
92873
- case 198 /* TemplateLiteralType */:
92874
- case 150 /* StringKeyword */:
92875
- return factory.createIdentifier("String");
92876
- case 148 /* ObjectKeyword */:
92877
- return factory.createIdentifier("Object");
92878
- case 196 /* LiteralType */:
92879
- switch (node.literal.kind) {
92880
- case 10 /* StringLiteral */:
92881
- case 14 /* NoSubstitutionTemplateLiteral */:
92882
- return factory.createIdentifier("String");
92883
- case 219 /* PrefixUnaryExpression */:
92884
- case 8 /* NumericLiteral */:
92885
- return factory.createIdentifier("Number");
92886
- case 9 /* BigIntLiteral */:
92887
- return getGlobalBigIntNameWithFallback();
92888
- case 110 /* TrueKeyword */:
92889
- case 95 /* FalseKeyword */:
92890
- return factory.createIdentifier("Boolean");
92891
- case 104 /* NullKeyword */:
92892
- return factory.createVoidZero();
92893
- default:
92894
- return ts.Debug.failBadSyntaxKind(node.literal);
92895
- }
92896
- case 147 /* NumberKeyword */:
92897
- return factory.createIdentifier("Number");
92898
- case 158 /* BigIntKeyword */:
92899
- return getGlobalBigIntNameWithFallback();
92900
- case 151 /* SymbolKeyword */:
92901
- return languageVersion < 2 /* ES2015 */
92902
- ? getGlobalSymbolNameWithFallback()
92903
- : factory.createIdentifier("Symbol");
92904
- case 178 /* TypeReference */:
92905
- return serializeTypeReferenceNode(node);
92906
- case 188 /* IntersectionType */:
92907
- case 187 /* UnionType */:
92908
- return serializeTypeList(node.types);
92909
- case 189 /* ConditionalType */:
92910
- return serializeTypeList([node.trueType, node.falseType]);
92911
- case 193 /* TypeOperator */:
92912
- if (node.operator === 145 /* ReadonlyKeyword */) {
92913
- return serializeTypeNode(node.type);
92914
- }
92915
- break;
92916
- case 181 /* TypeQuery */:
92917
- case 194 /* IndexedAccessType */:
92918
- case 195 /* MappedType */:
92919
- case 182 /* TypeLiteral */:
92920
- case 130 /* AnyKeyword */:
92921
- case 155 /* UnknownKeyword */:
92922
- case 192 /* ThisType */:
92923
- case 200 /* ImportType */:
92924
- break;
92925
- // handle JSDoc types from an invalid parse
92926
- case 312 /* JSDocAllType */:
92927
- case 313 /* JSDocUnknownType */:
92928
- case 317 /* JSDocFunctionType */:
92929
- case 318 /* JSDocVariadicType */:
92930
- case 319 /* JSDocNamepathType */:
92931
- break;
92932
- case 314 /* JSDocNullableType */:
92933
- case 315 /* JSDocNonNullableType */:
92934
- case 316 /* JSDocOptionalType */:
92935
- return serializeTypeNode(node.type);
92936
- default:
92937
- return ts.Debug.failBadSyntaxKind(node);
92938
- }
92939
- return factory.createIdentifier("Object");
92940
- }
92941
- function serializeTypeList(types) {
92942
- // Note when updating logic here also update getEntityNameForDecoratorMetadata
92943
- // so that aliases can be marked as referenced
92944
- var serializedUnion;
92945
- for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
92946
- var typeNode = types_22[_i];
92947
- while (typeNode.kind === 191 /* ParenthesizedType */) {
92948
- typeNode = typeNode.type; // Skip parens if need be
92949
- }
92950
- if (typeNode.kind === 143 /* NeverKeyword */) {
92951
- continue; // Always elide `never` from the union/intersection if possible
92952
- }
92953
- if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
92954
- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
92955
- }
92956
- var serializedIndividual = serializeTypeNode(typeNode);
92957
- if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
92958
- // One of the individual is global object, return immediately
92959
- return serializedIndividual;
92960
- }
92961
- // If there exists union that is not void 0 expression, check if the the common type is identifier.
92962
- // anything more complex and we will just default to Object
92963
- else if (serializedUnion) {
92964
- // Different types
92965
- if (!ts.isIdentifier(serializedUnion) ||
92966
- !ts.isIdentifier(serializedIndividual) ||
92967
- serializedUnion.escapedText !== serializedIndividual.escapedText) {
92968
- return factory.createIdentifier("Object");
92969
- }
92970
- }
92971
- else {
92972
- // Initialize the union type
92973
- serializedUnion = serializedIndividual;
92974
- }
92975
- }
92976
- // If we were able to find common type, use it
92977
- return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
92978
- }
92979
- /**
92980
- * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
92981
- * decorator type metadata.
92982
- *
92983
- * @param node The type reference node.
92984
- */
92985
- function serializeTypeReferenceNode(node) {
92986
- var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
92987
- switch (kind) {
92988
- case ts.TypeReferenceSerializationKind.Unknown:
92989
- // From conditional type type reference that cannot be resolved is Similar to any or unknown
92990
- if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
92991
- return factory.createIdentifier("Object");
92992
- }
92993
- var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
92994
- var temp = factory.createTempVariable(hoistVariableDeclaration);
92995
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
92996
- /*questionToken*/ undefined, temp,
92997
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
92998
- case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
92999
- return serializeEntityNameAsExpression(node.typeName);
93000
- case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
93001
- return factory.createVoidZero();
93002
- case ts.TypeReferenceSerializationKind.BigIntLikeType:
93003
- return getGlobalBigIntNameWithFallback();
93004
- case ts.TypeReferenceSerializationKind.BooleanType:
93005
- return factory.createIdentifier("Boolean");
93006
- case ts.TypeReferenceSerializationKind.NumberLikeType:
93007
- return factory.createIdentifier("Number");
93008
- case ts.TypeReferenceSerializationKind.StringLikeType:
93009
- return factory.createIdentifier("String");
93010
- case ts.TypeReferenceSerializationKind.ArrayLikeType:
93011
- return factory.createIdentifier("Array");
93012
- case ts.TypeReferenceSerializationKind.ESSymbolType:
93013
- return languageVersion < 2 /* ES2015 */
93014
- ? getGlobalSymbolNameWithFallback()
93015
- : factory.createIdentifier("Symbol");
93016
- case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
93017
- return factory.createIdentifier("Function");
93018
- case ts.TypeReferenceSerializationKind.Promise:
93019
- return factory.createIdentifier("Promise");
93020
- case ts.TypeReferenceSerializationKind.ObjectType:
93021
- return factory.createIdentifier("Object");
93022
- default:
93023
- return ts.Debug.assertNever(kind);
93024
- }
93025
- }
93026
- function createCheckedValue(left, right) {
93027
- return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
93028
- }
93029
- /**
93030
- * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
93031
- *
93032
- * @param node The entity name to serialize.
93033
- */
93034
- function serializeEntityNameAsExpressionFallback(node) {
93035
- if (node.kind === 79 /* Identifier */) {
93036
- // A -> typeof A !== undefined && A
93037
- var copied = serializeEntityNameAsExpression(node);
93038
- return createCheckedValue(copied, copied);
93039
- }
93040
- if (node.left.kind === 79 /* Identifier */) {
93041
- // A.B -> typeof A !== undefined && A.B
93042
- return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
93043
- }
93044
- // A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
93045
- var left = serializeEntityNameAsExpressionFallback(node.left);
93046
- var temp = factory.createTempVariable(hoistVariableDeclaration);
93047
- return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
93048
- }
93049
- /**
93050
- * Serializes an entity name as an expression for decorator type metadata.
93051
- *
93052
- * @param node The entity name to serialize.
93053
- */
93054
- function serializeEntityNameAsExpression(node) {
93055
- switch (node.kind) {
93056
- case 79 /* Identifier */:
93057
- // Create a clone of the name with a new parent, and treat it as if it were
93058
- // a source tree node for the purposes of the checker.
93059
- var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
93060
- name.original = undefined;
93061
- ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
93062
- return name;
93063
- case 161 /* QualifiedName */:
93064
- return serializeQualifiedNameAsExpression(node);
93065
- }
93066
- }
93067
- /**
93068
- * Serializes an qualified name as an expression for decorator type metadata.
93069
- *
93070
- * @param node The qualified name to serialize.
93071
- * @param useFallback A value indicating whether to use logical operators to test for the
93072
- * qualified name at runtime.
93073
- */
93074
- function serializeQualifiedNameAsExpression(node) {
93075
- return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
93076
- }
93077
- /**
93078
- * Gets an expression that points to the global "Symbol" constructor at runtime if it is
93079
- * available.
93080
- */
93081
- function getGlobalSymbolNameWithFallback() {
93082
- return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
93083
- /*questionToken*/ undefined, factory.createIdentifier("Symbol"),
93084
- /*colonToken*/ undefined, factory.createIdentifier("Object"));
93085
- }
93086
- /**
93087
- * Gets an expression that points to the global "BigInt" constructor at runtime if it is
93088
- * available.
93089
- */
93090
- function getGlobalBigIntNameWithFallback() {
93091
- return languageVersion < 99 /* ESNext */
93092
- ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
93093
- /*questionToken*/ undefined, factory.createIdentifier("BigInt"),
93094
- /*colonToken*/ undefined, factory.createIdentifier("Object"))
93095
- : factory.createIdentifier("BigInt");
93096
- }
93097
92641
  /**
93098
92642
  * Gets an expression that represents a property name (for decorated properties or enums).
93099
92643
  * For a computed property, a name is generated for the node.
@@ -93178,21 +92722,23 @@ var ts;
93178
92722
  function shouldEmitFunctionLikeDeclaration(node) {
93179
92723
  return !ts.nodeIsMissing(node.body);
93180
92724
  }
93181
- function visitPropertyDeclaration(node) {
93182
- if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
92725
+ function visitPropertyDeclaration(node, parent) {
92726
+ var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
92727
+ if (isAmbient && !ts.some(node.decorators)) {
93183
92728
  return undefined;
93184
92729
  }
93185
- var updated = factory.updatePropertyDeclaration(node,
93186
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
92730
+ var allDecorators = getAllDecoratorsOfClassElement(node, parent);
92731
+ var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators);
92732
+ // Preserve a `declare x` property with decorators to be handled by the decorators transform
92733
+ if (isAmbient) {
92734
+ return factory.updatePropertyDeclaration(node, decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */), ts.visitNode(node.name, visitor, ts.isPropertyName),
92735
+ /*questionOrExclamationToken*/ undefined,
92736
+ /*type*/ undefined,
92737
+ /*initializer*/ undefined);
92738
+ }
92739
+ return factory.updatePropertyDeclaration(node, decorators, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
93187
92740
  /*questionOrExclamationToken*/ undefined,
93188
92741
  /*type*/ undefined, ts.visitNode(node.initializer, visitor));
93189
- if (updated !== node) {
93190
- // While we emit the source map for the node after skipping decorators and modifiers,
93191
- // we need to emit the comments for the original range.
93192
- ts.setCommentRange(updated, node);
93193
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93194
- }
93195
- return updated;
93196
92742
  }
93197
92743
  function visitConstructor(node) {
93198
92744
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93200,7 +92746,7 @@ var ts;
93200
92746
  }
93201
92747
  return factory.updateConstructorDeclaration(node,
93202
92748
  /*decorators*/ undefined,
93203
- /*modifiers*/ undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
92749
+ /*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
93204
92750
  }
93205
92751
  function transformConstructorBody(body, constructor) {
93206
92752
  var parametersWithPropertyAssignments = constructor &&
@@ -93264,22 +92810,19 @@ var ts;
93264
92810
  ts.setEmitFlags(localName, 1536 /* NoComments */);
93265
92811
  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))));
93266
92812
  }
93267
- function visitMethodDeclaration(node) {
92813
+ function visitMethodDeclaration(node, parent) {
92814
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92815
+ return node;
92816
+ }
93268
92817
  if (!shouldEmitFunctionLikeDeclaration(node)) {
93269
92818
  return undefined;
93270
92819
  }
93271
- var updated = factory.updateMethodDeclaration(node,
93272
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
92820
+ var allDecorators = ts.isClassLike(parent) ? getAllDecoratorsOfClassElement(node, parent) : undefined;
92821
+ var decorators = ts.isClassLike(parent) ? transformAllDecoratorsOfDeclaration(node, parent, allDecorators) : undefined;
92822
+ return factory.updateMethodDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node),
93273
92823
  /*questionToken*/ undefined,
93274
92824
  /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
93275
92825
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
93276
- if (updated !== node) {
93277
- // While we emit the source map for the node after skipping decorators and modifiers,
93278
- // we need to emit the comments for the original range.
93279
- ts.setCommentRange(updated, node);
93280
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93281
- }
93282
- return updated;
93283
92826
  }
93284
92827
  /**
93285
92828
  * Determines whether to emit an accessor declaration. We should not emit the
@@ -93290,34 +92833,30 @@ var ts;
93290
92833
  function shouldEmitAccessorDeclaration(node) {
93291
92834
  return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
93292
92835
  }
93293
- function visitGetAccessor(node) {
92836
+ function visitGetAccessor(node, parent) {
92837
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92838
+ return node;
92839
+ }
93294
92840
  if (!shouldEmitAccessorDeclaration(node)) {
93295
92841
  return undefined;
93296
92842
  }
93297
- var updated = factory.updateGetAccessorDeclaration(node,
93298
- /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
92843
+ var decorators = ts.isClassLike(parent) ?
92844
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92845
+ undefined;
92846
+ return factory.updateGetAccessorDeclaration(node, decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context),
93299
92847
  /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
93300
- if (updated !== node) {
93301
- // While we emit the source map for the node after skipping decorators and modifiers,
93302
- // we need to emit the comments for the original range.
93303
- ts.setCommentRange(updated, node);
93304
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93305
- }
93306
- return updated;
93307
92848
  }
93308
- function visitSetAccessor(node) {
92849
+ function visitSetAccessor(node, parent) {
92850
+ if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
92851
+ return node;
92852
+ }
93309
92853
  if (!shouldEmitAccessorDeclaration(node)) {
93310
92854
  return undefined;
93311
92855
  }
93312
- var updated = factory.updateSetAccessorDeclaration(node,
93313
- /*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([]));
93314
- if (updated !== node) {
93315
- // While we emit the source map for the node after skipping decorators and modifiers,
93316
- // we need to emit the comments for the original range.
93317
- ts.setCommentRange(updated, node);
93318
- ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
93319
- }
93320
- return updated;
92856
+ var decorators = ts.isClassLike(parent) ?
92857
+ transformAllDecoratorsOfDeclaration(node, parent, getAllDecoratorsOfClassElement(node, parent)) :
92858
+ undefined;
92859
+ 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([]));
93321
92860
  }
93322
92861
  function visitFunctionDeclaration(node) {
93323
92862
  if (!shouldEmitFunctionLikeDeclaration(node)) {
@@ -93353,9 +92892,9 @@ var ts;
93353
92892
  if (ts.parameterIsThisKeyword(node)) {
93354
92893
  return undefined;
93355
92894
  }
93356
- var updated = factory.updateParameterDeclaration(node,
93357
- /*decorators*/ undefined,
93358
- /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
92895
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators), // preserve positions, if available
92896
+ ts.elideNodes(factory, node.modifiers), // preserve positions, if available
92897
+ node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
93359
92898
  /*questionToken*/ undefined,
93360
92899
  /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
93361
92900
  if (updated !== node) {
@@ -94051,12 +93590,6 @@ var ts;
94051
93590
  return isExternalModuleExport(node)
94052
93591
  && ts.hasSyntacticModifier(node, 512 /* Default */);
94053
93592
  }
94054
- /**
94055
- * Creates a statement for the provided expression. This is used in calls to `map`.
94056
- */
94057
- function expressionToStatement(expression) {
94058
- return factory.createExpressionStatement(expression);
94059
- }
94060
93593
  function addExportMemberAssignment(statements, node) {
94061
93594
  var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
94062
93595
  ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
@@ -94088,44 +93621,12 @@ var ts;
94088
93621
  function getNamespaceContainerName(node) {
94089
93622
  return factory.getGeneratedNameForNode(node);
94090
93623
  }
94091
- /**
94092
- * Gets a local alias for a class declaration if it is a decorated class with an internal
94093
- * reference to the static side of the class. This is necessary to avoid issues with
94094
- * double-binding semantics for the class name.
94095
- */
94096
- function getClassAliasIfNeeded(node) {
94097
- if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
94098
- enableSubstitutionForClassAliases();
94099
- var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
94100
- classAliases[ts.getOriginalNodeId(node)] = classAlias;
94101
- hoistVariableDeclaration(classAlias);
94102
- return classAlias;
94103
- }
94104
- }
94105
- function getClassPrototype(node) {
94106
- return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
94107
- }
94108
- function getClassMemberPrefix(node, member) {
94109
- return ts.isStatic(member)
94110
- ? factory.getDeclarationName(node)
94111
- : getClassPrototype(node);
94112
- }
94113
93624
  function enableSubstitutionForNonQualifiedEnumMembers() {
94114
93625
  if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
94115
93626
  enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
94116
93627
  context.enableSubstitution(79 /* Identifier */);
94117
93628
  }
94118
93629
  }
94119
- function enableSubstitutionForClassAliases() {
94120
- if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
94121
- enabledSubstitutions |= 1 /* ClassAliases */;
94122
- // We need to enable substitutions for identifiers. This allows us to
94123
- // substitute class names inside of a class declaration.
94124
- context.enableSubstitution(79 /* Identifier */);
94125
- // Keep track of class aliases.
94126
- classAliases = [];
94127
- }
94128
- }
94129
93630
  function enableSubstitutionForNamespaceExports() {
94130
93631
  if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
94131
93632
  enabledSubstitutions |= 2 /* NamespaceExports */;
@@ -94210,32 +93711,9 @@ var ts;
94210
93711
  return node;
94211
93712
  }
94212
93713
  function substituteExpressionIdentifier(node) {
94213
- return trySubstituteClassAlias(node)
94214
- || trySubstituteNamespaceExportedName(node)
93714
+ return trySubstituteNamespaceExportedName(node)
94215
93715
  || node;
94216
93716
  }
94217
- function trySubstituteClassAlias(node) {
94218
- if (enabledSubstitutions & 1 /* ClassAliases */) {
94219
- if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
94220
- // Due to the emit for class decorators, any reference to the class from inside of the class body
94221
- // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
94222
- // behavior of class names in ES6.
94223
- // Also, when emitting statics for class expressions, we must substitute a class alias for
94224
- // constructor references in static property initializers.
94225
- var declaration = resolver.getReferencedValueDeclaration(node);
94226
- if (declaration) {
94227
- var classAlias = classAliases[declaration.id]; // TODO: GH#18217
94228
- if (classAlias) {
94229
- var clone_2 = factory.cloneNode(classAlias);
94230
- ts.setSourceMapRange(clone_2, node);
94231
- ts.setCommentRange(clone_2, node);
94232
- return clone_2;
94233
- }
94234
- }
94235
- }
94236
- }
94237
- return undefined;
94238
- }
94239
93717
  function trySubstituteNamespaceExportedName(node) {
94240
93718
  // If this is explicitly a local name, do not substitute.
94241
93719
  if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
@@ -94373,7 +93851,7 @@ var ts;
94373
93851
  return visited;
94374
93852
  }
94375
93853
  function visitorWorker(node, valueIsDiscarded) {
94376
- if (node.transformFlags & 8388608 /* ContainsClassFields */) {
93854
+ if (node.transformFlags & 16777216 /* ContainsClassFields */) {
94377
93855
  switch (node.kind) {
94378
93856
  case 226 /* ClassExpression */:
94379
93857
  case 257 /* ClassDeclaration */:
@@ -94388,8 +93866,8 @@ var ts;
94388
93866
  return visitClassStaticBlockDeclaration(node);
94389
93867
  }
94390
93868
  }
94391
- if (node.transformFlags & 8388608 /* ContainsClassFields */ ||
94392
- node.transformFlags & 33554432 /* ContainsLexicalSuper */ &&
93869
+ if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
93870
+ node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
94393
93871
  shouldTransformSuperInStaticInitializers &&
94394
93872
  currentStaticPropertyDeclarationOrStaticBlock &&
94395
93873
  currentClassLexicalEnvironment) {
@@ -94963,13 +94441,13 @@ var ts;
94963
94441
  facts |= 2 /* NeedsClassConstructorReference */;
94964
94442
  }
94965
94443
  if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
94966
- if (shouldTransformThisInStaticInitializers && member.transformFlags & 8192 /* ContainsLexicalThis */) {
94444
+ if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
94967
94445
  facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
94968
94446
  if (!(facts & 1 /* ClassWasDecorated */)) {
94969
94447
  facts |= 2 /* NeedsClassConstructorReference */;
94970
94448
  }
94971
94449
  }
94972
- if (shouldTransformSuperInStaticInitializers && member.transformFlags & 33554432 /* ContainsLexicalSuper */) {
94450
+ if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
94973
94451
  if (!(facts & 1 /* ClassWasDecorated */)) {
94974
94452
  facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
94975
94453
  }
@@ -95554,10 +95032,10 @@ var ts;
95554
95032
  if (declaration) {
95555
95033
  var classAlias = classAliases[declaration.id]; // TODO: GH#18217
95556
95034
  if (classAlias) {
95557
- var clone_3 = factory.cloneNode(classAlias);
95558
- ts.setSourceMapRange(clone_3, node);
95559
- ts.setCommentRange(clone_3, node);
95560
- return clone_3;
95035
+ var clone_2 = factory.cloneNode(classAlias);
95036
+ ts.setSourceMapRange(clone_2, node);
95037
+ ts.setCommentRange(clone_2, node);
95038
+ return clone_2;
95561
95039
  }
95562
95040
  }
95563
95041
  }
@@ -95919,6 +95397,965 @@ var ts;
95919
95397
  })(ts || (ts = {}));
95920
95398
  /*@internal*/
95921
95399
  var ts;
95400
+ (function (ts) {
95401
+ function createRuntimeTypeSerializer(context) {
95402
+ var hoistVariableDeclaration = context.hoistVariableDeclaration;
95403
+ var resolver = context.getEmitResolver();
95404
+ var compilerOptions = context.getCompilerOptions();
95405
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95406
+ var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
95407
+ var currentLexicalScope;
95408
+ var currentNameScope;
95409
+ return {
95410
+ serializeTypeNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeNode, node); },
95411
+ serializeTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeTypeOfNode, node); },
95412
+ serializeParameterTypesOfNode: function (serializerContext, node, container) { return setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container); },
95413
+ serializeReturnTypeOfNode: function (serializerContext, node) { return setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node); },
95414
+ };
95415
+ function setSerializerContextAnd(serializerContext, cb, node, arg) {
95416
+ var savedCurrentLexicalScope = currentLexicalScope;
95417
+ var savedCurrentNameScope = currentNameScope;
95418
+ currentLexicalScope = serializerContext.currentLexicalScope;
95419
+ currentNameScope = serializerContext.currentNameScope;
95420
+ var result = arg === undefined ? cb(node) : cb(node, arg);
95421
+ currentLexicalScope = savedCurrentLexicalScope;
95422
+ currentNameScope = savedCurrentNameScope;
95423
+ return result;
95424
+ }
95425
+ function getAccessorTypeNode(node) {
95426
+ var accessors = resolver.getAllAccessorDeclarations(node);
95427
+ return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
95428
+ || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
95429
+ }
95430
+ /**
95431
+ * Serializes the type of a node for use with decorator type metadata.
95432
+ * @param node The node that should have its type serialized.
95433
+ */
95434
+ function serializeTypeOfNode(node) {
95435
+ switch (node.kind) {
95436
+ case 167 /* PropertyDeclaration */:
95437
+ case 164 /* Parameter */:
95438
+ return serializeTypeNode(node.type);
95439
+ case 173 /* SetAccessor */:
95440
+ case 172 /* GetAccessor */:
95441
+ return serializeTypeNode(getAccessorTypeNode(node));
95442
+ case 257 /* ClassDeclaration */:
95443
+ case 226 /* ClassExpression */:
95444
+ case 169 /* MethodDeclaration */:
95445
+ return ts.factory.createIdentifier("Function");
95446
+ default:
95447
+ return ts.factory.createVoidZero();
95448
+ }
95449
+ }
95450
+ /**
95451
+ * Serializes the type of a node for use with decorator type metadata.
95452
+ * @param node The node that should have its type serialized.
95453
+ */
95454
+ function serializeParameterTypesOfNode(node, container) {
95455
+ var valueDeclaration = ts.isClassLike(node)
95456
+ ? ts.getFirstConstructorWithBody(node)
95457
+ : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
95458
+ ? node
95459
+ : undefined;
95460
+ var expressions = [];
95461
+ if (valueDeclaration) {
95462
+ var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
95463
+ var numParameters = parameters.length;
95464
+ for (var i = 0; i < numParameters; i++) {
95465
+ var parameter = parameters[i];
95466
+ if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
95467
+ continue;
95468
+ }
95469
+ if (parameter.dotDotDotToken) {
95470
+ expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
95471
+ }
95472
+ else {
95473
+ expressions.push(serializeTypeOfNode(parameter));
95474
+ }
95475
+ }
95476
+ }
95477
+ return ts.factory.createArrayLiteralExpression(expressions);
95478
+ }
95479
+ function getParametersOfDecoratedDeclaration(node, container) {
95480
+ if (container && node.kind === 172 /* GetAccessor */) {
95481
+ var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
95482
+ if (setAccessor) {
95483
+ return setAccessor.parameters;
95484
+ }
95485
+ }
95486
+ return node.parameters;
95487
+ }
95488
+ /**
95489
+ * Serializes the return type of a node for use with decorator type metadata.
95490
+ * @param node The node that should have its return type serialized.
95491
+ */
95492
+ function serializeReturnTypeOfNode(node) {
95493
+ if (ts.isFunctionLike(node) && node.type) {
95494
+ return serializeTypeNode(node.type);
95495
+ }
95496
+ else if (ts.isAsyncFunction(node)) {
95497
+ return ts.factory.createIdentifier("Promise");
95498
+ }
95499
+ return ts.factory.createVoidZero();
95500
+ }
95501
+ /**
95502
+ * Serializes a type node for use with decorator type metadata.
95503
+ *
95504
+ * Types are serialized in the following fashion:
95505
+ * - Void types point to "undefined" (e.g. "void 0")
95506
+ * - Function and Constructor types point to the global "Function" constructor.
95507
+ * - Interface types with a call or construct signature types point to the global
95508
+ * "Function" constructor.
95509
+ * - Array and Tuple types point to the global "Array" constructor.
95510
+ * - Type predicates and booleans point to the global "Boolean" constructor.
95511
+ * - String literal types and strings point to the global "String" constructor.
95512
+ * - Enum and number types point to the global "Number" constructor.
95513
+ * - Symbol types point to the global "Symbol" constructor.
95514
+ * - Type references to classes (or class-like variables) point to the constructor for the class.
95515
+ * - Anything else points to the global "Object" constructor.
95516
+ *
95517
+ * @param node The type node to serialize.
95518
+ */
95519
+ function serializeTypeNode(node) {
95520
+ if (node === undefined) {
95521
+ return ts.factory.createIdentifier("Object");
95522
+ }
95523
+ node = ts.skipTypeParentheses(node);
95524
+ switch (node.kind) {
95525
+ case 114 /* VoidKeyword */:
95526
+ case 153 /* UndefinedKeyword */:
95527
+ case 143 /* NeverKeyword */:
95528
+ return ts.factory.createVoidZero();
95529
+ case 179 /* FunctionType */:
95530
+ case 180 /* ConstructorType */:
95531
+ return ts.factory.createIdentifier("Function");
95532
+ case 183 /* ArrayType */:
95533
+ case 184 /* TupleType */:
95534
+ return ts.factory.createIdentifier("Array");
95535
+ case 177 /* TypePredicate */:
95536
+ return node.assertsModifier ?
95537
+ ts.factory.createVoidZero() :
95538
+ ts.factory.createIdentifier("Boolean");
95539
+ case 133 /* BooleanKeyword */:
95540
+ return ts.factory.createIdentifier("Boolean");
95541
+ case 198 /* TemplateLiteralType */:
95542
+ case 150 /* StringKeyword */:
95543
+ return ts.factory.createIdentifier("String");
95544
+ case 148 /* ObjectKeyword */:
95545
+ return ts.factory.createIdentifier("Object");
95546
+ case 196 /* LiteralType */:
95547
+ return serializeLiteralOfLiteralTypeNode(node.literal);
95548
+ case 147 /* NumberKeyword */:
95549
+ return ts.factory.createIdentifier("Number");
95550
+ case 158 /* BigIntKeyword */:
95551
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95552
+ case 151 /* SymbolKeyword */:
95553
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95554
+ case 178 /* TypeReference */:
95555
+ return serializeTypeReferenceNode(node);
95556
+ case 188 /* IntersectionType */:
95557
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true);
95558
+ case 187 /* UnionType */:
95559
+ return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false);
95560
+ case 189 /* ConditionalType */:
95561
+ return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false);
95562
+ case 193 /* TypeOperator */:
95563
+ if (node.operator === 145 /* ReadonlyKeyword */) {
95564
+ return serializeTypeNode(node.type);
95565
+ }
95566
+ break;
95567
+ case 181 /* TypeQuery */:
95568
+ case 194 /* IndexedAccessType */:
95569
+ case 195 /* MappedType */:
95570
+ case 182 /* TypeLiteral */:
95571
+ case 130 /* AnyKeyword */:
95572
+ case 155 /* UnknownKeyword */:
95573
+ case 192 /* ThisType */:
95574
+ case 200 /* ImportType */:
95575
+ break;
95576
+ // handle JSDoc types from an invalid parse
95577
+ case 312 /* JSDocAllType */:
95578
+ case 313 /* JSDocUnknownType */:
95579
+ case 317 /* JSDocFunctionType */:
95580
+ case 318 /* JSDocVariadicType */:
95581
+ case 319 /* JSDocNamepathType */:
95582
+ break;
95583
+ case 314 /* JSDocNullableType */:
95584
+ case 315 /* JSDocNonNullableType */:
95585
+ case 316 /* JSDocOptionalType */:
95586
+ return serializeTypeNode(node.type);
95587
+ default:
95588
+ return ts.Debug.failBadSyntaxKind(node);
95589
+ }
95590
+ return ts.factory.createIdentifier("Object");
95591
+ }
95592
+ function serializeLiteralOfLiteralTypeNode(node) {
95593
+ switch (node.kind) {
95594
+ case 10 /* StringLiteral */:
95595
+ case 14 /* NoSubstitutionTemplateLiteral */:
95596
+ return ts.factory.createIdentifier("String");
95597
+ case 219 /* PrefixUnaryExpression */: {
95598
+ var operand = node.operand;
95599
+ switch (operand.kind) {
95600
+ case 8 /* NumericLiteral */:
95601
+ case 9 /* BigIntLiteral */:
95602
+ return serializeLiteralOfLiteralTypeNode(operand);
95603
+ default:
95604
+ return ts.Debug.failBadSyntaxKind(operand);
95605
+ }
95606
+ }
95607
+ case 8 /* NumericLiteral */:
95608
+ return ts.factory.createIdentifier("Number");
95609
+ case 9 /* BigIntLiteral */:
95610
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95611
+ case 110 /* TrueKeyword */:
95612
+ case 95 /* FalseKeyword */:
95613
+ return ts.factory.createIdentifier("Boolean");
95614
+ case 104 /* NullKeyword */:
95615
+ return ts.factory.createVoidZero();
95616
+ default:
95617
+ return ts.Debug.failBadSyntaxKind(node);
95618
+ }
95619
+ }
95620
+ function serializeUnionOrIntersectionConstituents(types, isIntersection) {
95621
+ // Note when updating logic here also update `getEntityNameForDecoratorMetadata` in checker.ts so that aliases can be marked as referenced
95622
+ var serializedType;
95623
+ for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
95624
+ var typeNode = types_22[_i];
95625
+ typeNode = ts.skipTypeParentheses(typeNode);
95626
+ if (typeNode.kind === 143 /* NeverKeyword */) {
95627
+ if (isIntersection)
95628
+ return ts.factory.createVoidZero(); // Reduce to `never` in an intersection
95629
+ continue; // Elide `never` in a union
95630
+ }
95631
+ if (typeNode.kind === 155 /* UnknownKeyword */) {
95632
+ if (!isIntersection)
95633
+ return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union
95634
+ continue; // Elide `unknown` in an intersection
95635
+ }
95636
+ if (typeNode.kind === 130 /* AnyKeyword */) {
95637
+ return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection
95638
+ }
95639
+ if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) {
95640
+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
95641
+ }
95642
+ var serializedConstituent = serializeTypeNode(typeNode);
95643
+ if (ts.isIdentifier(serializedConstituent) && serializedConstituent.escapedText === "Object") {
95644
+ // One of the individual is global object, return immediately
95645
+ return serializedConstituent;
95646
+ }
95647
+ // If there exists union that is not `void 0` expression, check if the the common type is identifier.
95648
+ // anything more complex and we will just default to Object
95649
+ if (serializedType) {
95650
+ // Different types
95651
+ if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
95652
+ return ts.factory.createIdentifier("Object");
95653
+ }
95654
+ }
95655
+ else {
95656
+ // Initialize the union type
95657
+ serializedType = serializedConstituent;
95658
+ }
95659
+ }
95660
+ // If we were able to find common type, use it
95661
+ return serializedType !== null && serializedType !== void 0 ? serializedType : (ts.factory.createVoidZero()); // Fallback is only hit if all union constituents are null/undefined/never
95662
+ }
95663
+ function equateSerializedTypeNodes(left, right) {
95664
+ return (
95665
+ // temp vars used in fallback
95666
+ ts.isGeneratedIdentifier(left) ? ts.isGeneratedIdentifier(right) :
95667
+ // entity names
95668
+ ts.isIdentifier(left) ? ts.isIdentifier(right)
95669
+ && left.escapedText === right.escapedText :
95670
+ ts.isPropertyAccessExpression(left) ? ts.isPropertyAccessExpression(right)
95671
+ && equateSerializedTypeNodes(left.expression, right.expression)
95672
+ && equateSerializedTypeNodes(left.name, right.name) :
95673
+ // `void 0`
95674
+ ts.isVoidExpression(left) ? ts.isVoidExpression(right)
95675
+ && ts.isNumericLiteral(left.expression) && left.expression.text === "0"
95676
+ && ts.isNumericLiteral(right.expression) && right.expression.text === "0" :
95677
+ // `"undefined"` or `"function"` in `typeof` checks
95678
+ ts.isStringLiteral(left) ? ts.isStringLiteral(right)
95679
+ && left.text === right.text :
95680
+ // used in `typeof` checks for fallback
95681
+ ts.isTypeOfExpression(left) ? ts.isTypeOfExpression(right)
95682
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95683
+ // parens in `typeof` checks with temps
95684
+ ts.isParenthesizedExpression(left) ? ts.isParenthesizedExpression(right)
95685
+ && equateSerializedTypeNodes(left.expression, right.expression) :
95686
+ // conditionals used in fallback
95687
+ ts.isConditionalExpression(left) ? ts.isConditionalExpression(right)
95688
+ && equateSerializedTypeNodes(left.condition, right.condition)
95689
+ && equateSerializedTypeNodes(left.whenTrue, right.whenTrue)
95690
+ && equateSerializedTypeNodes(left.whenFalse, right.whenFalse) :
95691
+ // logical binary and assignments used in fallback
95692
+ ts.isBinaryExpression(left) ? ts.isBinaryExpression(right)
95693
+ && left.operatorToken.kind === right.operatorToken.kind
95694
+ && equateSerializedTypeNodes(left.left, right.left)
95695
+ && equateSerializedTypeNodes(left.right, right.right) :
95696
+ false);
95697
+ }
95698
+ /**
95699
+ * Serializes a TypeReferenceNode to an appropriate JS constructor value for use with decorator type metadata.
95700
+ * @param node The type reference node.
95701
+ */
95702
+ function serializeTypeReferenceNode(node) {
95703
+ var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope !== null && currentNameScope !== void 0 ? currentNameScope : currentLexicalScope);
95704
+ switch (kind) {
95705
+ case ts.TypeReferenceSerializationKind.Unknown:
95706
+ // From conditional type type reference that cannot be resolved is Similar to any or unknown
95707
+ if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
95708
+ return ts.factory.createIdentifier("Object");
95709
+ }
95710
+ var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
95711
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95712
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createAssignment(temp, serialized), "function"),
95713
+ /*questionToken*/ undefined, temp,
95714
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95715
+ case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
95716
+ return serializeEntityNameAsExpression(node.typeName);
95717
+ case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
95718
+ return ts.factory.createVoidZero();
95719
+ case ts.TypeReferenceSerializationKind.BigIntLikeType:
95720
+ return getGlobalConstructor("BigInt", 7 /* ES2020 */);
95721
+ case ts.TypeReferenceSerializationKind.BooleanType:
95722
+ return ts.factory.createIdentifier("Boolean");
95723
+ case ts.TypeReferenceSerializationKind.NumberLikeType:
95724
+ return ts.factory.createIdentifier("Number");
95725
+ case ts.TypeReferenceSerializationKind.StringLikeType:
95726
+ return ts.factory.createIdentifier("String");
95727
+ case ts.TypeReferenceSerializationKind.ArrayLikeType:
95728
+ return ts.factory.createIdentifier("Array");
95729
+ case ts.TypeReferenceSerializationKind.ESSymbolType:
95730
+ return getGlobalConstructor("Symbol", 2 /* ES2015 */);
95731
+ case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
95732
+ return ts.factory.createIdentifier("Function");
95733
+ case ts.TypeReferenceSerializationKind.Promise:
95734
+ return ts.factory.createIdentifier("Promise");
95735
+ case ts.TypeReferenceSerializationKind.ObjectType:
95736
+ return ts.factory.createIdentifier("Object");
95737
+ default:
95738
+ return ts.Debug.assertNever(kind);
95739
+ }
95740
+ }
95741
+ /**
95742
+ * Produces an expression that results in `right` if `left` is not undefined at runtime:
95743
+ *
95744
+ * ```
95745
+ * typeof left !== "undefined" && right
95746
+ * ```
95747
+ *
95748
+ * We use `typeof L !== "undefined"` (rather than `L !== undefined`) since `L` may not be declared.
95749
+ * It's acceptable for this expression to result in `false` at runtime, as the result is intended to be
95750
+ * further checked by any containing expression.
95751
+ */
95752
+ function createCheckedValue(left, right) {
95753
+ return ts.factory.createLogicalAnd(ts.factory.createStrictInequality(ts.factory.createTypeOfExpression(left), ts.factory.createStringLiteral("undefined")), right);
95754
+ }
95755
+ /**
95756
+ * Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
95757
+ * @param node The entity name to serialize.
95758
+ */
95759
+ function serializeEntityNameAsExpressionFallback(node) {
95760
+ if (node.kind === 79 /* Identifier */) {
95761
+ // A -> typeof A !== "undefined" && A
95762
+ var copied = serializeEntityNameAsExpression(node);
95763
+ return createCheckedValue(copied, copied);
95764
+ }
95765
+ if (node.left.kind === 79 /* Identifier */) {
95766
+ // A.B -> typeof A !== "undefined" && A.B
95767
+ return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
95768
+ }
95769
+ // A.B.C -> typeof A !== "undefined" && (_a = A.B) !== void 0 && _a.C
95770
+ var left = serializeEntityNameAsExpressionFallback(node.left);
95771
+ var temp = ts.factory.createTempVariable(hoistVariableDeclaration);
95772
+ 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));
95773
+ }
95774
+ /**
95775
+ * Serializes an entity name as an expression for decorator type metadata.
95776
+ * @param node The entity name to serialize.
95777
+ */
95778
+ function serializeEntityNameAsExpression(node) {
95779
+ switch (node.kind) {
95780
+ case 79 /* Identifier */:
95781
+ // Create a clone of the name with a new parent, and treat it as if it were
95782
+ // a source tree node for the purposes of the checker.
95783
+ var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
95784
+ name.original = undefined;
95785
+ ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
95786
+ return name;
95787
+ case 161 /* QualifiedName */:
95788
+ return serializeQualifiedNameAsExpression(node);
95789
+ }
95790
+ }
95791
+ /**
95792
+ * Serializes an qualified name as an expression for decorator type metadata.
95793
+ * @param node The qualified name to serialize.
95794
+ */
95795
+ function serializeQualifiedNameAsExpression(node) {
95796
+ return ts.factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
95797
+ }
95798
+ function getGlobalConstructorWithFallback(name) {
95799
+ return ts.factory.createConditionalExpression(ts.factory.createTypeCheck(ts.factory.createIdentifier(name), "function"),
95800
+ /*questionToken*/ undefined, ts.factory.createIdentifier(name),
95801
+ /*colonToken*/ undefined, ts.factory.createIdentifier("Object"));
95802
+ }
95803
+ function getGlobalConstructor(name, minLanguageVersion) {
95804
+ return languageVersion < minLanguageVersion ?
95805
+ getGlobalConstructorWithFallback(name) :
95806
+ ts.factory.createIdentifier(name);
95807
+ }
95808
+ }
95809
+ ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;
95810
+ })(ts || (ts = {}));
95811
+ /*@internal*/
95812
+ var ts;
95813
+ (function (ts) {
95814
+ function transformLegacyDecorators(context) {
95815
+ var factory = context.factory, emitHelpers = context.getEmitHelperFactory, hoistVariableDeclaration = context.hoistVariableDeclaration;
95816
+ var resolver = context.getEmitResolver();
95817
+ var compilerOptions = context.getCompilerOptions();
95818
+ var languageVersion = ts.getEmitScriptTarget(compilerOptions);
95819
+ // Save the previous transformation hooks.
95820
+ var previousOnSubstituteNode = context.onSubstituteNode;
95821
+ // Set new transformation hooks.
95822
+ context.onSubstituteNode = onSubstituteNode;
95823
+ /**
95824
+ * A map that keeps track of aliases created for classes with decorators to avoid issues
95825
+ * with the double-binding behavior of classes.
95826
+ */
95827
+ var classAliases;
95828
+ return ts.chainBundle(context, transformSourceFile);
95829
+ function transformSourceFile(node) {
95830
+ var visited = ts.visitEachChild(node, visitor, context);
95831
+ ts.addEmitHelpers(visited, context.readEmitHelpers());
95832
+ return visited;
95833
+ }
95834
+ function visitor(node) {
95835
+ if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) {
95836
+ return node;
95837
+ }
95838
+ switch (node.kind) {
95839
+ case 165 /* Decorator */:
95840
+ // Decorators are elided. They will be emitted as part of `visitClassDeclaration`.
95841
+ return undefined;
95842
+ case 257 /* ClassDeclaration */:
95843
+ return visitClassDeclaration(node);
95844
+ case 226 /* ClassExpression */:
95845
+ return visitClassExpression(node);
95846
+ case 171 /* Constructor */:
95847
+ return visitConstructorDeclaration(node);
95848
+ case 169 /* MethodDeclaration */:
95849
+ return visitMethodDeclaration(node);
95850
+ case 173 /* SetAccessor */:
95851
+ return visitSetAccessorDeclaration(node);
95852
+ case 172 /* GetAccessor */:
95853
+ return visitGetAccessorDeclaration(node);
95854
+ case 170 /* ClassStaticBlockDeclaration */:
95855
+ return visitClassStaticBlockDeclaration(node);
95856
+ case 167 /* PropertyDeclaration */:
95857
+ return visitPropertyDeclaration(node);
95858
+ case 164 /* Parameter */:
95859
+ return visitParameterDeclaration(node);
95860
+ default:
95861
+ return ts.visitEachChild(node, visitor, context);
95862
+ }
95863
+ }
95864
+ function visitClassDeclaration(node) {
95865
+ if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node)))
95866
+ return ts.visitEachChild(node, visitor, context);
95867
+ var classStatement = ts.some(node.decorators) ?
95868
+ createClassDeclarationHeadWithDecorators(node, node.name) :
95869
+ createClassDeclarationHeadWithoutDecorators(node, node.name);
95870
+ var statements = [classStatement];
95871
+ // Write any decorators of the node.
95872
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
95873
+ addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
95874
+ addConstructorDecorationStatement(statements, node);
95875
+ if (statements.length > 1) {
95876
+ // Add a DeclarationMarker as a marker for the end of the declaration
95877
+ statements.push(factory.createEndOfDeclarationMarker(node));
95878
+ ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */);
95879
+ }
95880
+ return ts.singleOrMany(statements);
95881
+ }
95882
+ /**
95883
+ * Transforms a non-decorated class declaration.
95884
+ *
95885
+ * @param node A ClassDeclaration node.
95886
+ * @param name The name of the class.
95887
+ */
95888
+ function createClassDeclarationHeadWithoutDecorators(node, name) {
95889
+ // ${modifiers} class ${name} ${heritageClauses} {
95890
+ // ${members}
95891
+ // }
95892
+ return factory.updateClassDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, name,
95893
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
95894
+ }
95895
+ /**
95896
+ * Transforms a decorated class declaration and appends the resulting statements. If
95897
+ * the class requires an alias to avoid issues with double-binding, the alias is returned.
95898
+ */
95899
+ function createClassDeclarationHeadWithDecorators(node, name) {
95900
+ // When we emit an ES6 class that has a class decorator, we must tailor the
95901
+ // emit to certain specific cases.
95902
+ //
95903
+ // In the simplest case, we emit the class declaration as a let declaration, and
95904
+ // evaluate decorators after the close of the class body:
95905
+ //
95906
+ // [Example 1]
95907
+ // ---------------------------------------------------------------------
95908
+ // TypeScript | Javascript
95909
+ // ---------------------------------------------------------------------
95910
+ // @dec | let C = class C {
95911
+ // class C { | }
95912
+ // } | C = __decorate([dec], C);
95913
+ // ---------------------------------------------------------------------
95914
+ // @dec | let C = class C {
95915
+ // export class C { | }
95916
+ // } | C = __decorate([dec], C);
95917
+ // | export { C };
95918
+ // ---------------------------------------------------------------------
95919
+ //
95920
+ // If a class declaration contains a reference to itself *inside* of the class body,
95921
+ // this introduces two bindings to the class: One outside of the class body, and one
95922
+ // inside of the class body. If we apply decorators as in [Example 1] above, there
95923
+ // is the possibility that the decorator `dec` will return a new value for the
95924
+ // constructor, which would result in the binding inside of the class no longer
95925
+ // pointing to the same reference as the binding outside of the class.
95926
+ //
95927
+ // As a result, we must instead rewrite all references to the class *inside* of the
95928
+ // class body to instead point to a local temporary alias for the class:
95929
+ //
95930
+ // [Example 2]
95931
+ // ---------------------------------------------------------------------
95932
+ // TypeScript | Javascript
95933
+ // ---------------------------------------------------------------------
95934
+ // @dec | let C = C_1 = class C {
95935
+ // class C { | static x() { return C_1.y; }
95936
+ // static x() { return C.y; } | }
95937
+ // static y = 1; | C.y = 1;
95938
+ // } | C = C_1 = __decorate([dec], C);
95939
+ // | var C_1;
95940
+ // ---------------------------------------------------------------------
95941
+ // @dec | let C = class C {
95942
+ // export class C { | static x() { return C_1.y; }
95943
+ // static x() { return C.y; } | }
95944
+ // static y = 1; | C.y = 1;
95945
+ // } | C = C_1 = __decorate([dec], C);
95946
+ // | export { C };
95947
+ // | var C_1;
95948
+ // ---------------------------------------------------------------------
95949
+ //
95950
+ // If a class declaration is the default export of a module, we instead emit
95951
+ // the export after the decorated declaration:
95952
+ //
95953
+ // [Example 3]
95954
+ // ---------------------------------------------------------------------
95955
+ // TypeScript | Javascript
95956
+ // ---------------------------------------------------------------------
95957
+ // @dec | let default_1 = class {
95958
+ // export default class { | }
95959
+ // } | default_1 = __decorate([dec], default_1);
95960
+ // | export default default_1;
95961
+ // ---------------------------------------------------------------------
95962
+ // @dec | let C = class C {
95963
+ // export default class C { | }
95964
+ // } | C = __decorate([dec], C);
95965
+ // | export default C;
95966
+ // ---------------------------------------------------------------------
95967
+ //
95968
+ // If the class declaration is the default export and a reference to itself
95969
+ // inside of the class body, we must emit both an alias for the class *and*
95970
+ // move the export after the declaration:
95971
+ //
95972
+ // [Example 4]
95973
+ // ---------------------------------------------------------------------
95974
+ // TypeScript | Javascript
95975
+ // ---------------------------------------------------------------------
95976
+ // @dec | let C = class C {
95977
+ // export default class C { | static x() { return C_1.y; }
95978
+ // static x() { return C.y; } | }
95979
+ // static y = 1; | C.y = 1;
95980
+ // } | C = C_1 = __decorate([dec], C);
95981
+ // | export default C;
95982
+ // | var C_1;
95983
+ // ---------------------------------------------------------------------
95984
+ //
95985
+ var location = ts.moveRangePastModifiers(node);
95986
+ var classAlias = getClassAliasIfNeeded(node);
95987
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
95988
+ // without any block-scoped variable collision handling
95989
+ var declName = languageVersion <= 2 /* ES2015 */ ?
95990
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
95991
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
95992
+ // ... = class ${name} ${heritageClauses} {
95993
+ // ${members}
95994
+ // }
95995
+ var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
95996
+ var members = ts.visitNodes(node.members, visitor, ts.isClassElement);
95997
+ var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
95998
+ ts.setOriginalNode(classExpression, node);
95999
+ ts.setTextRange(classExpression, location);
96000
+ // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
96001
+ // or decoratedClassAlias if the class contain self-reference.
96002
+ var statement = factory.createVariableStatement(
96003
+ /*modifiers*/ undefined, factory.createVariableDeclarationList([
96004
+ factory.createVariableDeclaration(declName,
96005
+ /*exclamationToken*/ undefined,
96006
+ /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
96007
+ ], 1 /* Let */));
96008
+ ts.setOriginalNode(statement, node);
96009
+ ts.setTextRange(statement, location);
96010
+ ts.setCommentRange(statement, node);
96011
+ return statement;
96012
+ }
96013
+ function visitClassExpression(node) {
96014
+ // Legacy decorators were not supported on class expressions
96015
+ return factory.updateClassExpression(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.name,
96016
+ /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement));
96017
+ }
96018
+ function visitConstructorDeclaration(node) {
96019
+ return factory.updateConstructorDeclaration(node,
96020
+ /*decorators*/ undefined, node.modifiers, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock));
96021
+ }
96022
+ function finishClassElement(updated, original) {
96023
+ if (updated !== original) {
96024
+ // While we emit the source map for the node after skipping decorators and modifiers,
96025
+ // we need to emit the comments for the original range.
96026
+ ts.setCommentRange(updated, original);
96027
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(original));
96028
+ }
96029
+ return updated;
96030
+ }
96031
+ function visitMethodDeclaration(node) {
96032
+ return finishClassElement(factory.updateMethodDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName),
96033
+ /*questionToken*/ undefined,
96034
+ /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration),
96035
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96036
+ }
96037
+ function visitGetAccessorDeclaration(node) {
96038
+ 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),
96039
+ /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock)), node);
96040
+ }
96041
+ function visitSetAccessorDeclaration(node) {
96042
+ 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);
96043
+ }
96044
+ function visitClassStaticBlockDeclaration(node) {
96045
+ return factory.updateClassStaticBlockDeclaration(node,
96046
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.body, visitor, ts.isBlock));
96047
+ }
96048
+ function visitPropertyDeclaration(node) {
96049
+ if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) {
96050
+ return undefined;
96051
+ }
96052
+ return finishClassElement(factory.updatePropertyDeclaration(node, ts.elideNodes(factory, node.decorators), node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName),
96053
+ /*questionOrExclamationToken*/ undefined,
96054
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
96055
+ }
96056
+ function visitParameterDeclaration(node) {
96057
+ var updated = factory.updateParameterDeclaration(node, ts.elideNodes(factory, node.decorators),
96058
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.visitNode(node.name, visitor, ts.isBindingName),
96059
+ /*questionToken*/ undefined,
96060
+ /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
96061
+ if (updated !== node) {
96062
+ // While we emit the source map for the node after skipping decorators and modifiers,
96063
+ // we need to emit the comments for the original range.
96064
+ ts.setCommentRange(updated, node);
96065
+ ts.setTextRange(updated, ts.moveRangePastModifiers(node));
96066
+ ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
96067
+ ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */);
96068
+ }
96069
+ return updated;
96070
+ }
96071
+ /**
96072
+ * Transforms all of the decorators for a declaration into an array of expressions.
96073
+ *
96074
+ * @param allDecorators An object containing all of the decorators for the declaration.
96075
+ */
96076
+ function transformAllDecoratorsOfDeclaration(allDecorators) {
96077
+ if (!allDecorators) {
96078
+ return undefined;
96079
+ }
96080
+ var decoratorExpressions = [];
96081
+ ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
96082
+ ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
96083
+ return decoratorExpressions;
96084
+ }
96085
+ /**
96086
+ * Generates statements used to apply decorators to either the static or instance members
96087
+ * of a class.
96088
+ *
96089
+ * @param node The class node.
96090
+ * @param isStatic A value indicating whether to generate statements for static or
96091
+ * instance members.
96092
+ */
96093
+ function addClassElementDecorationStatements(statements, node, isStatic) {
96094
+ ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), function (expr) { return factory.createExpressionStatement(expr); }));
96095
+ }
96096
+ /**
96097
+ * Determines whether a class member is either a static or an instance member of a class
96098
+ * that is decorated, or has parameters that are decorated.
96099
+ *
96100
+ * @param member The class member.
96101
+ */
96102
+ function isDecoratedClassElement(member, isStaticElement, parent) {
96103
+ return ts.nodeOrChildIsDecorated(member, parent)
96104
+ && isStaticElement === ts.isStatic(member);
96105
+ }
96106
+ /**
96107
+ * Gets either the static or instance members of a class that are decorated, or have
96108
+ * parameters that are decorated.
96109
+ *
96110
+ * @param node The class containing the member.
96111
+ * @param isStatic A value indicating whether to retrieve static or instance members of
96112
+ * the class.
96113
+ */
96114
+ function getDecoratedClassElements(node, isStatic) {
96115
+ return ts.filter(node.members, function (m) { return isDecoratedClassElement(m, isStatic, node); });
96116
+ }
96117
+ /**
96118
+ * Generates expressions used to apply decorators to either the static or instance members
96119
+ * of a class.
96120
+ *
96121
+ * @param node The class node.
96122
+ * @param isStatic A value indicating whether to generate expressions for static or
96123
+ * instance members.
96124
+ */
96125
+ function generateClassElementDecorationExpressions(node, isStatic) {
96126
+ var members = getDecoratedClassElements(node, isStatic);
96127
+ var expressions;
96128
+ for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
96129
+ var member = members_8[_i];
96130
+ expressions = ts.append(expressions, generateClassElementDecorationExpression(node, member));
96131
+ }
96132
+ return expressions;
96133
+ }
96134
+ /**
96135
+ * Generates an expression used to evaluate class element decorators at runtime.
96136
+ *
96137
+ * @param node The class node that contains the member.
96138
+ * @param member The class member.
96139
+ */
96140
+ function generateClassElementDecorationExpression(node, member) {
96141
+ var allDecorators = ts.getAllDecoratorsOfClassElement(member, node);
96142
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96143
+ if (!decoratorExpressions) {
96144
+ return undefined;
96145
+ }
96146
+ // Emit the call to __decorate. Given the following:
96147
+ //
96148
+ // class C {
96149
+ // @dec method(@dec2 x) {}
96150
+ // @dec get accessor() {}
96151
+ // @dec prop;
96152
+ // }
96153
+ //
96154
+ // The emit for a method is:
96155
+ //
96156
+ // __decorate([
96157
+ // dec,
96158
+ // __param(0, dec2),
96159
+ // __metadata("design:type", Function),
96160
+ // __metadata("design:paramtypes", [Object]),
96161
+ // __metadata("design:returntype", void 0)
96162
+ // ], C.prototype, "method", null);
96163
+ //
96164
+ // The emit for an accessor is:
96165
+ //
96166
+ // __decorate([
96167
+ // dec
96168
+ // ], C.prototype, "accessor", null);
96169
+ //
96170
+ // The emit for a property is:
96171
+ //
96172
+ // __decorate([
96173
+ // dec
96174
+ // ], C.prototype, "prop");
96175
+ //
96176
+ var prefix = getClassMemberPrefix(node, member);
96177
+ var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
96178
+ var descriptor = languageVersion > 0 /* ES3 */
96179
+ ? member.kind === 167 /* PropertyDeclaration */
96180
+ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
96181
+ // should not invoke `Object.getOwnPropertyDescriptor`.
96182
+ ? factory.createVoidZero()
96183
+ // We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
96184
+ // We have this extra argument here so that we can inject an explicit property descriptor at a later date.
96185
+ : factory.createNull()
96186
+ : undefined;
96187
+ var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
96188
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96189
+ ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member));
96190
+ return helper;
96191
+ }
96192
+ /**
96193
+ * Generates a __decorate helper call for a class constructor.
96194
+ *
96195
+ * @param node The class node.
96196
+ */
96197
+ function addConstructorDecorationStatement(statements, node) {
96198
+ var expression = generateConstructorDecorationExpression(node);
96199
+ if (expression) {
96200
+ statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
96201
+ }
96202
+ }
96203
+ /**
96204
+ * Generates a __decorate helper call for a class constructor.
96205
+ *
96206
+ * @param node The class node.
96207
+ */
96208
+ function generateConstructorDecorationExpression(node) {
96209
+ var allDecorators = ts.getAllDecoratorsOfClass(node);
96210
+ var decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
96211
+ if (!decoratorExpressions) {
96212
+ return undefined;
96213
+ }
96214
+ var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
96215
+ // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
96216
+ // without any block-scoped variable collision handling
96217
+ var localName = languageVersion <= 2 /* ES2015 */ ?
96218
+ factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
96219
+ factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
96220
+ var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
96221
+ var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
96222
+ ts.setEmitFlags(expression, 1536 /* NoComments */);
96223
+ ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node));
96224
+ return expression;
96225
+ }
96226
+ /**
96227
+ * Transforms a decorator into an expression.
96228
+ *
96229
+ * @param decorator The decorator node.
96230
+ */
96231
+ function transformDecorator(decorator) {
96232
+ return ts.visitNode(decorator.expression, visitor, ts.isExpression);
96233
+ }
96234
+ /**
96235
+ * Transforms the decorators of a parameter.
96236
+ *
96237
+ * @param decorators The decorators for the parameter at the provided offset.
96238
+ * @param parameterOffset The offset of the parameter.
96239
+ */
96240
+ function transformDecoratorsOfParameter(decorators, parameterOffset) {
96241
+ var expressions;
96242
+ if (decorators) {
96243
+ expressions = [];
96244
+ for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
96245
+ var decorator = decorators_1[_i];
96246
+ var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
96247
+ ts.setTextRange(helper, decorator.expression);
96248
+ ts.setEmitFlags(helper, 1536 /* NoComments */);
96249
+ expressions.push(helper);
96250
+ }
96251
+ }
96252
+ return expressions;
96253
+ }
96254
+ /**
96255
+ * Gets an expression that represents a property name (for decorated properties or enums).
96256
+ * For a computed property, a name is generated for the node.
96257
+ *
96258
+ * @param member The member whose name should be converted into an expression.
96259
+ */
96260
+ function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
96261
+ var name = member.name;
96262
+ if (ts.isPrivateIdentifier(name)) {
96263
+ return factory.createIdentifier("");
96264
+ }
96265
+ else if (ts.isComputedPropertyName(name)) {
96266
+ return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
96267
+ ? factory.getGeneratedNameForNode(name)
96268
+ : name.expression;
96269
+ }
96270
+ else if (ts.isIdentifier(name)) {
96271
+ return factory.createStringLiteral(ts.idText(name));
96272
+ }
96273
+ else {
96274
+ return factory.cloneNode(name);
96275
+ }
96276
+ }
96277
+ function enableSubstitutionForClassAliases() {
96278
+ if (!classAliases) {
96279
+ // We need to enable substitutions for identifiers. This allows us to
96280
+ // substitute class names inside of a class declaration.
96281
+ context.enableSubstitution(79 /* Identifier */);
96282
+ // Keep track of class aliases.
96283
+ classAliases = [];
96284
+ }
96285
+ }
96286
+ /**
96287
+ * Gets a local alias for a class declaration if it is a decorated class with an internal
96288
+ * reference to the static side of the class. This is necessary to avoid issues with
96289
+ * double-binding semantics for the class name.
96290
+ */
96291
+ function getClassAliasIfNeeded(node) {
96292
+ if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
96293
+ enableSubstitutionForClassAliases();
96294
+ var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
96295
+ classAliases[ts.getOriginalNodeId(node)] = classAlias;
96296
+ hoistVariableDeclaration(classAlias);
96297
+ return classAlias;
96298
+ }
96299
+ }
96300
+ function getClassPrototype(node) {
96301
+ return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
96302
+ }
96303
+ function getClassMemberPrefix(node, member) {
96304
+ return ts.isStatic(member)
96305
+ ? factory.getDeclarationName(node)
96306
+ : getClassPrototype(node);
96307
+ }
96308
+ /**
96309
+ * Hooks node substitutions.
96310
+ *
96311
+ * @param hint A hint as to the intended usage of the node.
96312
+ * @param node The node to substitute.
96313
+ */
96314
+ function onSubstituteNode(hint, node) {
96315
+ node = previousOnSubstituteNode(hint, node);
96316
+ if (hint === 1 /* Expression */) {
96317
+ return substituteExpression(node);
96318
+ }
96319
+ return node;
96320
+ }
96321
+ function substituteExpression(node) {
96322
+ switch (node.kind) {
96323
+ case 79 /* Identifier */:
96324
+ return substituteExpressionIdentifier(node);
96325
+ }
96326
+ return node;
96327
+ }
96328
+ function substituteExpressionIdentifier(node) {
96329
+ var _a;
96330
+ return (_a = trySubstituteClassAlias(node)) !== null && _a !== void 0 ? _a : node;
96331
+ }
96332
+ function trySubstituteClassAlias(node) {
96333
+ if (classAliases) {
96334
+ if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
96335
+ // Due to the emit for class decorators, any reference to the class from inside of the class body
96336
+ // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
96337
+ // behavior of class names in ES6.
96338
+ // Also, when emitting statics for class expressions, we must substitute a class alias for
96339
+ // constructor references in static property initializers.
96340
+ var declaration = resolver.getReferencedValueDeclaration(node);
96341
+ if (declaration) {
96342
+ var classAlias = classAliases[declaration.id]; // TODO: GH#18217
96343
+ if (classAlias) {
96344
+ var clone_3 = factory.cloneNode(classAlias);
96345
+ ts.setSourceMapRange(clone_3, node);
96346
+ ts.setCommentRange(clone_3, node);
96347
+ return clone_3;
96348
+ }
96349
+ }
96350
+ }
96351
+ }
96352
+ return undefined;
96353
+ }
96354
+ }
96355
+ ts.transformLegacyDecorators = transformLegacyDecorators;
96356
+ })(ts || (ts = {}));
96357
+ /*@internal*/
96358
+ var ts;
95922
96359
  (function (ts) {
95923
96360
  var ES2017SubstitutionFlags;
95924
96361
  (function (ES2017SubstitutionFlags) {
@@ -96767,7 +97204,7 @@ var ts;
96767
97204
  return objects;
96768
97205
  }
96769
97206
  function visitObjectLiteralExpression(node) {
96770
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97207
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96771
97208
  // spread elements emit like so:
96772
97209
  // non-spread elements are chunked together into object literals, and then all are passed to __assign:
96773
97210
  // { a, ...o, b } => __assign(__assign({a}, o), {b});
@@ -96840,7 +97277,7 @@ var ts;
96840
97277
  * expression of an `ExpressionStatement`).
96841
97278
  */
96842
97279
  function visitBinaryExpression(node, expressionResultIsUnused) {
96843
- if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97280
+ if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96844
97281
  return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
96845
97282
  }
96846
97283
  if (node.operatorToken.kind === 27 /* CommaToken */) {
@@ -96871,7 +97308,7 @@ var ts;
96871
97308
  function visitCatchClause(node) {
96872
97309
  if (node.variableDeclaration &&
96873
97310
  ts.isBindingPattern(node.variableDeclaration.name) &&
96874
- node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97311
+ node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96875
97312
  var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
96876
97313
  var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
96877
97314
  var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
@@ -96912,7 +97349,7 @@ var ts;
96912
97349
  }
96913
97350
  function visitVariableDeclarationWorker(node, exportedVariableStatement) {
96914
97351
  // If we are here it is because the name contains a binding pattern with a rest somewhere in it.
96915
- if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97352
+ if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96916
97353
  return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
96917
97354
  /*rval*/ undefined, exportedVariableStatement);
96918
97355
  }
@@ -96931,7 +97368,7 @@ var ts;
96931
97368
  */
96932
97369
  function visitForOfStatement(node, outermostLabeledStatement) {
96933
97370
  var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
96934
- if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97371
+ if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
96935
97372
  node = transformForOfStatementWithObjectRest(node);
96936
97373
  }
96937
97374
  var result = node.awaitModifier ?
@@ -97044,7 +97481,7 @@ var ts;
97044
97481
  /*type*/ undefined,
97045
97482
  /*initializer*/ undefined);
97046
97483
  }
97047
- if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97484
+ if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97048
97485
  // Binding patterns are converted into a generated name and are
97049
97486
  // evaluated inside the function body.
97050
97487
  return factory.updateParameterDeclaration(node,
@@ -97062,7 +97499,7 @@ var ts;
97062
97499
  if (parameters) {
97063
97500
  parameters.add(parameter);
97064
97501
  }
97065
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97502
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97066
97503
  parameters = new ts.Set();
97067
97504
  }
97068
97505
  }
@@ -97285,7 +97722,7 @@ var ts;
97285
97722
  statements = ts.append(statements, statement);
97286
97723
  }
97287
97724
  }
97288
- else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
97725
+ else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
97289
97726
  containsPrecedingObjectRestOrSpread = true;
97290
97727
  var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
97291
97728
  /*doNotRecordTempVariablesInLine*/ false,
@@ -98657,7 +99094,7 @@ var ts;
98657
99094
  && !node.expression;
98658
99095
  }
98659
99096
  function isOrMayContainReturnCompletion(node) {
98660
- return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */
99097
+ return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
98661
99098
  && (ts.isReturnStatement(node)
98662
99099
  || ts.isIfStatement(node)
98663
99100
  || ts.isWithStatement(node)
@@ -99221,7 +99658,7 @@ var ts;
99221
99658
  factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
99222
99659
  insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
99223
99660
  if (isDerivedClass || superCallExpression) {
99224
- if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
99661
+ if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
99225
99662
  // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
99226
99663
  // following representation:
99227
99664
  //
@@ -99766,7 +100203,7 @@ var ts;
99766
100203
  * @param node An ArrowFunction node.
99767
100204
  */
99768
100205
  function visitArrowFunction(node) {
99769
- if (node.transformFlags & 8192 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
100206
+ if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
99770
100207
  hierarchyFacts |= 65536 /* CapturedLexicalThis */;
99771
100208
  }
99772
100209
  var savedConvertedLoopState = convertedLoopState;
@@ -100052,7 +100489,7 @@ var ts;
100052
100489
  * @param node A VariableDeclarationList node.
100053
100490
  */
100054
100491
  function visitVariableDeclarationList(node) {
100055
- if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) {
100492
+ if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
100056
100493
  if (node.flags & 3 /* BlockScoped */) {
100057
100494
  enableSubstitutionsForBlockScopedBindings();
100058
100495
  }
@@ -100065,7 +100502,7 @@ var ts;
100065
100502
  ts.setCommentRange(declarationList, node);
100066
100503
  // If the first or last declaration is a binding pattern, we need to modify
100067
100504
  // the source map range for the declaration list.
100068
- if (node.transformFlags & 262144 /* ContainsBindingPattern */
100505
+ if (node.transformFlags & 524288 /* ContainsBindingPattern */
100069
100506
  && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
100070
100507
  ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
100071
100508
  }
@@ -100389,7 +100826,7 @@ var ts;
100389
100826
  var numInitialProperties = -1, hasComputed = false;
100390
100827
  for (var i = 0; i < properties.length; i++) {
100391
100828
  var property = properties[i];
100392
- if ((property.transformFlags & 524288 /* ContainsYield */ &&
100829
+ if ((property.transformFlags & 1048576 /* ContainsYield */ &&
100393
100830
  hierarchyFacts & 4 /* AsyncFunctionBody */)
100394
100831
  || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
100395
100832
  numInitialProperties = i;
@@ -100662,7 +101099,7 @@ var ts;
100662
101099
  */
100663
101100
  function createFunctionForInitializerOfForStatement(node, currentState) {
100664
101101
  var functionName = factory.createUniqueName("_loop_init");
100665
- var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0;
101102
+ var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
100666
101103
  var emitFlags = 0 /* None */;
100667
101104
  if (currentState.containsLexicalThis)
100668
101105
  emitFlags |= 8 /* CapturesThis */;
@@ -100777,7 +101214,7 @@ var ts;
100777
101214
  var loopBody = factory.createBlock(statements, /*multiLine*/ true);
100778
101215
  if (ts.isBlock(statement))
100779
101216
  ts.setOriginalNode(loopBody, statement);
100780
- var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0;
101217
+ var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
100781
101218
  var emitFlags = 524288 /* ReuseTempVariableScope */;
100782
101219
  if (currentState.containsLexicalThis)
100783
101220
  emitFlags |= 8 /* CapturesThis */;
@@ -101259,7 +101696,7 @@ var ts;
101259
101696
  function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
101260
101697
  // We are here either because SuperKeyword was used somewhere in the expression, or
101261
101698
  // because we contain a SpreadElementExpression.
101262
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */ ||
101699
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
101263
101700
  node.expression.kind === 106 /* SuperKeyword */ ||
101264
101701
  ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
101265
101702
  var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
@@ -101267,7 +101704,7 @@ var ts;
101267
101704
  ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
101268
101705
  }
101269
101706
  var resultingCall = void 0;
101270
- if (node.transformFlags & 16384 /* ContainsRestOrSpread */) {
101707
+ if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
101271
101708
  // [source]
101272
101709
  // f(...a, b)
101273
101710
  // x.m(...a, b)
@@ -102109,10 +102546,10 @@ var ts;
102109
102546
  case 247 /* ReturnStatement */:
102110
102547
  return visitReturnStatement(node);
102111
102548
  default:
102112
- if (node.transformFlags & 524288 /* ContainsYield */) {
102549
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102113
102550
  return visitJavaScriptContainingYield(node);
102114
102551
  }
102115
- else if (node.transformFlags & (2048 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) {
102552
+ else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
102116
102553
  return ts.visitEachChild(node, visitor, context);
102117
102554
  }
102118
102555
  else {
@@ -102317,7 +102754,7 @@ var ts;
102317
102754
  * @param node The node to visit.
102318
102755
  */
102319
102756
  function visitVariableStatement(node) {
102320
- if (node.transformFlags & 524288 /* ContainsYield */) {
102757
+ if (node.transformFlags & 1048576 /* ContainsYield */) {
102321
102758
  transformAndEmitVariableDeclarationList(node.declarationList);
102322
102759
  return undefined;
102323
102760
  }
@@ -103375,7 +103812,7 @@ var ts;
103375
103812
  }
103376
103813
  }
103377
103814
  function containsYield(node) {
103378
- return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0;
103815
+ return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
103379
103816
  }
103380
103817
  function countInitialNodesWithoutYield(nodes) {
103381
103818
  var numNodes = nodes.length;
@@ -104424,7 +104861,7 @@ var ts;
104424
104861
  function transformSourceFile(node) {
104425
104862
  if (node.isDeclarationFile ||
104426
104863
  !(ts.isEffectiveExternalModule(node, compilerOptions) ||
104427
- node.transformFlags & 4194304 /* ContainsDynamicImport */ ||
104864
+ node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
104428
104865
  (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
104429
104866
  return node;
104430
104867
  }
@@ -104761,7 +105198,7 @@ var ts;
104761
105198
  function visitorWorker(node, valueIsDiscarded) {
104762
105199
  // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
104763
105200
  // as export/import statements are only transformed at the top level of a file.
104764
- if (!(node.transformFlags & (4194304 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
105201
+ if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
104765
105202
  return node;
104766
105203
  }
104767
105204
  switch (node.kind) {
@@ -104912,7 +105349,7 @@ var ts;
104912
105349
  var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
104913
105350
  // 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.
104914
105351
  var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
104915
- var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */);
105352
+ var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
104916
105353
  switch (compilerOptions.module) {
104917
105354
  case ts.ModuleKind.AMD:
104918
105355
  return createImportCallExpressionAMD(argument, containsLexicalThis);
@@ -105899,7 +106336,7 @@ var ts;
105899
106336
  * @param node The SourceFile node.
105900
106337
  */
105901
106338
  function transformSourceFile(node) {
105902
- if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) {
106339
+ if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
105903
106340
  return node;
105904
106341
  }
105905
106342
  var id = ts.getOriginalNodeId(node);
@@ -106068,7 +106505,7 @@ var ts;
106068
106505
  // - Temporary variables will appear at the top rather than at the bottom of the file
106069
106506
  ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
106070
106507
  var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
106071
- var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ?
106508
+ var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
106072
106509
  factory.createModifiersFromModifierFlags(256 /* Async */) :
106073
106510
  undefined;
106074
106511
  var moduleObject = factory.createObjectLiteralExpression([
@@ -106977,7 +107414,7 @@ var ts;
106977
107414
  * @param node The node to visit.
106978
107415
  */
106979
107416
  function visitorWorker(node, valueIsDiscarded) {
106980
- if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 4194304 /* ContainsDynamicImport */ | 67108864 /* ContainsUpdateExpressionForIdentifier */))) {
107417
+ if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
106981
107418
  return node;
106982
107419
  }
106983
107420
  switch (node.kind) {
@@ -108145,7 +108582,8 @@ var ts;
108145
108582
  trackReferencedAmbientModule: trackReferencedAmbientModule,
108146
108583
  trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
108147
108584
  reportNonlocalAugmentation: reportNonlocalAugmentation,
108148
- reportNonSerializableProperty: reportNonSerializableProperty
108585
+ reportNonSerializableProperty: reportNonSerializableProperty,
108586
+ reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
108149
108587
  };
108150
108588
  var errorNameNode;
108151
108589
  var errorFallbackNode;
@@ -108272,6 +108710,11 @@ var ts;
108272
108710
  context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
108273
108711
  }
108274
108712
  }
108713
+ function reportImportTypeNodeResolutionModeOverride() {
108714
+ if (!ts.isNightly() && (errorNameNode || errorFallbackNode)) {
108715
+ 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));
108716
+ }
108717
+ }
108275
108718
  function transformDeclarationsForJS(sourceFile, bundled) {
108276
108719
  var oldDiag = getSymbolAccessibilityDiagnostic;
108277
108720
  getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
@@ -108722,7 +109165,7 @@ var ts;
108722
109165
  var mode = ts.getResolutionModeOverrideForClause(assertClause);
108723
109166
  if (mode !== undefined) {
108724
109167
  if (!ts.isNightly()) {
108725
- 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));
109168
+ 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));
108726
109169
  }
108727
109170
  return assertClause;
108728
109171
  }
@@ -109514,6 +109957,7 @@ var ts;
109514
109957
  var transformers = [];
109515
109958
  ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
109516
109959
  transformers.push(ts.transformTypeScript);
109960
+ transformers.push(ts.transformLegacyDecorators);
109517
109961
  transformers.push(ts.transformClassFields);
109518
109962
  if (ts.getJSXTransformEnabled(compilerOptions)) {
109519
109963
  transformers.push(ts.transformJsx);
@@ -116231,12 +116675,14 @@ var ts;
116231
116675
  }
116232
116676
  ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
116233
116677
  ;
116234
- /* @internal */
116678
+ /**
116679
+ * Calculates the resulting resolution mode for some reference in some file - this is generally the explicitly
116680
+ * provided resolution mode in the reference, unless one is not present, in which case it is the mode of the containing file.
116681
+ */
116235
116682
  function getModeForFileReference(ref, containingFileMode) {
116236
116683
  return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
116237
116684
  }
116238
116685
  ts.getModeForFileReference = getModeForFileReference;
116239
- /* @internal */
116240
116686
  function getModeForResolutionAtIndex(file, index) {
116241
116687
  if (file.impliedNodeFormat === undefined)
116242
116688
  return undefined;
@@ -116257,7 +116703,15 @@ var ts;
116257
116703
  return false;
116258
116704
  }
116259
116705
  ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
116260
- /* @internal */
116706
+ /**
116707
+ * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if
116708
+ * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm).
116709
+ * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when
116710
+ * `moduleResolution` is `node16`+.
116711
+ * @param file The file the import or import-like reference is contained within
116712
+ * @param usage The module reference string
116713
+ * @returns The final resolution mode of the import
116714
+ */
116261
116715
  function getModeForUsageLocation(file, usage) {
116262
116716
  var _a, _b;
116263
116717
  if (file.impliedNodeFormat === undefined)
@@ -118493,7 +118947,7 @@ var ts;
118493
118947
  ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
118494
118948
  var mode = ref.resolutionMode || file.impliedNodeFormat;
118495
118949
  if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
118496
- programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118950
+ programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
118497
118951
  }
118498
118952
  processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
118499
118953
  }
@@ -167408,7 +167862,7 @@ var ts;
167408
167862
  if (_this.safeList === undefined) {
167409
167863
  _this.safeList = ts.JsTyping.loadSafeList(_this.host, ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
167410
167864
  }
167411
- return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry);
167865
+ return ts.JsTyping.discoverTypings(_this.host, function (msg) { return _this.logger.log(msg); }, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), _this.safeList, info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports, info.typesRegistry, ts.emptyOptions);
167412
167866
  });
167413
167867
  };
167414
167868
  return CoreServicesShimObject;
@@ -167677,7 +168131,7 @@ var ts;
167677
168131
  * @param typeAcquisition is used to customize the typing acquisition process
167678
168132
  * @param compilerOptions are used as a source for typing inference
167679
168133
  */
167680
- function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
168134
+ function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
167681
168135
  if (!typeAcquisition || !typeAcquisition.enable) {
167682
168136
  return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
167683
168137
  }
@@ -167695,12 +168149,14 @@ var ts;
167695
168149
  addInferredTypings(typeAcquisition.include, "Explicitly included types");
167696
168150
  var exclude = typeAcquisition.exclude || [];
167697
168151
  // Directories to search for package.json, bower.json and other typing information
167698
- var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
167699
- possibleSearchDirs.add(projectRootPath);
167700
- possibleSearchDirs.forEach(function (searchDir) {
167701
- getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
167702
- getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
167703
- });
168152
+ if (!compilerOptions.types) {
168153
+ var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
168154
+ possibleSearchDirs.add(projectRootPath);
168155
+ possibleSearchDirs.forEach(function (searchDir) {
168156
+ getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
168157
+ getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
168158
+ });
168159
+ }
167704
168160
  if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
167705
168161
  getTypingNamesFromSourceFileNames(fileNames);
167706
168162
  }