typescript 4.8.0-dev.20220602 → 4.8.0-dev.20220605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +1013 -634
- package/lib/tsserver.js +1481 -1029
- package/lib/tsserverlibrary.d.ts +26 -0
- package/lib/tsserverlibrary.js +1481 -1029
- package/lib/typescript.d.ts +26 -0
- package/lib/typescript.js +1481 -1029
- package/lib/typescriptServices.d.ts +26 -0
- package/lib/typescriptServices.js +1481 -1029
- package/lib/typingsInstaller.js +1481 -1029
- package/package.json +1 -1
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.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220605";
|
|
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"] =
|
|
5576
|
-
TransformFlags[TransformFlags["ContainsLexicalThis"] =
|
|
5577
|
-
TransformFlags[TransformFlags["ContainsRestOrSpread"] =
|
|
5578
|
-
TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] =
|
|
5579
|
-
TransformFlags[TransformFlags["ContainsComputedPropertyName"] =
|
|
5580
|
-
TransformFlags[TransformFlags["ContainsBlockScopedBinding"] =
|
|
5581
|
-
TransformFlags[TransformFlags["ContainsBindingPattern"] =
|
|
5582
|
-
TransformFlags[TransformFlags["ContainsYield"] =
|
|
5583
|
-
TransformFlags[TransformFlags["ContainsAwait"] =
|
|
5584
|
-
TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] =
|
|
5585
|
-
TransformFlags[TransformFlags["ContainsDynamicImport"] =
|
|
5586
|
-
TransformFlags[TransformFlags["ContainsClassFields"] =
|
|
5587
|
-
TransformFlags[TransformFlags["
|
|
5588
|
-
TransformFlags[TransformFlags["
|
|
5589
|
-
TransformFlags[TransformFlags["
|
|
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"] =
|
|
5616
|
-
TransformFlags[TransformFlags["FunctionExcludes"] =
|
|
5617
|
-
TransformFlags[TransformFlags["ConstructorExcludes"] =
|
|
5618
|
-
TransformFlags[TransformFlags["MethodOrAccessorExcludes"] =
|
|
5619
|
-
TransformFlags[TransformFlags["PropertyExcludes"] =
|
|
5620
|
-
TransformFlags[TransformFlags["ClassExcludes"] =
|
|
5621
|
-
TransformFlags[TransformFlags["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"] =
|
|
5624
|
-
TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] =
|
|
5625
|
-
TransformFlags[TransformFlags["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"] =
|
|
5628
|
-
TransformFlags[TransformFlags["BindingPatternExcludes"] =
|
|
5629
|
-
TransformFlags[TransformFlags["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"] =
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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) & ~
|
|
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 |=
|
|
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 |=
|
|
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 */ |
|
|
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 =
|
|
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
|
-
|
|
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 |=
|
|
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
|
-
|
|
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
|
-
|
|
23146
|
+
16777216 /* ContainsClassFields */;
|
|
23135
23147
|
if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
|
|
23136
|
-
node.transformFlags |=
|
|
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) |
|
|
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
|
-
|
|
23744
|
-
if (node.transformFlags &
|
|
23755
|
+
524288 /* ContainsBindingPattern */;
|
|
23756
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
|
|
23745
23757
|
node.transformFlags |=
|
|
23746
23758
|
128 /* ContainsES2018 */ |
|
|
23747
|
-
|
|
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
|
-
|
|
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 |=
|
|
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 |=
|
|
23976
|
+
node.transformFlags |= 8388608 /* ContainsDynamicImport */;
|
|
23965
23977
|
}
|
|
23966
23978
|
else if (ts.isSuperProperty(node.expression)) {
|
|
23967
|
-
node.transformFlags |=
|
|
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 |=
|
|
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 */ |
|
|
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
|
-
|
|
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 |=
|
|
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 |=
|
|
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 &
|
|
24294
|
-
return
|
|
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 &
|
|
24303
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24949
|
+
4194304 /* ContainsHoistedDeclarationOrCompletion */;
|
|
24938
24950
|
if (flags & 3 /* BlockScoped */) {
|
|
24939
24951
|
node.transformFlags |=
|
|
24940
24952
|
1024 /* ContainsES2015 */ |
|
|
24941
|
-
|
|
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
|
-
|
|
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 &
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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 &= ~
|
|
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
|
-
|
|
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) & ~
|
|
27145
|
+
return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */;
|
|
27134
27146
|
}
|
|
27135
27147
|
function propagatePropertyNameFlagsOfChild(node, transformFlags) {
|
|
27136
|
-
return transformFlags | (node.transformFlags &
|
|
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
|
|
27179
|
+
return 536903680 /* ArrayLiteralOrCallOrNewExcludes */;
|
|
27168
27180
|
case 261 /* ModuleDeclaration */:
|
|
27169
|
-
return
|
|
27181
|
+
return 742678528 /* ModuleExcludes */;
|
|
27170
27182
|
case 164 /* Parameter */:
|
|
27171
27183
|
return 536870912 /* ParameterExcludes */;
|
|
27172
27184
|
case 214 /* ArrowFunction */:
|
|
27173
|
-
return
|
|
27185
|
+
return 612179968 /* ArrowFunctionExcludes */;
|
|
27174
27186
|
case 213 /* FunctionExpression */:
|
|
27175
27187
|
case 256 /* FunctionDeclaration */:
|
|
27176
|
-
return
|
|
27188
|
+
return 746414080 /* FunctionExcludes */;
|
|
27177
27189
|
case 255 /* VariableDeclarationList */:
|
|
27178
|
-
return
|
|
27190
|
+
return 537460736 /* VariableDeclarationListExcludes */;
|
|
27179
27191
|
case 257 /* ClassDeclaration */:
|
|
27180
27192
|
case 226 /* ClassExpression */:
|
|
27181
|
-
return
|
|
27193
|
+
return 537010176 /* ClassExcludes */;
|
|
27182
27194
|
case 171 /* Constructor */:
|
|
27183
|
-
return
|
|
27195
|
+
return 746405888 /* ConstructorExcludes */;
|
|
27184
27196
|
case 167 /* PropertyDeclaration */:
|
|
27185
|
-
return
|
|
27197
|
+
return 671105024 /* PropertyExcludes */;
|
|
27186
27198
|
case 169 /* MethodDeclaration */:
|
|
27187
27199
|
case 172 /* GetAccessor */:
|
|
27188
27200
|
case 173 /* SetAccessor */:
|
|
27189
|
-
return
|
|
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
|
|
27221
|
+
return 537075712 /* ObjectLiteralExcludes */;
|
|
27210
27222
|
case 292 /* CatchClause */:
|
|
27211
|
-
return
|
|
27223
|
+
return 536936448 /* CatchClauseExcludes */;
|
|
27212
27224
|
case 201 /* ObjectBindingPattern */:
|
|
27213
27225
|
case 202 /* ArrayBindingPattern */:
|
|
27214
|
-
return
|
|
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 &
|
|
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 &
|
|
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, "/"); }),
|
|
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) {
|
|
@@ -80880,8 +80933,11 @@ var ts;
|
|
|
80880
80933
|
if (node.assertions) {
|
|
80881
80934
|
var override = ts.getResolutionModeOverrideForClause(node.assertions.assertClause, grammarErrorOnNode);
|
|
80882
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
|
+
}
|
|
80883
80939
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
80884
|
-
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.
|
|
80940
|
+
grammarErrorOnNode(node.assertions.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
80885
80941
|
}
|
|
80886
80942
|
}
|
|
80887
80943
|
}
|
|
@@ -85287,10 +85343,10 @@ var ts;
|
|
|
85287
85343
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
85288
85344
|
if (validForTypeAssertions && override) {
|
|
85289
85345
|
if (!ts.isNightly()) {
|
|
85290
|
-
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
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);
|
|
85291
85347
|
}
|
|
85292
85348
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
85293
|
-
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.
|
|
85349
|
+
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
85294
85350
|
}
|
|
85295
85351
|
return; // Other grammar checks do not apply to type-only imports with resolution mode assertions
|
|
85296
85352
|
}
|
|
@@ -91019,6 +91075,124 @@ var ts;
|
|
|
91019
91075
|
return !ts.isStatic(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name);
|
|
91020
91076
|
}
|
|
91021
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
|
+
}
|
|
91022
91196
|
})(ts || (ts = {}));
|
|
91023
91197
|
/*@internal*/
|
|
91024
91198
|
var ts;
|
|
@@ -91292,8 +91466,8 @@ var ts;
|
|
|
91292
91466
|
if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
|
|
91293
91467
|
var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
|
|
91294
91468
|
if (flattenContext.level >= 1 /* ObjectRest */
|
|
91295
|
-
&& !(element.transformFlags & (
|
|
91296
|
-
&& !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (
|
|
91469
|
+
&& !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
|
|
91470
|
+
&& !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */))
|
|
91297
91471
|
&& !ts.isComputedPropertyName(propertyName)) {
|
|
91298
91472
|
bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
|
|
91299
91473
|
}
|
|
@@ -91359,7 +91533,7 @@ var ts;
|
|
|
91359
91533
|
if (flattenContext.level >= 1 /* ObjectRest */) {
|
|
91360
91534
|
// If an array pattern contains an ObjectRest, we must cache the result so that we
|
|
91361
91535
|
// can perform the ObjectRest destructuring in a different declaration
|
|
91362
|
-
if (element.transformFlags &
|
|
91536
|
+
if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
|
|
91363
91537
|
flattenContext.hasTransformedPriorElement = true;
|
|
91364
91538
|
var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
91365
91539
|
if (flattenContext.hoistTempVariables) {
|
|
@@ -91581,8 +91755,6 @@ var ts;
|
|
|
91581
91755
|
var USE_NEW_TYPE_METADATA_FORMAT = false;
|
|
91582
91756
|
var TypeScriptSubstitutionFlags;
|
|
91583
91757
|
(function (TypeScriptSubstitutionFlags) {
|
|
91584
|
-
/** Enables substitutions for decorated classes. */
|
|
91585
|
-
TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["ClassAliases"] = 1] = "ClassAliases";
|
|
91586
91758
|
/** Enables substitutions for namespace exports. */
|
|
91587
91759
|
TypeScriptSubstitutionFlags[TypeScriptSubstitutionFlags["NamespaceExports"] = 2] = "NamespaceExports";
|
|
91588
91760
|
/* Enables substitutions for unqualified enum members */
|
|
@@ -91608,9 +91780,9 @@ var ts;
|
|
|
91608
91780
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
|
|
91609
91781
|
var resolver = context.getEmitResolver();
|
|
91610
91782
|
var compilerOptions = context.getCompilerOptions();
|
|
91611
|
-
var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
|
|
91612
91783
|
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
91613
91784
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
91785
|
+
var typeSerializer = compilerOptions.emitDecoratorMetadata ? ts.createRuntimeTypeSerializer(context) : undefined;
|
|
91614
91786
|
// Save the previous transformation hooks.
|
|
91615
91787
|
var previousOnEmitNode = context.onEmitNode;
|
|
91616
91788
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
@@ -91625,7 +91797,6 @@ var ts;
|
|
|
91625
91797
|
var currentNamespace;
|
|
91626
91798
|
var currentNamespaceContainerName;
|
|
91627
91799
|
var currentLexicalScope;
|
|
91628
|
-
var currentNameScope;
|
|
91629
91800
|
var currentScopeFirstDeclarationsOfName;
|
|
91630
91801
|
var currentClassHasParameterProperties;
|
|
91631
91802
|
/**
|
|
@@ -91633,11 +91804,6 @@ var ts;
|
|
|
91633
91804
|
* They are persisted between each SourceFile transformation and should not be reset.
|
|
91634
91805
|
*/
|
|
91635
91806
|
var enabledSubstitutions;
|
|
91636
|
-
/**
|
|
91637
|
-
* A map that keeps track of aliases created for classes with decorators to avoid issues
|
|
91638
|
-
* with the double-binding behavior of classes.
|
|
91639
|
-
*/
|
|
91640
|
-
var classAliases;
|
|
91641
91807
|
/**
|
|
91642
91808
|
* Keeps track of whether we are within any containing namespaces when performing
|
|
91643
91809
|
* just-in-time substitution while printing an expression identifier.
|
|
@@ -91681,7 +91847,6 @@ var ts;
|
|
|
91681
91847
|
function saveStateAndInvoke(node, f) {
|
|
91682
91848
|
// Save state
|
|
91683
91849
|
var savedCurrentScope = currentLexicalScope;
|
|
91684
|
-
var savedCurrentNameScope = currentNameScope;
|
|
91685
91850
|
var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
|
|
91686
91851
|
var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
|
|
91687
91852
|
// Handle state changes before visiting a node.
|
|
@@ -91692,7 +91857,6 @@ var ts;
|
|
|
91692
91857
|
currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
|
|
91693
91858
|
}
|
|
91694
91859
|
currentLexicalScope = savedCurrentScope;
|
|
91695
|
-
currentNameScope = savedCurrentNameScope;
|
|
91696
91860
|
currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
|
|
91697
91861
|
return visited;
|
|
91698
91862
|
}
|
|
@@ -91708,7 +91872,6 @@ var ts;
|
|
|
91708
91872
|
case 262 /* ModuleBlock */:
|
|
91709
91873
|
case 235 /* Block */:
|
|
91710
91874
|
currentLexicalScope = node;
|
|
91711
|
-
currentNameScope = undefined;
|
|
91712
91875
|
currentScopeFirstDeclarationsOfName = undefined;
|
|
91713
91876
|
break;
|
|
91714
91877
|
case 257 /* ClassDeclaration */:
|
|
@@ -91726,10 +91889,6 @@ var ts;
|
|
|
91726
91889
|
// programs may also have an undefined name.
|
|
91727
91890
|
ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */));
|
|
91728
91891
|
}
|
|
91729
|
-
if (ts.isClassDeclaration(node)) {
|
|
91730
|
-
// XXX: should probably also cover interfaces and type aliases that can have type variables?
|
|
91731
|
-
currentNameScope = node;
|
|
91732
|
-
}
|
|
91733
91892
|
break;
|
|
91734
91893
|
}
|
|
91735
91894
|
}
|
|
@@ -91831,35 +91990,66 @@ var ts;
|
|
|
91831
91990
|
return node;
|
|
91832
91991
|
}
|
|
91833
91992
|
/**
|
|
91834
|
-
*
|
|
91993
|
+
* Gets a specialized visitor that visits the immediate children of a class with TypeScript syntax.
|
|
91835
91994
|
*
|
|
91836
|
-
* @param
|
|
91995
|
+
* @param parent The class containing the elements to visit.
|
|
91837
91996
|
*/
|
|
91838
|
-
function
|
|
91839
|
-
return saveStateAndInvoke(node, classElementVisitorWorker);
|
|
91997
|
+
function getClassElementVisitor(parent) {
|
|
91998
|
+
return function (node) { return saveStateAndInvoke(node, function (n) { return classElementVisitorWorker(n, parent); }); };
|
|
91840
91999
|
}
|
|
91841
92000
|
/**
|
|
91842
92001
|
* Specialized visitor that visits the immediate children of a class with TypeScript syntax.
|
|
91843
92002
|
*
|
|
91844
92003
|
* @param node The node to visit.
|
|
91845
92004
|
*/
|
|
91846
|
-
function classElementVisitorWorker(node) {
|
|
92005
|
+
function classElementVisitorWorker(node, parent) {
|
|
91847
92006
|
switch (node.kind) {
|
|
91848
92007
|
case 171 /* Constructor */:
|
|
91849
92008
|
return visitConstructor(node);
|
|
91850
92009
|
case 167 /* PropertyDeclaration */:
|
|
91851
92010
|
// Property declarations are not TypeScript syntax, but they must be visited
|
|
91852
92011
|
// for the decorator transformation.
|
|
91853
|
-
return visitPropertyDeclaration(node);
|
|
91854
|
-
case 176 /* IndexSignature */:
|
|
92012
|
+
return visitPropertyDeclaration(node, parent);
|
|
91855
92013
|
case 172 /* GetAccessor */:
|
|
92014
|
+
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
|
|
92015
|
+
return visitGetAccessor(node, parent);
|
|
91856
92016
|
case 173 /* SetAccessor */:
|
|
92017
|
+
// Set Accessors can have TypeScript modifiers and type annotations.
|
|
92018
|
+
return visitSetAccessor(node, parent);
|
|
91857
92019
|
case 169 /* MethodDeclaration */:
|
|
92020
|
+
// TypeScript method declarations may have decorators, modifiers
|
|
92021
|
+
// or type annotations.
|
|
92022
|
+
return visitMethodDeclaration(node, parent);
|
|
91858
92023
|
case 170 /* ClassStaticBlockDeclaration */:
|
|
91859
|
-
|
|
91860
|
-
return visitorWorker(node);
|
|
92024
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91861
92025
|
case 234 /* SemicolonClassElement */:
|
|
91862
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);
|
|
91863
92053
|
default:
|
|
91864
92054
|
return ts.Debug.failBadSyntaxKind(node);
|
|
91865
92055
|
}
|
|
@@ -91932,22 +92122,14 @@ var ts;
|
|
|
91932
92122
|
// TypeScript type nodes are elided.
|
|
91933
92123
|
// falls through
|
|
91934
92124
|
case 176 /* IndexSignature */:
|
|
91935
|
-
|
|
91936
|
-
// falls through
|
|
91937
|
-
case 165 /* Decorator */:
|
|
91938
|
-
// TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration.
|
|
92125
|
+
// TypeScript index signatures are elided.
|
|
91939
92126
|
return undefined;
|
|
91940
92127
|
case 259 /* TypeAliasDeclaration */:
|
|
91941
92128
|
// TypeScript type-only declarations are elided.
|
|
91942
92129
|
return factory.createNotEmittedStatement(node);
|
|
91943
|
-
case 167 /* PropertyDeclaration */:
|
|
91944
|
-
// TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects
|
|
91945
|
-
return visitPropertyDeclaration(node);
|
|
91946
92130
|
case 264 /* NamespaceExportDeclaration */:
|
|
91947
92131
|
// TypeScript namespace export declarations are elided.
|
|
91948
92132
|
return undefined;
|
|
91949
|
-
case 171 /* Constructor */:
|
|
91950
|
-
return visitConstructor(node);
|
|
91951
92133
|
case 258 /* InterfaceDeclaration */:
|
|
91952
92134
|
// TypeScript interfaces are elided, but some comments may be preserved.
|
|
91953
92135
|
// See the implementation of `getLeadingComments` in comments.ts for more details.
|
|
@@ -91981,16 +92163,15 @@ var ts;
|
|
|
91981
92163
|
case 228 /* ExpressionWithTypeArguments */:
|
|
91982
92164
|
// TypeScript supports type arguments on an expression in an `extends` heritage clause.
|
|
91983
92165
|
return visitExpressionWithTypeArguments(node);
|
|
92166
|
+
case 205 /* ObjectLiteralExpression */:
|
|
92167
|
+
return visitObjectLiteralExpression(node);
|
|
92168
|
+
case 171 /* Constructor */:
|
|
92169
|
+
case 167 /* PropertyDeclaration */:
|
|
91984
92170
|
case 169 /* MethodDeclaration */:
|
|
91985
|
-
// TypeScript method declarations may have decorators, modifiers
|
|
91986
|
-
// or type annotations.
|
|
91987
|
-
return visitMethodDeclaration(node);
|
|
91988
92171
|
case 172 /* GetAccessor */:
|
|
91989
|
-
// Get Accessors can have TypeScript modifiers, decorators, and type annotations.
|
|
91990
|
-
return visitGetAccessor(node);
|
|
91991
92172
|
case 173 /* SetAccessor */:
|
|
91992
|
-
|
|
91993
|
-
return
|
|
92173
|
+
case 170 /* ClassStaticBlockDeclaration */:
|
|
92174
|
+
return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors");
|
|
91994
92175
|
case 256 /* FunctionDeclaration */:
|
|
91995
92176
|
// Typescript function declarations can have modifiers, decorators, and type annotations.
|
|
91996
92177
|
return visitFunctionDeclaration(node);
|
|
@@ -92056,6 +92237,9 @@ var ts;
|
|
|
92056
92237
|
!ts.isJsonSourceFile(node);
|
|
92057
92238
|
return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
|
|
92058
92239
|
}
|
|
92240
|
+
function visitObjectLiteralExpression(node) {
|
|
92241
|
+
return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement));
|
|
92242
|
+
}
|
|
92059
92243
|
function getClassFacts(node, staticProperties) {
|
|
92060
92244
|
var facts = 0 /* None */;
|
|
92061
92245
|
if (ts.some(staticProperties))
|
|
@@ -92078,7 +92262,7 @@ var ts;
|
|
|
92078
92262
|
return facts;
|
|
92079
92263
|
}
|
|
92080
92264
|
function hasTypeScriptClassSyntax(node) {
|
|
92081
|
-
return !!(node.transformFlags &
|
|
92265
|
+
return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */);
|
|
92082
92266
|
}
|
|
92083
92267
|
function isClassLikeDeclarationWithTypeScriptSyntax(node) {
|
|
92084
92268
|
return ts.some(node.decorators)
|
|
@@ -92088,7 +92272,9 @@ var ts;
|
|
|
92088
92272
|
}
|
|
92089
92273
|
function visitClassDeclaration(node) {
|
|
92090
92274
|
if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) {
|
|
92091
|
-
return ts.
|
|
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));
|
|
92092
92278
|
}
|
|
92093
92279
|
var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true);
|
|
92094
92280
|
var facts = getClassFacts(node, staticProperties);
|
|
@@ -92096,14 +92282,25 @@ var ts;
|
|
|
92096
92282
|
context.startLexicalEnvironment();
|
|
92097
92283
|
}
|
|
92098
92284
|
var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined);
|
|
92099
|
-
var
|
|
92100
|
-
|
|
92101
|
-
|
|
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);
|
|
92102
92303
|
var statements = [classStatement];
|
|
92103
|
-
// Write any decorators of the node.
|
|
92104
|
-
addClassElementDecorationStatements(statements, node, /*isStatic*/ false);
|
|
92105
|
-
addClassElementDecorationStatements(statements, node, /*isStatic*/ true);
|
|
92106
|
-
addConstructorDecorationStatement(statements, node);
|
|
92107
92304
|
if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) {
|
|
92108
92305
|
// When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the
|
|
92109
92306
|
// 'es2015' transformer can properly nest static initializers and decorators. The result
|
|
@@ -92163,164 +92360,14 @@ var ts;
|
|
|
92163
92360
|
}
|
|
92164
92361
|
return ts.singleOrMany(statements);
|
|
92165
92362
|
}
|
|
92166
|
-
/**
|
|
92167
|
-
* Transforms a non-decorated class declaration and appends the resulting statements.
|
|
92168
|
-
*
|
|
92169
|
-
* @param node A ClassDeclaration node.
|
|
92170
|
-
* @param name The name of the class.
|
|
92171
|
-
* @param facts Precomputed facts about the class.
|
|
92172
|
-
*/
|
|
92173
|
-
function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
|
|
92174
|
-
// ${modifiers} class ${name} ${heritageClauses} {
|
|
92175
|
-
// ${members}
|
|
92176
|
-
// }
|
|
92177
|
-
// we do not emit modifiers on the declaration if we are emitting an IIFE
|
|
92178
|
-
var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */)
|
|
92179
|
-
? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
|
|
92180
|
-
: undefined;
|
|
92181
|
-
var classDeclaration = factory.createClassDeclaration(
|
|
92182
|
-
/*decorators*/ undefined, modifiers, name,
|
|
92183
|
-
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
|
|
92184
|
-
// To better align with the old emitter, we should not emit a trailing source map
|
|
92185
|
-
// entry if the class has static properties.
|
|
92186
|
-
var emitFlags = ts.getEmitFlags(node);
|
|
92187
|
-
if (facts & 1 /* HasStaticInitializedProperties */) {
|
|
92188
|
-
emitFlags |= 32 /* NoTrailingSourceMap */;
|
|
92189
|
-
}
|
|
92190
|
-
ts.setTextRange(classDeclaration, node);
|
|
92191
|
-
ts.setOriginalNode(classDeclaration, node);
|
|
92192
|
-
ts.setEmitFlags(classDeclaration, emitFlags);
|
|
92193
|
-
return classDeclaration;
|
|
92194
|
-
}
|
|
92195
|
-
/**
|
|
92196
|
-
* Transforms a decorated class declaration and appends the resulting statements. If
|
|
92197
|
-
* the class requires an alias to avoid issues with double-binding, the alias is returned.
|
|
92198
|
-
*/
|
|
92199
|
-
function createClassDeclarationHeadWithDecorators(node, name) {
|
|
92200
|
-
// When we emit an ES6 class that has a class decorator, we must tailor the
|
|
92201
|
-
// emit to certain specific cases.
|
|
92202
|
-
//
|
|
92203
|
-
// In the simplest case, we emit the class declaration as a let declaration, and
|
|
92204
|
-
// evaluate decorators after the close of the class body:
|
|
92205
|
-
//
|
|
92206
|
-
// [Example 1]
|
|
92207
|
-
// ---------------------------------------------------------------------
|
|
92208
|
-
// TypeScript | Javascript
|
|
92209
|
-
// ---------------------------------------------------------------------
|
|
92210
|
-
// @dec | let C = class C {
|
|
92211
|
-
// class C { | }
|
|
92212
|
-
// } | C = __decorate([dec], C);
|
|
92213
|
-
// ---------------------------------------------------------------------
|
|
92214
|
-
// @dec | let C = class C {
|
|
92215
|
-
// export class C { | }
|
|
92216
|
-
// } | C = __decorate([dec], C);
|
|
92217
|
-
// | export { C };
|
|
92218
|
-
// ---------------------------------------------------------------------
|
|
92219
|
-
//
|
|
92220
|
-
// If a class declaration contains a reference to itself *inside* of the class body,
|
|
92221
|
-
// this introduces two bindings to the class: One outside of the class body, and one
|
|
92222
|
-
// inside of the class body. If we apply decorators as in [Example 1] above, there
|
|
92223
|
-
// is the possibility that the decorator `dec` will return a new value for the
|
|
92224
|
-
// constructor, which would result in the binding inside of the class no longer
|
|
92225
|
-
// pointing to the same reference as the binding outside of the class.
|
|
92226
|
-
//
|
|
92227
|
-
// As a result, we must instead rewrite all references to the class *inside* of the
|
|
92228
|
-
// class body to instead point to a local temporary alias for the class:
|
|
92229
|
-
//
|
|
92230
|
-
// [Example 2]
|
|
92231
|
-
// ---------------------------------------------------------------------
|
|
92232
|
-
// TypeScript | Javascript
|
|
92233
|
-
// ---------------------------------------------------------------------
|
|
92234
|
-
// @dec | let C = C_1 = class C {
|
|
92235
|
-
// class C { | static x() { return C_1.y; }
|
|
92236
|
-
// static x() { return C.y; } | }
|
|
92237
|
-
// static y = 1; | C.y = 1;
|
|
92238
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92239
|
-
// | var C_1;
|
|
92240
|
-
// ---------------------------------------------------------------------
|
|
92241
|
-
// @dec | let C = class C {
|
|
92242
|
-
// export class C { | static x() { return C_1.y; }
|
|
92243
|
-
// static x() { return C.y; } | }
|
|
92244
|
-
// static y = 1; | C.y = 1;
|
|
92245
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92246
|
-
// | export { C };
|
|
92247
|
-
// | var C_1;
|
|
92248
|
-
// ---------------------------------------------------------------------
|
|
92249
|
-
//
|
|
92250
|
-
// If a class declaration is the default export of a module, we instead emit
|
|
92251
|
-
// the export after the decorated declaration:
|
|
92252
|
-
//
|
|
92253
|
-
// [Example 3]
|
|
92254
|
-
// ---------------------------------------------------------------------
|
|
92255
|
-
// TypeScript | Javascript
|
|
92256
|
-
// ---------------------------------------------------------------------
|
|
92257
|
-
// @dec | let default_1 = class {
|
|
92258
|
-
// export default class { | }
|
|
92259
|
-
// } | default_1 = __decorate([dec], default_1);
|
|
92260
|
-
// | export default default_1;
|
|
92261
|
-
// ---------------------------------------------------------------------
|
|
92262
|
-
// @dec | let C = class C {
|
|
92263
|
-
// export default class C { | }
|
|
92264
|
-
// } | C = __decorate([dec], C);
|
|
92265
|
-
// | export default C;
|
|
92266
|
-
// ---------------------------------------------------------------------
|
|
92267
|
-
//
|
|
92268
|
-
// If the class declaration is the default export and a reference to itself
|
|
92269
|
-
// inside of the class body, we must emit both an alias for the class *and*
|
|
92270
|
-
// move the export after the declaration:
|
|
92271
|
-
//
|
|
92272
|
-
// [Example 4]
|
|
92273
|
-
// ---------------------------------------------------------------------
|
|
92274
|
-
// TypeScript | Javascript
|
|
92275
|
-
// ---------------------------------------------------------------------
|
|
92276
|
-
// @dec | let C = class C {
|
|
92277
|
-
// export default class C { | static x() { return C_1.y; }
|
|
92278
|
-
// static x() { return C.y; } | }
|
|
92279
|
-
// static y = 1; | C.y = 1;
|
|
92280
|
-
// } | C = C_1 = __decorate([dec], C);
|
|
92281
|
-
// | export default C;
|
|
92282
|
-
// | var C_1;
|
|
92283
|
-
// ---------------------------------------------------------------------
|
|
92284
|
-
//
|
|
92285
|
-
var location = ts.moveRangePastDecorators(node);
|
|
92286
|
-
var classAlias = getClassAliasIfNeeded(node);
|
|
92287
|
-
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
92288
|
-
// without any block-scoped variable collision handling
|
|
92289
|
-
var declName = languageVersion <= 2 /* ES2015 */ ?
|
|
92290
|
-
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
92291
|
-
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
92292
|
-
// ... = class ${name} ${heritageClauses} {
|
|
92293
|
-
// ${members}
|
|
92294
|
-
// }
|
|
92295
|
-
var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
|
|
92296
|
-
var members = transformClassMembers(node);
|
|
92297
|
-
var classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members);
|
|
92298
|
-
ts.setOriginalNode(classExpression, node);
|
|
92299
|
-
ts.setTextRange(classExpression, location);
|
|
92300
|
-
// let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference
|
|
92301
|
-
// or decoratedClassAlias if the class contain self-reference.
|
|
92302
|
-
var statement = factory.createVariableStatement(
|
|
92303
|
-
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
92304
|
-
factory.createVariableDeclaration(declName,
|
|
92305
|
-
/*exclamationToken*/ undefined,
|
|
92306
|
-
/*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
|
|
92307
|
-
], 1 /* Let */));
|
|
92308
|
-
ts.setOriginalNode(statement, node);
|
|
92309
|
-
ts.setTextRange(statement, location);
|
|
92310
|
-
ts.setCommentRange(statement, node);
|
|
92311
|
-
return statement;
|
|
92312
|
-
}
|
|
92313
92363
|
function visitClassExpression(node) {
|
|
92314
|
-
|
|
92315
|
-
|
|
92316
|
-
|
|
92317
|
-
var classExpression = factory.createClassExpression(
|
|
92318
|
-
/*decorators*/ undefined,
|
|
92364
|
+
var allDecorators = getAllDecoratorsOfConstructor(node);
|
|
92365
|
+
var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
|
92366
|
+
return factory.updateClassExpression(node, decorators,
|
|
92319
92367
|
/*modifiers*/ undefined, node.name,
|
|
92320
|
-
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause),
|
|
92321
|
-
|
|
92322
|
-
|
|
92323
|
-
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));
|
|
92324
92371
|
}
|
|
92325
92372
|
/**
|
|
92326
92373
|
* Transforms the members of a class.
|
|
@@ -92345,48 +92392,9 @@ var ts;
|
|
|
92345
92392
|
}
|
|
92346
92393
|
}
|
|
92347
92394
|
}
|
|
92348
|
-
ts.addRange(members, ts.visitNodes(node.members,
|
|
92395
|
+
ts.addRange(members, ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement));
|
|
92349
92396
|
return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
|
92350
92397
|
}
|
|
92351
|
-
/**
|
|
92352
|
-
* Gets either the static or instance members of a class that are decorated, or have
|
|
92353
|
-
* parameters that are decorated.
|
|
92354
|
-
*
|
|
92355
|
-
* @param node The class containing the member.
|
|
92356
|
-
* @param isStatic A value indicating whether to retrieve static or instance members of
|
|
92357
|
-
* the class.
|
|
92358
|
-
*/
|
|
92359
|
-
function getDecoratedClassElements(node, isStatic) {
|
|
92360
|
-
return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
|
|
92361
|
-
}
|
|
92362
|
-
/**
|
|
92363
|
-
* Determines whether a class member is a static member of a class that is decorated, or
|
|
92364
|
-
* has parameters that are decorated.
|
|
92365
|
-
*
|
|
92366
|
-
* @param member The class member.
|
|
92367
|
-
*/
|
|
92368
|
-
function isStaticDecoratedClassElement(member, parent) {
|
|
92369
|
-
return isDecoratedClassElement(member, /*isStaticElement*/ true, parent);
|
|
92370
|
-
}
|
|
92371
|
-
/**
|
|
92372
|
-
* Determines whether a class member is an instance member of a class that is decorated,
|
|
92373
|
-
* or has parameters that are decorated.
|
|
92374
|
-
*
|
|
92375
|
-
* @param member The class member.
|
|
92376
|
-
*/
|
|
92377
|
-
function isInstanceDecoratedClassElement(member, parent) {
|
|
92378
|
-
return isDecoratedClassElement(member, /*isStaticElement*/ false, parent);
|
|
92379
|
-
}
|
|
92380
|
-
/**
|
|
92381
|
-
* Determines whether a class member is either a static or an instance member of a class
|
|
92382
|
-
* that is decorated, or has parameters that are decorated.
|
|
92383
|
-
*
|
|
92384
|
-
* @param member The class member.
|
|
92385
|
-
*/
|
|
92386
|
-
function isDecoratedClassElement(member, isStaticElement, parent) {
|
|
92387
|
-
return ts.nodeOrChildIsDecorated(member, parent)
|
|
92388
|
-
&& isStaticElement === ts.isStatic(member);
|
|
92389
|
-
}
|
|
92390
92398
|
/**
|
|
92391
92399
|
* Gets an array of arrays of decorators for the parameters of a function-like node.
|
|
92392
92400
|
* The offset into the result array should correspond to the offset of the parameter.
|
|
@@ -92432,14 +92440,14 @@ var ts;
|
|
|
92432
92440
|
/**
|
|
92433
92441
|
* Gets an AllDecorators object containing the decorators for the member and its parameters.
|
|
92434
92442
|
*
|
|
92435
|
-
* @param
|
|
92443
|
+
* @param parent The class node that contains the member.
|
|
92436
92444
|
* @param member The class member.
|
|
92437
92445
|
*/
|
|
92438
|
-
function getAllDecoratorsOfClassElement(
|
|
92446
|
+
function getAllDecoratorsOfClassElement(member, parent) {
|
|
92439
92447
|
switch (member.kind) {
|
|
92440
92448
|
case 172 /* GetAccessor */:
|
|
92441
92449
|
case 173 /* SetAccessor */:
|
|
92442
|
-
return getAllDecoratorsOfAccessors(
|
|
92450
|
+
return getAllDecoratorsOfAccessors(parent, member);
|
|
92443
92451
|
case 169 /* MethodDeclaration */:
|
|
92444
92452
|
return getAllDecoratorsOfMethod(member);
|
|
92445
92453
|
case 167 /* PropertyDeclaration */:
|
|
@@ -92508,209 +92516,82 @@ var ts;
|
|
|
92508
92516
|
if (!allDecorators) {
|
|
92509
92517
|
return undefined;
|
|
92510
92518
|
}
|
|
92511
|
-
var
|
|
92512
|
-
|
|
92513
|
-
ts.
|
|
92514
|
-
|
|
92515
|
-
|
|
92516
|
-
|
|
92517
|
-
/**
|
|
92518
|
-
* Generates statements used to apply decorators to either the static or instance members
|
|
92519
|
-
* of a class.
|
|
92520
|
-
*
|
|
92521
|
-
* @param node The class node.
|
|
92522
|
-
* @param isStatic A value indicating whether to generate statements for static or
|
|
92523
|
-
* instance members.
|
|
92524
|
-
*/
|
|
92525
|
-
function addClassElementDecorationStatements(statements, node, isStatic) {
|
|
92526
|
-
ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
|
|
92527
|
-
}
|
|
92528
|
-
/**
|
|
92529
|
-
* Generates expressions used to apply decorators to either the static or instance members
|
|
92530
|
-
* of a class.
|
|
92531
|
-
*
|
|
92532
|
-
* @param node The class node.
|
|
92533
|
-
* @param isStatic A value indicating whether to generate expressions for static or
|
|
92534
|
-
* instance members.
|
|
92535
|
-
*/
|
|
92536
|
-
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
92537
|
-
var members = getDecoratedClassElements(node, isStatic);
|
|
92538
|
-
var expressions;
|
|
92539
|
-
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
92540
|
-
var member = members_8[_i];
|
|
92541
|
-
var expression = generateClassElementDecorationExpression(node, member);
|
|
92542
|
-
if (expression) {
|
|
92543
|
-
if (!expressions) {
|
|
92544
|
-
expressions = [expression];
|
|
92545
|
-
}
|
|
92546
|
-
else {
|
|
92547
|
-
expressions.push(expression);
|
|
92548
|
-
}
|
|
92549
|
-
}
|
|
92550
|
-
}
|
|
92551
|
-
return expressions;
|
|
92552
|
-
}
|
|
92553
|
-
/**
|
|
92554
|
-
* Generates an expression used to evaluate class element decorators at runtime.
|
|
92555
|
-
*
|
|
92556
|
-
* @param node The class node that contains the member.
|
|
92557
|
-
* @param member The class member.
|
|
92558
|
-
*/
|
|
92559
|
-
function generateClassElementDecorationExpression(node, member) {
|
|
92560
|
-
var allDecorators = getAllDecoratorsOfClassElement(node, member);
|
|
92561
|
-
var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
|
|
92562
|
-
if (!decoratorExpressions) {
|
|
92563
|
-
return undefined;
|
|
92564
|
-
}
|
|
92565
|
-
// Emit the call to __decorate. Given the following:
|
|
92566
|
-
//
|
|
92567
|
-
// class C {
|
|
92568
|
-
// @dec method(@dec2 x) {}
|
|
92569
|
-
// @dec get accessor() {}
|
|
92570
|
-
// @dec prop;
|
|
92571
|
-
// }
|
|
92572
|
-
//
|
|
92573
|
-
// The emit for a method is:
|
|
92574
|
-
//
|
|
92575
|
-
// __decorate([
|
|
92576
|
-
// dec,
|
|
92577
|
-
// __param(0, dec2),
|
|
92578
|
-
// __metadata("design:type", Function),
|
|
92579
|
-
// __metadata("design:paramtypes", [Object]),
|
|
92580
|
-
// __metadata("design:returntype", void 0)
|
|
92581
|
-
// ], C.prototype, "method", null);
|
|
92582
|
-
//
|
|
92583
|
-
// The emit for an accessor is:
|
|
92584
|
-
//
|
|
92585
|
-
// __decorate([
|
|
92586
|
-
// dec
|
|
92587
|
-
// ], C.prototype, "accessor", null);
|
|
92588
|
-
//
|
|
92589
|
-
// The emit for a property is:
|
|
92590
|
-
//
|
|
92591
|
-
// __decorate([
|
|
92592
|
-
// dec
|
|
92593
|
-
// ], C.prototype, "prop");
|
|
92594
|
-
//
|
|
92595
|
-
var prefix = getClassMemberPrefix(node, member);
|
|
92596
|
-
var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */));
|
|
92597
|
-
var descriptor = languageVersion > 0 /* ES3 */
|
|
92598
|
-
? member.kind === 167 /* PropertyDeclaration */
|
|
92599
|
-
// We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it
|
|
92600
|
-
// should not invoke `Object.getOwnPropertyDescriptor`.
|
|
92601
|
-
? factory.createVoidZero()
|
|
92602
|
-
// We emit `null` here to indicate to `__decorate` that it can invoke `Object.getOwnPropertyDescriptor` directly.
|
|
92603
|
-
// We have this extra argument here so that we can inject an explicit property descriptor at a later date.
|
|
92604
|
-
: factory.createNull()
|
|
92605
|
-
: undefined;
|
|
92606
|
-
var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
|
|
92607
|
-
ts.setTextRange(helper, ts.moveRangePastDecorators(member));
|
|
92608
|
-
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
92609
|
-
return helper;
|
|
92610
|
-
}
|
|
92611
|
-
/**
|
|
92612
|
-
* Generates a __decorate helper call for a class constructor.
|
|
92613
|
-
*
|
|
92614
|
-
* @param node The class node.
|
|
92615
|
-
*/
|
|
92616
|
-
function addConstructorDecorationStatement(statements, node) {
|
|
92617
|
-
var expression = generateConstructorDecorationExpression(node);
|
|
92618
|
-
if (expression) {
|
|
92619
|
-
statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
|
|
92620
|
-
}
|
|
92621
|
-
}
|
|
92622
|
-
/**
|
|
92623
|
-
* Generates a __decorate helper call for a class constructor.
|
|
92624
|
-
*
|
|
92625
|
-
* @param node The class node.
|
|
92626
|
-
*/
|
|
92627
|
-
function generateConstructorDecorationExpression(node) {
|
|
92628
|
-
var allDecorators = getAllDecoratorsOfConstructor(node);
|
|
92629
|
-
var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
|
|
92630
|
-
if (!decoratorExpressions) {
|
|
92631
|
-
return undefined;
|
|
92632
|
-
}
|
|
92633
|
-
var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
|
|
92634
|
-
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
|
92635
|
-
// without any block-scoped variable collision handling
|
|
92636
|
-
var localName = languageVersion <= 2 /* ES2015 */ ?
|
|
92637
|
-
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
|
92638
|
-
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
|
92639
|
-
var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
|
|
92640
|
-
var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
|
|
92641
|
-
ts.setEmitFlags(expression, 1536 /* NoComments */);
|
|
92642
|
-
ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
|
|
92643
|
-
return expression;
|
|
92644
|
-
}
|
|
92645
|
-
/**
|
|
92646
|
-
* Transforms a decorator into an expression.
|
|
92647
|
-
*
|
|
92648
|
-
* @param decorator The decorator node.
|
|
92649
|
-
*/
|
|
92650
|
-
function transformDecorator(decorator) {
|
|
92651
|
-
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;
|
|
92652
92525
|
}
|
|
92653
92526
|
/**
|
|
92654
|
-
* Transforms the decorators of a parameter.
|
|
92527
|
+
* Transforms the decorators of a parameter into decorators of the class/method.
|
|
92655
92528
|
*
|
|
92656
|
-
* @param
|
|
92529
|
+
* @param parameterDecorators The decorators for the parameter at the provided offset.
|
|
92657
92530
|
* @param parameterOffset The offset of the parameter.
|
|
92658
92531
|
*/
|
|
92659
|
-
function transformDecoratorsOfParameter(
|
|
92660
|
-
|
|
92661
|
-
|
|
92662
|
-
|
|
92663
|
-
|
|
92664
|
-
var
|
|
92665
|
-
var helper = emitHelpers().createParamHelper(
|
|
92666
|
-
ts.setTextRange(helper,
|
|
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);
|
|
92667
92540
|
ts.setEmitFlags(helper, 1536 /* NoComments */);
|
|
92668
|
-
|
|
92541
|
+
var decorator = factory.createDecorator(helper);
|
|
92542
|
+
ts.setTextRange(decorator, parameterDecorator.expression);
|
|
92543
|
+
ts.setEmitFlags(decorator, 1536 /* NoComments */);
|
|
92544
|
+
decorators.push(decorator);
|
|
92669
92545
|
}
|
|
92546
|
+
return decorators;
|
|
92670
92547
|
}
|
|
92671
|
-
return expressions;
|
|
92672
92548
|
}
|
|
92673
92549
|
/**
|
|
92674
|
-
*
|
|
92550
|
+
* Gets optional type metadata for a declaration.
|
|
92675
92551
|
*
|
|
92676
92552
|
* @param node The declaration node.
|
|
92677
|
-
* @param decoratorExpressions The destination array to which to add new decorator expressions.
|
|
92678
92553
|
*/
|
|
92679
|
-
function
|
|
92680
|
-
|
|
92681
|
-
|
|
92682
|
-
|
|
92683
|
-
else {
|
|
92684
|
-
addOldTypeMetadata(node, container, decoratorExpressions);
|
|
92685
|
-
}
|
|
92554
|
+
function getTypeMetadata(node, container) {
|
|
92555
|
+
return USE_NEW_TYPE_METADATA_FORMAT ?
|
|
92556
|
+
getNewTypeMetadata(node, container) :
|
|
92557
|
+
getOldTypeMetadata(node, container);
|
|
92686
92558
|
}
|
|
92687
|
-
function
|
|
92688
|
-
if (
|
|
92559
|
+
function getOldTypeMetadata(node, container) {
|
|
92560
|
+
if (typeSerializer) {
|
|
92561
|
+
var decorators = void 0;
|
|
92689
92562
|
if (shouldAddTypeMetadata(node)) {
|
|
92690
|
-
|
|
92563
|
+
var typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
|
|
92564
|
+
decorators = ts.append(decorators, factory.createDecorator(typeMetadata));
|
|
92691
92565
|
}
|
|
92692
92566
|
if (shouldAddParamTypesMetadata(node)) {
|
|
92693
|
-
|
|
92567
|
+
var paramTypesMetadata = emitHelpers().createMetadataHelper("design:paramtypes", typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container));
|
|
92568
|
+
decorators = ts.append(decorators, factory.createDecorator(paramTypesMetadata));
|
|
92694
92569
|
}
|
|
92695
92570
|
if (shouldAddReturnTypeMetadata(node)) {
|
|
92696
|
-
|
|
92571
|
+
var returnTypeMetadata = emitHelpers().createMetadataHelper("design:returntype", typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node));
|
|
92572
|
+
decorators = ts.append(decorators, factory.createDecorator(returnTypeMetadata));
|
|
92697
92573
|
}
|
|
92574
|
+
return decorators;
|
|
92698
92575
|
}
|
|
92699
92576
|
}
|
|
92700
|
-
function
|
|
92701
|
-
if (
|
|
92577
|
+
function getNewTypeMetadata(node, container) {
|
|
92578
|
+
if (typeSerializer) {
|
|
92702
92579
|
var properties = void 0;
|
|
92703
92580
|
if (shouldAddTypeMetadata(node)) {
|
|
92704
|
-
|
|
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);
|
|
92705
92583
|
}
|
|
92706
92584
|
if (shouldAddParamTypesMetadata(node)) {
|
|
92707
|
-
|
|
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);
|
|
92708
92587
|
}
|
|
92709
92588
|
if (shouldAddReturnTypeMetadata(node)) {
|
|
92710
|
-
|
|
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);
|
|
92711
92591
|
}
|
|
92712
92592
|
if (properties) {
|
|
92713
|
-
|
|
92593
|
+
var typeInfoMetadata = emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, /*multiLine*/ true));
|
|
92594
|
+
return [factory.createDecorator(typeInfoMetadata)];
|
|
92714
92595
|
}
|
|
92715
92596
|
}
|
|
92716
92597
|
}
|
|
@@ -92757,347 +92638,6 @@ var ts;
|
|
|
92757
92638
|
}
|
|
92758
92639
|
return false;
|
|
92759
92640
|
}
|
|
92760
|
-
function getAccessorTypeNode(node) {
|
|
92761
|
-
var accessors = resolver.getAllAccessorDeclarations(node);
|
|
92762
|
-
return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
|
|
92763
|
-
|| accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
|
|
92764
|
-
}
|
|
92765
|
-
/**
|
|
92766
|
-
* Serializes the type of a node for use with decorator type metadata.
|
|
92767
|
-
*
|
|
92768
|
-
* @param node The node that should have its type serialized.
|
|
92769
|
-
*/
|
|
92770
|
-
function serializeTypeOfNode(node) {
|
|
92771
|
-
switch (node.kind) {
|
|
92772
|
-
case 167 /* PropertyDeclaration */:
|
|
92773
|
-
case 164 /* Parameter */:
|
|
92774
|
-
return serializeTypeNode(node.type);
|
|
92775
|
-
case 173 /* SetAccessor */:
|
|
92776
|
-
case 172 /* GetAccessor */:
|
|
92777
|
-
return serializeTypeNode(getAccessorTypeNode(node));
|
|
92778
|
-
case 257 /* ClassDeclaration */:
|
|
92779
|
-
case 226 /* ClassExpression */:
|
|
92780
|
-
case 169 /* MethodDeclaration */:
|
|
92781
|
-
return factory.createIdentifier("Function");
|
|
92782
|
-
default:
|
|
92783
|
-
return factory.createVoidZero();
|
|
92784
|
-
}
|
|
92785
|
-
}
|
|
92786
|
-
/**
|
|
92787
|
-
* Serializes the types of the parameters of a node for use with decorator type metadata.
|
|
92788
|
-
*
|
|
92789
|
-
* @param node The node that should have its parameter types serialized.
|
|
92790
|
-
*/
|
|
92791
|
-
function serializeParameterTypesOfNode(node, container) {
|
|
92792
|
-
var valueDeclaration = ts.isClassLike(node)
|
|
92793
|
-
? ts.getFirstConstructorWithBody(node)
|
|
92794
|
-
: ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
|
|
92795
|
-
? node
|
|
92796
|
-
: undefined;
|
|
92797
|
-
var expressions = [];
|
|
92798
|
-
if (valueDeclaration) {
|
|
92799
|
-
var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
|
|
92800
|
-
var numParameters = parameters.length;
|
|
92801
|
-
for (var i = 0; i < numParameters; i++) {
|
|
92802
|
-
var parameter = parameters[i];
|
|
92803
|
-
if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
|
|
92804
|
-
continue;
|
|
92805
|
-
}
|
|
92806
|
-
if (parameter.dotDotDotToken) {
|
|
92807
|
-
expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
|
|
92808
|
-
}
|
|
92809
|
-
else {
|
|
92810
|
-
expressions.push(serializeTypeOfNode(parameter));
|
|
92811
|
-
}
|
|
92812
|
-
}
|
|
92813
|
-
}
|
|
92814
|
-
return factory.createArrayLiteralExpression(expressions);
|
|
92815
|
-
}
|
|
92816
|
-
function getParametersOfDecoratedDeclaration(node, container) {
|
|
92817
|
-
if (container && node.kind === 172 /* GetAccessor */) {
|
|
92818
|
-
var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
|
|
92819
|
-
if (setAccessor) {
|
|
92820
|
-
return setAccessor.parameters;
|
|
92821
|
-
}
|
|
92822
|
-
}
|
|
92823
|
-
return node.parameters;
|
|
92824
|
-
}
|
|
92825
|
-
/**
|
|
92826
|
-
* Serializes the return type of a node for use with decorator type metadata.
|
|
92827
|
-
*
|
|
92828
|
-
* @param node The node that should have its return type serialized.
|
|
92829
|
-
*/
|
|
92830
|
-
function serializeReturnTypeOfNode(node) {
|
|
92831
|
-
if (ts.isFunctionLike(node) && node.type) {
|
|
92832
|
-
return serializeTypeNode(node.type);
|
|
92833
|
-
}
|
|
92834
|
-
else if (ts.isAsyncFunction(node)) {
|
|
92835
|
-
return factory.createIdentifier("Promise");
|
|
92836
|
-
}
|
|
92837
|
-
return factory.createVoidZero();
|
|
92838
|
-
}
|
|
92839
|
-
/**
|
|
92840
|
-
* Serializes a type node for use with decorator type metadata.
|
|
92841
|
-
*
|
|
92842
|
-
* Types are serialized in the following fashion:
|
|
92843
|
-
* - Void types point to "undefined" (e.g. "void 0")
|
|
92844
|
-
* - Function and Constructor types point to the global "Function" constructor.
|
|
92845
|
-
* - Interface types with a call or construct signature types point to the global
|
|
92846
|
-
* "Function" constructor.
|
|
92847
|
-
* - Array and Tuple types point to the global "Array" constructor.
|
|
92848
|
-
* - Type predicates and booleans point to the global "Boolean" constructor.
|
|
92849
|
-
* - String literal types and strings point to the global "String" constructor.
|
|
92850
|
-
* - Enum and number types point to the global "Number" constructor.
|
|
92851
|
-
* - Symbol types point to the global "Symbol" constructor.
|
|
92852
|
-
* - Type references to classes (or class-like variables) point to the constructor for the class.
|
|
92853
|
-
* - Anything else points to the global "Object" constructor.
|
|
92854
|
-
*
|
|
92855
|
-
* @param node The type node to serialize.
|
|
92856
|
-
*/
|
|
92857
|
-
function serializeTypeNode(node) {
|
|
92858
|
-
if (node === undefined) {
|
|
92859
|
-
return factory.createIdentifier("Object");
|
|
92860
|
-
}
|
|
92861
|
-
switch (node.kind) {
|
|
92862
|
-
case 114 /* VoidKeyword */:
|
|
92863
|
-
case 153 /* UndefinedKeyword */:
|
|
92864
|
-
case 143 /* NeverKeyword */:
|
|
92865
|
-
return factory.createVoidZero();
|
|
92866
|
-
case 191 /* ParenthesizedType */:
|
|
92867
|
-
return serializeTypeNode(node.type);
|
|
92868
|
-
case 179 /* FunctionType */:
|
|
92869
|
-
case 180 /* ConstructorType */:
|
|
92870
|
-
return factory.createIdentifier("Function");
|
|
92871
|
-
case 183 /* ArrayType */:
|
|
92872
|
-
case 184 /* TupleType */:
|
|
92873
|
-
return factory.createIdentifier("Array");
|
|
92874
|
-
case 177 /* TypePredicate */:
|
|
92875
|
-
case 133 /* BooleanKeyword */:
|
|
92876
|
-
return factory.createIdentifier("Boolean");
|
|
92877
|
-
case 198 /* TemplateLiteralType */:
|
|
92878
|
-
case 150 /* StringKeyword */:
|
|
92879
|
-
return factory.createIdentifier("String");
|
|
92880
|
-
case 148 /* ObjectKeyword */:
|
|
92881
|
-
return factory.createIdentifier("Object");
|
|
92882
|
-
case 196 /* LiteralType */:
|
|
92883
|
-
switch (node.literal.kind) {
|
|
92884
|
-
case 10 /* StringLiteral */:
|
|
92885
|
-
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
92886
|
-
return factory.createIdentifier("String");
|
|
92887
|
-
case 219 /* PrefixUnaryExpression */:
|
|
92888
|
-
case 8 /* NumericLiteral */:
|
|
92889
|
-
return factory.createIdentifier("Number");
|
|
92890
|
-
case 9 /* BigIntLiteral */:
|
|
92891
|
-
return getGlobalBigIntNameWithFallback();
|
|
92892
|
-
case 110 /* TrueKeyword */:
|
|
92893
|
-
case 95 /* FalseKeyword */:
|
|
92894
|
-
return factory.createIdentifier("Boolean");
|
|
92895
|
-
case 104 /* NullKeyword */:
|
|
92896
|
-
return factory.createVoidZero();
|
|
92897
|
-
default:
|
|
92898
|
-
return ts.Debug.failBadSyntaxKind(node.literal);
|
|
92899
|
-
}
|
|
92900
|
-
case 147 /* NumberKeyword */:
|
|
92901
|
-
return factory.createIdentifier("Number");
|
|
92902
|
-
case 158 /* BigIntKeyword */:
|
|
92903
|
-
return getGlobalBigIntNameWithFallback();
|
|
92904
|
-
case 151 /* SymbolKeyword */:
|
|
92905
|
-
return languageVersion < 2 /* ES2015 */
|
|
92906
|
-
? getGlobalSymbolNameWithFallback()
|
|
92907
|
-
: factory.createIdentifier("Symbol");
|
|
92908
|
-
case 178 /* TypeReference */:
|
|
92909
|
-
return serializeTypeReferenceNode(node);
|
|
92910
|
-
case 188 /* IntersectionType */:
|
|
92911
|
-
case 187 /* UnionType */:
|
|
92912
|
-
return serializeTypeList(node.types);
|
|
92913
|
-
case 189 /* ConditionalType */:
|
|
92914
|
-
return serializeTypeList([node.trueType, node.falseType]);
|
|
92915
|
-
case 193 /* TypeOperator */:
|
|
92916
|
-
if (node.operator === 145 /* ReadonlyKeyword */) {
|
|
92917
|
-
return serializeTypeNode(node.type);
|
|
92918
|
-
}
|
|
92919
|
-
break;
|
|
92920
|
-
case 181 /* TypeQuery */:
|
|
92921
|
-
case 194 /* IndexedAccessType */:
|
|
92922
|
-
case 195 /* MappedType */:
|
|
92923
|
-
case 182 /* TypeLiteral */:
|
|
92924
|
-
case 130 /* AnyKeyword */:
|
|
92925
|
-
case 155 /* UnknownKeyword */:
|
|
92926
|
-
case 192 /* ThisType */:
|
|
92927
|
-
case 200 /* ImportType */:
|
|
92928
|
-
break;
|
|
92929
|
-
// handle JSDoc types from an invalid parse
|
|
92930
|
-
case 312 /* JSDocAllType */:
|
|
92931
|
-
case 313 /* JSDocUnknownType */:
|
|
92932
|
-
case 317 /* JSDocFunctionType */:
|
|
92933
|
-
case 318 /* JSDocVariadicType */:
|
|
92934
|
-
case 319 /* JSDocNamepathType */:
|
|
92935
|
-
break;
|
|
92936
|
-
case 314 /* JSDocNullableType */:
|
|
92937
|
-
case 315 /* JSDocNonNullableType */:
|
|
92938
|
-
case 316 /* JSDocOptionalType */:
|
|
92939
|
-
return serializeTypeNode(node.type);
|
|
92940
|
-
default:
|
|
92941
|
-
return ts.Debug.failBadSyntaxKind(node);
|
|
92942
|
-
}
|
|
92943
|
-
return factory.createIdentifier("Object");
|
|
92944
|
-
}
|
|
92945
|
-
function serializeTypeList(types) {
|
|
92946
|
-
// Note when updating logic here also update getEntityNameForDecoratorMetadata
|
|
92947
|
-
// so that aliases can be marked as referenced
|
|
92948
|
-
var serializedUnion;
|
|
92949
|
-
for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
|
|
92950
|
-
var typeNode = types_22[_i];
|
|
92951
|
-
while (typeNode.kind === 191 /* ParenthesizedType */) {
|
|
92952
|
-
typeNode = typeNode.type; // Skip parens if need be
|
|
92953
|
-
}
|
|
92954
|
-
if (typeNode.kind === 143 /* NeverKeyword */) {
|
|
92955
|
-
continue; // Always elide `never` from the union/intersection if possible
|
|
92956
|
-
}
|
|
92957
|
-
if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) {
|
|
92958
|
-
continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
|
|
92959
|
-
}
|
|
92960
|
-
var serializedIndividual = serializeTypeNode(typeNode);
|
|
92961
|
-
if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
|
|
92962
|
-
// One of the individual is global object, return immediately
|
|
92963
|
-
return serializedIndividual;
|
|
92964
|
-
}
|
|
92965
|
-
// If there exists union that is not void 0 expression, check if the the common type is identifier.
|
|
92966
|
-
// anything more complex and we will just default to Object
|
|
92967
|
-
else if (serializedUnion) {
|
|
92968
|
-
// Different types
|
|
92969
|
-
if (!ts.isIdentifier(serializedUnion) ||
|
|
92970
|
-
!ts.isIdentifier(serializedIndividual) ||
|
|
92971
|
-
serializedUnion.escapedText !== serializedIndividual.escapedText) {
|
|
92972
|
-
return factory.createIdentifier("Object");
|
|
92973
|
-
}
|
|
92974
|
-
}
|
|
92975
|
-
else {
|
|
92976
|
-
// Initialize the union type
|
|
92977
|
-
serializedUnion = serializedIndividual;
|
|
92978
|
-
}
|
|
92979
|
-
}
|
|
92980
|
-
// If we were able to find common type, use it
|
|
92981
|
-
return serializedUnion || factory.createVoidZero(); // Fallback is only hit if all union constituients are null/undefined/never
|
|
92982
|
-
}
|
|
92983
|
-
/**
|
|
92984
|
-
* Serializes a TypeReferenceNode to an appropriate JS constructor value for use with
|
|
92985
|
-
* decorator type metadata.
|
|
92986
|
-
*
|
|
92987
|
-
* @param node The type reference node.
|
|
92988
|
-
*/
|
|
92989
|
-
function serializeTypeReferenceNode(node) {
|
|
92990
|
-
var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
|
|
92991
|
-
switch (kind) {
|
|
92992
|
-
case ts.TypeReferenceSerializationKind.Unknown:
|
|
92993
|
-
// From conditional type type reference that cannot be resolved is Similar to any or unknown
|
|
92994
|
-
if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
|
|
92995
|
-
return factory.createIdentifier("Object");
|
|
92996
|
-
}
|
|
92997
|
-
var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
|
|
92998
|
-
var temp = factory.createTempVariable(hoistVariableDeclaration);
|
|
92999
|
-
return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"),
|
|
93000
|
-
/*questionToken*/ undefined, temp,
|
|
93001
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"));
|
|
93002
|
-
case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
|
|
93003
|
-
return serializeEntityNameAsExpression(node.typeName);
|
|
93004
|
-
case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
|
|
93005
|
-
return factory.createVoidZero();
|
|
93006
|
-
case ts.TypeReferenceSerializationKind.BigIntLikeType:
|
|
93007
|
-
return getGlobalBigIntNameWithFallback();
|
|
93008
|
-
case ts.TypeReferenceSerializationKind.BooleanType:
|
|
93009
|
-
return factory.createIdentifier("Boolean");
|
|
93010
|
-
case ts.TypeReferenceSerializationKind.NumberLikeType:
|
|
93011
|
-
return factory.createIdentifier("Number");
|
|
93012
|
-
case ts.TypeReferenceSerializationKind.StringLikeType:
|
|
93013
|
-
return factory.createIdentifier("String");
|
|
93014
|
-
case ts.TypeReferenceSerializationKind.ArrayLikeType:
|
|
93015
|
-
return factory.createIdentifier("Array");
|
|
93016
|
-
case ts.TypeReferenceSerializationKind.ESSymbolType:
|
|
93017
|
-
return languageVersion < 2 /* ES2015 */
|
|
93018
|
-
? getGlobalSymbolNameWithFallback()
|
|
93019
|
-
: factory.createIdentifier("Symbol");
|
|
93020
|
-
case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
|
|
93021
|
-
return factory.createIdentifier("Function");
|
|
93022
|
-
case ts.TypeReferenceSerializationKind.Promise:
|
|
93023
|
-
return factory.createIdentifier("Promise");
|
|
93024
|
-
case ts.TypeReferenceSerializationKind.ObjectType:
|
|
93025
|
-
return factory.createIdentifier("Object");
|
|
93026
|
-
default:
|
|
93027
|
-
return ts.Debug.assertNever(kind);
|
|
93028
|
-
}
|
|
93029
|
-
}
|
|
93030
|
-
function createCheckedValue(left, right) {
|
|
93031
|
-
return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
|
|
93032
|
-
}
|
|
93033
|
-
/**
|
|
93034
|
-
* Serializes an entity name which may not exist at runtime, but whose access shouldn't throw
|
|
93035
|
-
*
|
|
93036
|
-
* @param node The entity name to serialize.
|
|
93037
|
-
*/
|
|
93038
|
-
function serializeEntityNameAsExpressionFallback(node) {
|
|
93039
|
-
if (node.kind === 79 /* Identifier */) {
|
|
93040
|
-
// A -> typeof A !== undefined && A
|
|
93041
|
-
var copied = serializeEntityNameAsExpression(node);
|
|
93042
|
-
return createCheckedValue(copied, copied);
|
|
93043
|
-
}
|
|
93044
|
-
if (node.left.kind === 79 /* Identifier */) {
|
|
93045
|
-
// A.B -> typeof A !== undefined && A.B
|
|
93046
|
-
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
|
|
93047
|
-
}
|
|
93048
|
-
// A.B.C -> typeof A !== undefined && (_a = A.B) !== void 0 && _a.C
|
|
93049
|
-
var left = serializeEntityNameAsExpressionFallback(node.left);
|
|
93050
|
-
var temp = factory.createTempVariable(hoistVariableDeclaration);
|
|
93051
|
-
return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
|
|
93052
|
-
}
|
|
93053
|
-
/**
|
|
93054
|
-
* Serializes an entity name as an expression for decorator type metadata.
|
|
93055
|
-
*
|
|
93056
|
-
* @param node The entity name to serialize.
|
|
93057
|
-
*/
|
|
93058
|
-
function serializeEntityNameAsExpression(node) {
|
|
93059
|
-
switch (node.kind) {
|
|
93060
|
-
case 79 /* Identifier */:
|
|
93061
|
-
// Create a clone of the name with a new parent, and treat it as if it were
|
|
93062
|
-
// a source tree node for the purposes of the checker.
|
|
93063
|
-
var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
|
|
93064
|
-
name.original = undefined;
|
|
93065
|
-
ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node.
|
|
93066
|
-
return name;
|
|
93067
|
-
case 161 /* QualifiedName */:
|
|
93068
|
-
return serializeQualifiedNameAsExpression(node);
|
|
93069
|
-
}
|
|
93070
|
-
}
|
|
93071
|
-
/**
|
|
93072
|
-
* Serializes an qualified name as an expression for decorator type metadata.
|
|
93073
|
-
*
|
|
93074
|
-
* @param node The qualified name to serialize.
|
|
93075
|
-
* @param useFallback A value indicating whether to use logical operators to test for the
|
|
93076
|
-
* qualified name at runtime.
|
|
93077
|
-
*/
|
|
93078
|
-
function serializeQualifiedNameAsExpression(node) {
|
|
93079
|
-
return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
|
|
93080
|
-
}
|
|
93081
|
-
/**
|
|
93082
|
-
* Gets an expression that points to the global "Symbol" constructor at runtime if it is
|
|
93083
|
-
* available.
|
|
93084
|
-
*/
|
|
93085
|
-
function getGlobalSymbolNameWithFallback() {
|
|
93086
|
-
return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"),
|
|
93087
|
-
/*questionToken*/ undefined, factory.createIdentifier("Symbol"),
|
|
93088
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"));
|
|
93089
|
-
}
|
|
93090
|
-
/**
|
|
93091
|
-
* Gets an expression that points to the global "BigInt" constructor at runtime if it is
|
|
93092
|
-
* available.
|
|
93093
|
-
*/
|
|
93094
|
-
function getGlobalBigIntNameWithFallback() {
|
|
93095
|
-
return languageVersion < 99 /* ESNext */
|
|
93096
|
-
? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"),
|
|
93097
|
-
/*questionToken*/ undefined, factory.createIdentifier("BigInt"),
|
|
93098
|
-
/*colonToken*/ undefined, factory.createIdentifier("Object"))
|
|
93099
|
-
: factory.createIdentifier("BigInt");
|
|
93100
|
-
}
|
|
93101
92641
|
/**
|
|
93102
92642
|
* Gets an expression that represents a property name (for decorated properties or enums).
|
|
93103
92643
|
* For a computed property, a name is generated for the node.
|
|
@@ -93182,21 +92722,23 @@ var ts;
|
|
|
93182
92722
|
function shouldEmitFunctionLikeDeclaration(node) {
|
|
93183
92723
|
return !ts.nodeIsMissing(node.body);
|
|
93184
92724
|
}
|
|
93185
|
-
function visitPropertyDeclaration(node) {
|
|
93186
|
-
|
|
92725
|
+
function visitPropertyDeclaration(node, parent) {
|
|
92726
|
+
var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */);
|
|
92727
|
+
if (isAmbient && !ts.some(node.decorators)) {
|
|
93187
92728
|
return undefined;
|
|
93188
92729
|
}
|
|
93189
|
-
var
|
|
93190
|
-
|
|
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),
|
|
93191
92740
|
/*questionOrExclamationToken*/ undefined,
|
|
93192
92741
|
/*type*/ undefined, ts.visitNode(node.initializer, visitor));
|
|
93193
|
-
if (updated !== node) {
|
|
93194
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93195
|
-
// we need to emit the comments for the original range.
|
|
93196
|
-
ts.setCommentRange(updated, node);
|
|
93197
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93198
|
-
}
|
|
93199
|
-
return updated;
|
|
93200
92742
|
}
|
|
93201
92743
|
function visitConstructor(node) {
|
|
93202
92744
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
@@ -93204,7 +92746,7 @@ var ts;
|
|
|
93204
92746
|
}
|
|
93205
92747
|
return factory.updateConstructorDeclaration(node,
|
|
93206
92748
|
/*decorators*/ undefined,
|
|
93207
|
-
/*modifiers*/
|
|
92749
|
+
/*modifiers*/ ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
|
|
93208
92750
|
}
|
|
93209
92751
|
function transformConstructorBody(body, constructor) {
|
|
93210
92752
|
var parametersWithPropertyAssignments = constructor &&
|
|
@@ -93268,22 +92810,19 @@ var ts;
|
|
|
93268
92810
|
ts.setEmitFlags(localName, 1536 /* NoComments */);
|
|
93269
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))));
|
|
93270
92812
|
}
|
|
93271
|
-
function visitMethodDeclaration(node) {
|
|
92813
|
+
function visitMethodDeclaration(node, parent) {
|
|
92814
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92815
|
+
return node;
|
|
92816
|
+
}
|
|
93272
92817
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
93273
92818
|
return undefined;
|
|
93274
92819
|
}
|
|
93275
|
-
var
|
|
93276
|
-
|
|
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),
|
|
93277
92823
|
/*questionToken*/ undefined,
|
|
93278
92824
|
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
|
|
93279
92825
|
/*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context));
|
|
93280
|
-
if (updated !== node) {
|
|
93281
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93282
|
-
// we need to emit the comments for the original range.
|
|
93283
|
-
ts.setCommentRange(updated, node);
|
|
93284
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93285
|
-
}
|
|
93286
|
-
return updated;
|
|
93287
92826
|
}
|
|
93288
92827
|
/**
|
|
93289
92828
|
* Determines whether to emit an accessor declaration. We should not emit the
|
|
@@ -93294,34 +92833,30 @@ var ts;
|
|
|
93294
92833
|
function shouldEmitAccessorDeclaration(node) {
|
|
93295
92834
|
return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */));
|
|
93296
92835
|
}
|
|
93297
|
-
function visitGetAccessor(node) {
|
|
92836
|
+
function visitGetAccessor(node, parent) {
|
|
92837
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92838
|
+
return node;
|
|
92839
|
+
}
|
|
93298
92840
|
if (!shouldEmitAccessorDeclaration(node)) {
|
|
93299
92841
|
return undefined;
|
|
93300
92842
|
}
|
|
93301
|
-
var
|
|
93302
|
-
|
|
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),
|
|
93303
92847
|
/*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([]));
|
|
93304
|
-
if (updated !== node) {
|
|
93305
|
-
// While we emit the source map for the node after skipping decorators and modifiers,
|
|
93306
|
-
// we need to emit the comments for the original range.
|
|
93307
|
-
ts.setCommentRange(updated, node);
|
|
93308
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93309
|
-
}
|
|
93310
|
-
return updated;
|
|
93311
92848
|
}
|
|
93312
|
-
function visitSetAccessor(node) {
|
|
92849
|
+
function visitSetAccessor(node, parent) {
|
|
92850
|
+
if (!(node.transformFlags & 1 /* ContainsTypeScript */)) {
|
|
92851
|
+
return node;
|
|
92852
|
+
}
|
|
93313
92853
|
if (!shouldEmitAccessorDeclaration(node)) {
|
|
93314
92854
|
return undefined;
|
|
93315
92855
|
}
|
|
93316
|
-
var
|
|
93317
|
-
|
|
93318
|
-
|
|
93319
|
-
|
|
93320
|
-
// we need to emit the comments for the original range.
|
|
93321
|
-
ts.setCommentRange(updated, node);
|
|
93322
|
-
ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
|
|
93323
|
-
}
|
|
93324
|
-
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([]));
|
|
93325
92860
|
}
|
|
93326
92861
|
function visitFunctionDeclaration(node) {
|
|
93327
92862
|
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
|
@@ -93357,9 +92892,9 @@ var ts;
|
|
|
93357
92892
|
if (ts.parameterIsThisKeyword(node)) {
|
|
93358
92893
|
return undefined;
|
|
93359
92894
|
}
|
|
93360
|
-
var updated = factory.updateParameterDeclaration(node,
|
|
93361
|
-
|
|
93362
|
-
|
|
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),
|
|
93363
92898
|
/*questionToken*/ undefined,
|
|
93364
92899
|
/*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
|
|
93365
92900
|
if (updated !== node) {
|
|
@@ -94055,12 +93590,6 @@ var ts;
|
|
|
94055
93590
|
return isExternalModuleExport(node)
|
|
94056
93591
|
&& ts.hasSyntacticModifier(node, 512 /* Default */);
|
|
94057
93592
|
}
|
|
94058
|
-
/**
|
|
94059
|
-
* Creates a statement for the provided expression. This is used in calls to `map`.
|
|
94060
|
-
*/
|
|
94061
|
-
function expressionToStatement(expression) {
|
|
94062
|
-
return factory.createExpressionStatement(expression);
|
|
94063
|
-
}
|
|
94064
93593
|
function addExportMemberAssignment(statements, node) {
|
|
94065
93594
|
var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node));
|
|
94066
93595
|
ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
|
|
@@ -94092,44 +93621,12 @@ var ts;
|
|
|
94092
93621
|
function getNamespaceContainerName(node) {
|
|
94093
93622
|
return factory.getGeneratedNameForNode(node);
|
|
94094
93623
|
}
|
|
94095
|
-
/**
|
|
94096
|
-
* Gets a local alias for a class declaration if it is a decorated class with an internal
|
|
94097
|
-
* reference to the static side of the class. This is necessary to avoid issues with
|
|
94098
|
-
* double-binding semantics for the class name.
|
|
94099
|
-
*/
|
|
94100
|
-
function getClassAliasIfNeeded(node) {
|
|
94101
|
-
if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) {
|
|
94102
|
-
enableSubstitutionForClassAliases();
|
|
94103
|
-
var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
|
|
94104
|
-
classAliases[ts.getOriginalNodeId(node)] = classAlias;
|
|
94105
|
-
hoistVariableDeclaration(classAlias);
|
|
94106
|
-
return classAlias;
|
|
94107
|
-
}
|
|
94108
|
-
}
|
|
94109
|
-
function getClassPrototype(node) {
|
|
94110
|
-
return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
|
|
94111
|
-
}
|
|
94112
|
-
function getClassMemberPrefix(node, member) {
|
|
94113
|
-
return ts.isStatic(member)
|
|
94114
|
-
? factory.getDeclarationName(node)
|
|
94115
|
-
: getClassPrototype(node);
|
|
94116
|
-
}
|
|
94117
93624
|
function enableSubstitutionForNonQualifiedEnumMembers() {
|
|
94118
93625
|
if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) {
|
|
94119
93626
|
enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */;
|
|
94120
93627
|
context.enableSubstitution(79 /* Identifier */);
|
|
94121
93628
|
}
|
|
94122
93629
|
}
|
|
94123
|
-
function enableSubstitutionForClassAliases() {
|
|
94124
|
-
if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) {
|
|
94125
|
-
enabledSubstitutions |= 1 /* ClassAliases */;
|
|
94126
|
-
// We need to enable substitutions for identifiers. This allows us to
|
|
94127
|
-
// substitute class names inside of a class declaration.
|
|
94128
|
-
context.enableSubstitution(79 /* Identifier */);
|
|
94129
|
-
// Keep track of class aliases.
|
|
94130
|
-
classAliases = [];
|
|
94131
|
-
}
|
|
94132
|
-
}
|
|
94133
93630
|
function enableSubstitutionForNamespaceExports() {
|
|
94134
93631
|
if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) {
|
|
94135
93632
|
enabledSubstitutions |= 2 /* NamespaceExports */;
|
|
@@ -94214,32 +93711,9 @@ var ts;
|
|
|
94214
93711
|
return node;
|
|
94215
93712
|
}
|
|
94216
93713
|
function substituteExpressionIdentifier(node) {
|
|
94217
|
-
return
|
|
94218
|
-
|| trySubstituteNamespaceExportedName(node)
|
|
93714
|
+
return trySubstituteNamespaceExportedName(node)
|
|
94219
93715
|
|| node;
|
|
94220
93716
|
}
|
|
94221
|
-
function trySubstituteClassAlias(node) {
|
|
94222
|
-
if (enabledSubstitutions & 1 /* ClassAliases */) {
|
|
94223
|
-
if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) {
|
|
94224
|
-
// Due to the emit for class decorators, any reference to the class from inside of the class body
|
|
94225
|
-
// must instead be rewritten to point to a temporary variable to avoid issues with the double-bind
|
|
94226
|
-
// behavior of class names in ES6.
|
|
94227
|
-
// Also, when emitting statics for class expressions, we must substitute a class alias for
|
|
94228
|
-
// constructor references in static property initializers.
|
|
94229
|
-
var declaration = resolver.getReferencedValueDeclaration(node);
|
|
94230
|
-
if (declaration) {
|
|
94231
|
-
var classAlias = classAliases[declaration.id]; // TODO: GH#18217
|
|
94232
|
-
if (classAlias) {
|
|
94233
|
-
var clone_2 = factory.cloneNode(classAlias);
|
|
94234
|
-
ts.setSourceMapRange(clone_2, node);
|
|
94235
|
-
ts.setCommentRange(clone_2, node);
|
|
94236
|
-
return clone_2;
|
|
94237
|
-
}
|
|
94238
|
-
}
|
|
94239
|
-
}
|
|
94240
|
-
}
|
|
94241
|
-
return undefined;
|
|
94242
|
-
}
|
|
94243
93717
|
function trySubstituteNamespaceExportedName(node) {
|
|
94244
93718
|
// If this is explicitly a local name, do not substitute.
|
|
94245
93719
|
if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
|
|
@@ -94377,7 +93851,7 @@ var ts;
|
|
|
94377
93851
|
return visited;
|
|
94378
93852
|
}
|
|
94379
93853
|
function visitorWorker(node, valueIsDiscarded) {
|
|
94380
|
-
if (node.transformFlags &
|
|
93854
|
+
if (node.transformFlags & 16777216 /* ContainsClassFields */) {
|
|
94381
93855
|
switch (node.kind) {
|
|
94382
93856
|
case 226 /* ClassExpression */:
|
|
94383
93857
|
case 257 /* ClassDeclaration */:
|
|
@@ -94392,8 +93866,8 @@ var ts;
|
|
|
94392
93866
|
return visitClassStaticBlockDeclaration(node);
|
|
94393
93867
|
}
|
|
94394
93868
|
}
|
|
94395
|
-
if (node.transformFlags &
|
|
94396
|
-
node.transformFlags &
|
|
93869
|
+
if (node.transformFlags & 16777216 /* ContainsClassFields */ ||
|
|
93870
|
+
node.transformFlags & 134217728 /* ContainsLexicalSuper */ &&
|
|
94397
93871
|
shouldTransformSuperInStaticInitializers &&
|
|
94398
93872
|
currentStaticPropertyDeclarationOrStaticBlock &&
|
|
94399
93873
|
currentClassLexicalEnvironment) {
|
|
@@ -94967,13 +94441,13 @@ var ts;
|
|
|
94967
94441
|
facts |= 2 /* NeedsClassConstructorReference */;
|
|
94968
94442
|
}
|
|
94969
94443
|
if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) {
|
|
94970
|
-
if (shouldTransformThisInStaticInitializers && member.transformFlags &
|
|
94444
|
+
if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) {
|
|
94971
94445
|
facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */;
|
|
94972
94446
|
if (!(facts & 1 /* ClassWasDecorated */)) {
|
|
94973
94447
|
facts |= 2 /* NeedsClassConstructorReference */;
|
|
94974
94448
|
}
|
|
94975
94449
|
}
|
|
94976
|
-
if (shouldTransformSuperInStaticInitializers && member.transformFlags &
|
|
94450
|
+
if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) {
|
|
94977
94451
|
if (!(facts & 1 /* ClassWasDecorated */)) {
|
|
94978
94452
|
facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */;
|
|
94979
94453
|
}
|
|
@@ -95558,10 +95032,10 @@ var ts;
|
|
|
95558
95032
|
if (declaration) {
|
|
95559
95033
|
var classAlias = classAliases[declaration.id]; // TODO: GH#18217
|
|
95560
95034
|
if (classAlias) {
|
|
95561
|
-
var
|
|
95562
|
-
ts.setSourceMapRange(
|
|
95563
|
-
ts.setCommentRange(
|
|
95564
|
-
return
|
|
95035
|
+
var clone_2 = factory.cloneNode(classAlias);
|
|
95036
|
+
ts.setSourceMapRange(clone_2, node);
|
|
95037
|
+
ts.setCommentRange(clone_2, node);
|
|
95038
|
+
return clone_2;
|
|
95565
95039
|
}
|
|
95566
95040
|
}
|
|
95567
95041
|
}
|
|
@@ -95923,6 +95397,965 @@ var ts;
|
|
|
95923
95397
|
})(ts || (ts = {}));
|
|
95924
95398
|
/*@internal*/
|
|
95925
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;
|
|
95926
96359
|
(function (ts) {
|
|
95927
96360
|
var ES2017SubstitutionFlags;
|
|
95928
96361
|
(function (ES2017SubstitutionFlags) {
|
|
@@ -96771,7 +97204,7 @@ var ts;
|
|
|
96771
97204
|
return objects;
|
|
96772
97205
|
}
|
|
96773
97206
|
function visitObjectLiteralExpression(node) {
|
|
96774
|
-
if (node.transformFlags &
|
|
97207
|
+
if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96775
97208
|
// spread elements emit like so:
|
|
96776
97209
|
// non-spread elements are chunked together into object literals, and then all are passed to __assign:
|
|
96777
97210
|
// { a, ...o, b } => __assign(__assign({a}, o), {b});
|
|
@@ -96844,7 +97277,7 @@ var ts;
|
|
|
96844
97277
|
* expression of an `ExpressionStatement`).
|
|
96845
97278
|
*/
|
|
96846
97279
|
function visitBinaryExpression(node, expressionResultIsUnused) {
|
|
96847
|
-
if (ts.isDestructuringAssignment(node) && node.left.transformFlags &
|
|
97280
|
+
if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96848
97281
|
return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused);
|
|
96849
97282
|
}
|
|
96850
97283
|
if (node.operatorToken.kind === 27 /* CommaToken */) {
|
|
@@ -96875,7 +97308,7 @@ var ts;
|
|
|
96875
97308
|
function visitCatchClause(node) {
|
|
96876
97309
|
if (node.variableDeclaration &&
|
|
96877
97310
|
ts.isBindingPattern(node.variableDeclaration.name) &&
|
|
96878
|
-
node.variableDeclaration.name.transformFlags &
|
|
97311
|
+
node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96879
97312
|
var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
|
|
96880
97313
|
var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name);
|
|
96881
97314
|
var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */);
|
|
@@ -96916,7 +97349,7 @@ var ts;
|
|
|
96916
97349
|
}
|
|
96917
97350
|
function visitVariableDeclarationWorker(node, exportedVariableStatement) {
|
|
96918
97351
|
// If we are here it is because the name contains a binding pattern with a rest somewhere in it.
|
|
96919
|
-
if (ts.isBindingPattern(node.name) && node.name.transformFlags &
|
|
97352
|
+
if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96920
97353
|
return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */,
|
|
96921
97354
|
/*rval*/ undefined, exportedVariableStatement);
|
|
96922
97355
|
}
|
|
@@ -96935,7 +97368,7 @@ var ts;
|
|
|
96935
97368
|
*/
|
|
96936
97369
|
function visitForOfStatement(node, outermostLabeledStatement) {
|
|
96937
97370
|
var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */);
|
|
96938
|
-
if (node.initializer.transformFlags &
|
|
97371
|
+
if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
96939
97372
|
node = transformForOfStatementWithObjectRest(node);
|
|
96940
97373
|
}
|
|
96941
97374
|
var result = node.awaitModifier ?
|
|
@@ -97048,7 +97481,7 @@ var ts;
|
|
|
97048
97481
|
/*type*/ undefined,
|
|
97049
97482
|
/*initializer*/ undefined);
|
|
97050
97483
|
}
|
|
97051
|
-
if (node.transformFlags &
|
|
97484
|
+
if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97052
97485
|
// Binding patterns are converted into a generated name and are
|
|
97053
97486
|
// evaluated inside the function body.
|
|
97054
97487
|
return factory.updateParameterDeclaration(node,
|
|
@@ -97066,7 +97499,7 @@ var ts;
|
|
|
97066
97499
|
if (parameters) {
|
|
97067
97500
|
parameters.add(parameter);
|
|
97068
97501
|
}
|
|
97069
|
-
else if (parameter.transformFlags &
|
|
97502
|
+
else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97070
97503
|
parameters = new ts.Set();
|
|
97071
97504
|
}
|
|
97072
97505
|
}
|
|
@@ -97289,7 +97722,7 @@ var ts;
|
|
|
97289
97722
|
statements = ts.append(statements, statement);
|
|
97290
97723
|
}
|
|
97291
97724
|
}
|
|
97292
|
-
else if (parameter.transformFlags &
|
|
97725
|
+
else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) {
|
|
97293
97726
|
containsPrecedingObjectRestOrSpread = true;
|
|
97294
97727
|
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
|
|
97295
97728
|
/*doNotRecordTempVariablesInLine*/ false,
|
|
@@ -98661,7 +99094,7 @@ var ts;
|
|
|
98661
99094
|
&& !node.expression;
|
|
98662
99095
|
}
|
|
98663
99096
|
function isOrMayContainReturnCompletion(node) {
|
|
98664
|
-
return node.transformFlags &
|
|
99097
|
+
return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */
|
|
98665
99098
|
&& (ts.isReturnStatement(node)
|
|
98666
99099
|
|| ts.isIfStatement(node)
|
|
98667
99100
|
|| ts.isWithStatement(node)
|
|
@@ -99225,7 +99658,7 @@ var ts;
|
|
|
99225
99658
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
99226
99659
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
99227
99660
|
if (isDerivedClass || superCallExpression) {
|
|
99228
|
-
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags &
|
|
99661
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) {
|
|
99229
99662
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
99230
99663
|
// following representation:
|
|
99231
99664
|
//
|
|
@@ -99770,7 +100203,7 @@ var ts;
|
|
|
99770
100203
|
* @param node An ArrowFunction node.
|
|
99771
100204
|
*/
|
|
99772
100205
|
function visitArrowFunction(node) {
|
|
99773
|
-
if (node.transformFlags &
|
|
100206
|
+
if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) {
|
|
99774
100207
|
hierarchyFacts |= 65536 /* CapturedLexicalThis */;
|
|
99775
100208
|
}
|
|
99776
100209
|
var savedConvertedLoopState = convertedLoopState;
|
|
@@ -100056,7 +100489,7 @@ var ts;
|
|
|
100056
100489
|
* @param node A VariableDeclarationList node.
|
|
100057
100490
|
*/
|
|
100058
100491
|
function visitVariableDeclarationList(node) {
|
|
100059
|
-
if (node.flags & 3 /* BlockScoped */ || node.transformFlags &
|
|
100492
|
+
if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) {
|
|
100060
100493
|
if (node.flags & 3 /* BlockScoped */) {
|
|
100061
100494
|
enableSubstitutionsForBlockScopedBindings();
|
|
100062
100495
|
}
|
|
@@ -100069,7 +100502,7 @@ var ts;
|
|
|
100069
100502
|
ts.setCommentRange(declarationList, node);
|
|
100070
100503
|
// If the first or last declaration is a binding pattern, we need to modify
|
|
100071
100504
|
// the source map range for the declaration list.
|
|
100072
|
-
if (node.transformFlags &
|
|
100505
|
+
if (node.transformFlags & 524288 /* ContainsBindingPattern */
|
|
100073
100506
|
&& (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
|
|
100074
100507
|
ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
|
|
100075
100508
|
}
|
|
@@ -100393,7 +100826,7 @@ var ts;
|
|
|
100393
100826
|
var numInitialProperties = -1, hasComputed = false;
|
|
100394
100827
|
for (var i = 0; i < properties.length; i++) {
|
|
100395
100828
|
var property = properties[i];
|
|
100396
|
-
if ((property.transformFlags &
|
|
100829
|
+
if ((property.transformFlags & 1048576 /* ContainsYield */ &&
|
|
100397
100830
|
hierarchyFacts & 4 /* AsyncFunctionBody */)
|
|
100398
100831
|
|| (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) {
|
|
100399
100832
|
numInitialProperties = i;
|
|
@@ -100666,7 +101099,7 @@ var ts;
|
|
|
100666
101099
|
*/
|
|
100667
101100
|
function createFunctionForInitializerOfForStatement(node, currentState) {
|
|
100668
101101
|
var functionName = factory.createUniqueName("_loop_init");
|
|
100669
|
-
var containsYield = (node.initializer.transformFlags &
|
|
101102
|
+
var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
100670
101103
|
var emitFlags = 0 /* None */;
|
|
100671
101104
|
if (currentState.containsLexicalThis)
|
|
100672
101105
|
emitFlags |= 8 /* CapturesThis */;
|
|
@@ -100781,7 +101214,7 @@ var ts;
|
|
|
100781
101214
|
var loopBody = factory.createBlock(statements, /*multiLine*/ true);
|
|
100782
101215
|
if (ts.isBlock(statement))
|
|
100783
101216
|
ts.setOriginalNode(loopBody, statement);
|
|
100784
|
-
var containsYield = (node.statement.transformFlags &
|
|
101217
|
+
var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
100785
101218
|
var emitFlags = 524288 /* ReuseTempVariableScope */;
|
|
100786
101219
|
if (currentState.containsLexicalThis)
|
|
100787
101220
|
emitFlags |= 8 /* CapturesThis */;
|
|
@@ -101263,7 +101696,7 @@ var ts;
|
|
|
101263
101696
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
101264
101697
|
// We are here either because SuperKeyword was used somewhere in the expression, or
|
|
101265
101698
|
// because we contain a SpreadElementExpression.
|
|
101266
|
-
if (node.transformFlags &
|
|
101699
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */ ||
|
|
101267
101700
|
node.expression.kind === 106 /* SuperKeyword */ ||
|
|
101268
101701
|
ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
|
|
101269
101702
|
var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
|
|
@@ -101271,7 +101704,7 @@ var ts;
|
|
|
101271
101704
|
ts.setEmitFlags(thisArg, 4 /* NoSubstitution */);
|
|
101272
101705
|
}
|
|
101273
101706
|
var resultingCall = void 0;
|
|
101274
|
-
if (node.transformFlags &
|
|
101707
|
+
if (node.transformFlags & 32768 /* ContainsRestOrSpread */) {
|
|
101275
101708
|
// [source]
|
|
101276
101709
|
// f(...a, b)
|
|
101277
101710
|
// x.m(...a, b)
|
|
@@ -102113,10 +102546,10 @@ var ts;
|
|
|
102113
102546
|
case 247 /* ReturnStatement */:
|
|
102114
102547
|
return visitReturnStatement(node);
|
|
102115
102548
|
default:
|
|
102116
|
-
if (node.transformFlags &
|
|
102549
|
+
if (node.transformFlags & 1048576 /* ContainsYield */) {
|
|
102117
102550
|
return visitJavaScriptContainingYield(node);
|
|
102118
102551
|
}
|
|
102119
|
-
else if (node.transformFlags & (2048 /* ContainsGenerator */ |
|
|
102552
|
+
else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) {
|
|
102120
102553
|
return ts.visitEachChild(node, visitor, context);
|
|
102121
102554
|
}
|
|
102122
102555
|
else {
|
|
@@ -102321,7 +102754,7 @@ var ts;
|
|
|
102321
102754
|
* @param node The node to visit.
|
|
102322
102755
|
*/
|
|
102323
102756
|
function visitVariableStatement(node) {
|
|
102324
|
-
if (node.transformFlags &
|
|
102757
|
+
if (node.transformFlags & 1048576 /* ContainsYield */) {
|
|
102325
102758
|
transformAndEmitVariableDeclarationList(node.declarationList);
|
|
102326
102759
|
return undefined;
|
|
102327
102760
|
}
|
|
@@ -103379,7 +103812,7 @@ var ts;
|
|
|
103379
103812
|
}
|
|
103380
103813
|
}
|
|
103381
103814
|
function containsYield(node) {
|
|
103382
|
-
return !!node && (node.transformFlags &
|
|
103815
|
+
return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0;
|
|
103383
103816
|
}
|
|
103384
103817
|
function countInitialNodesWithoutYield(nodes) {
|
|
103385
103818
|
var numNodes = nodes.length;
|
|
@@ -104428,7 +104861,7 @@ var ts;
|
|
|
104428
104861
|
function transformSourceFile(node) {
|
|
104429
104862
|
if (node.isDeclarationFile ||
|
|
104430
104863
|
!(ts.isEffectiveExternalModule(node, compilerOptions) ||
|
|
104431
|
-
node.transformFlags &
|
|
104864
|
+
node.transformFlags & 8388608 /* ContainsDynamicImport */ ||
|
|
104432
104865
|
(ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
|
|
104433
104866
|
return node;
|
|
104434
104867
|
}
|
|
@@ -104765,7 +105198,7 @@ var ts;
|
|
|
104765
105198
|
function visitorWorker(node, valueIsDiscarded) {
|
|
104766
105199
|
// This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression
|
|
104767
105200
|
// as export/import statements are only transformed at the top level of a file.
|
|
104768
|
-
if (!(node.transformFlags & (
|
|
105201
|
+
if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
|
|
104769
105202
|
return node;
|
|
104770
105203
|
}
|
|
104771
105204
|
switch (node.kind) {
|
|
@@ -104916,7 +105349,7 @@ var ts;
|
|
|
104916
105349
|
var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor);
|
|
104917
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.
|
|
104918
105351
|
var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
|
|
104919
|
-
var containsLexicalThis = !!(node.transformFlags &
|
|
105352
|
+
var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */);
|
|
104920
105353
|
switch (compilerOptions.module) {
|
|
104921
105354
|
case ts.ModuleKind.AMD:
|
|
104922
105355
|
return createImportCallExpressionAMD(argument, containsLexicalThis);
|
|
@@ -105903,7 +106336,7 @@ var ts;
|
|
|
105903
106336
|
* @param node The SourceFile node.
|
|
105904
106337
|
*/
|
|
105905
106338
|
function transformSourceFile(node) {
|
|
105906
|
-
if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags &
|
|
106339
|
+
if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) {
|
|
105907
106340
|
return node;
|
|
105908
106341
|
}
|
|
105909
106342
|
var id = ts.getOriginalNodeId(node);
|
|
@@ -106072,7 +106505,7 @@ var ts;
|
|
|
106072
106505
|
// - Temporary variables will appear at the top rather than at the bottom of the file
|
|
106073
106506
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
106074
106507
|
var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217
|
|
106075
|
-
var modifiers = node.transformFlags &
|
|
106508
|
+
var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ?
|
|
106076
106509
|
factory.createModifiersFromModifierFlags(256 /* Async */) :
|
|
106077
106510
|
undefined;
|
|
106078
106511
|
var moduleObject = factory.createObjectLiteralExpression([
|
|
@@ -106981,7 +107414,7 @@ var ts;
|
|
|
106981
107414
|
* @param node The node to visit.
|
|
106982
107415
|
*/
|
|
106983
107416
|
function visitorWorker(node, valueIsDiscarded) {
|
|
106984
|
-
if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ |
|
|
107417
|
+
if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) {
|
|
106985
107418
|
return node;
|
|
106986
107419
|
}
|
|
106987
107420
|
switch (node.kind) {
|
|
@@ -108149,7 +108582,8 @@ var ts;
|
|
|
108149
108582
|
trackReferencedAmbientModule: trackReferencedAmbientModule,
|
|
108150
108583
|
trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
|
|
108151
108584
|
reportNonlocalAugmentation: reportNonlocalAugmentation,
|
|
108152
|
-
reportNonSerializableProperty: reportNonSerializableProperty
|
|
108585
|
+
reportNonSerializableProperty: reportNonSerializableProperty,
|
|
108586
|
+
reportImportTypeNodeResolutionModeOverride: reportImportTypeNodeResolutionModeOverride,
|
|
108153
108587
|
};
|
|
108154
108588
|
var errorNameNode;
|
|
108155
108589
|
var errorFallbackNode;
|
|
@@ -108276,6 +108710,11 @@ var ts;
|
|
|
108276
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));
|
|
108277
108711
|
}
|
|
108278
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
|
+
}
|
|
108279
108718
|
function transformDeclarationsForJS(sourceFile, bundled) {
|
|
108280
108719
|
var oldDiag = getSymbolAccessibilityDiagnostic;
|
|
108281
108720
|
getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
|
|
@@ -108726,7 +109165,7 @@ var ts;
|
|
|
108726
109165
|
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108727
109166
|
if (mode !== undefined) {
|
|
108728
109167
|
if (!ts.isNightly()) {
|
|
108729
|
-
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.
|
|
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));
|
|
108730
109169
|
}
|
|
108731
109170
|
return assertClause;
|
|
108732
109171
|
}
|
|
@@ -109518,6 +109957,7 @@ var ts;
|
|
|
109518
109957
|
var transformers = [];
|
|
109519
109958
|
ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
|
|
109520
109959
|
transformers.push(ts.transformTypeScript);
|
|
109960
|
+
transformers.push(ts.transformLegacyDecorators);
|
|
109521
109961
|
transformers.push(ts.transformClassFields);
|
|
109522
109962
|
if (ts.getJSXTransformEnabled(compilerOptions)) {
|
|
109523
109963
|
transformers.push(ts.transformJsx);
|
|
@@ -116235,12 +116675,14 @@ var ts;
|
|
|
116235
116675
|
}
|
|
116236
116676
|
ts.loadWithTypeDirectiveCache = loadWithTypeDirectiveCache;
|
|
116237
116677
|
;
|
|
116238
|
-
|
|
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
|
+
*/
|
|
116239
116682
|
function getModeForFileReference(ref, containingFileMode) {
|
|
116240
116683
|
return (ts.isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
116241
116684
|
}
|
|
116242
116685
|
ts.getModeForFileReference = getModeForFileReference;
|
|
116243
|
-
/* @internal */
|
|
116244
116686
|
function getModeForResolutionAtIndex(file, index) {
|
|
116245
116687
|
if (file.impliedNodeFormat === undefined)
|
|
116246
116688
|
return undefined;
|
|
@@ -116261,7 +116703,15 @@ var ts;
|
|
|
116261
116703
|
return false;
|
|
116262
116704
|
}
|
|
116263
116705
|
ts.isExclusivelyTypeOnlyImportOrExport = isExclusivelyTypeOnlyImportOrExport;
|
|
116264
|
-
|
|
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
|
+
*/
|
|
116265
116715
|
function getModeForUsageLocation(file, usage) {
|
|
116266
116716
|
var _a, _b;
|
|
116267
116717
|
if (file.impliedNodeFormat === undefined)
|
|
@@ -118497,7 +118947,7 @@ var ts;
|
|
|
118497
118947
|
ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
|
|
118498
118948
|
var mode = ref.resolutionMode || file.impliedNodeFormat;
|
|
118499
118949
|
if (mode && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118500
|
-
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.
|
|
118950
|
+
programDiagnostics.add(ts.createDiagnosticForRange(file, ref, ts.Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext));
|
|
118501
118951
|
}
|
|
118502
118952
|
processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
|
|
118503
118953
|
}
|
|
@@ -167412,7 +167862,7 @@ var ts;
|
|
|
167412
167862
|
if (_this.safeList === undefined) {
|
|
167413
167863
|
_this.safeList = ts.JsTyping.loadSafeList(_this.host, ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName));
|
|
167414
167864
|
}
|
|
167415
|
-
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);
|
|
167416
167866
|
});
|
|
167417
167867
|
};
|
|
167418
167868
|
return CoreServicesShimObject;
|
|
@@ -167681,7 +168131,7 @@ var ts;
|
|
|
167681
168131
|
* @param typeAcquisition is used to customize the typing acquisition process
|
|
167682
168132
|
* @param compilerOptions are used as a source for typing inference
|
|
167683
168133
|
*/
|
|
167684
|
-
function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry) {
|
|
168134
|
+
function discoverTypings(host, log, fileNames, projectRootPath, safeList, packageNameToTypingLocation, typeAcquisition, unresolvedImports, typesRegistry, compilerOptions) {
|
|
167685
168135
|
if (!typeAcquisition || !typeAcquisition.enable) {
|
|
167686
168136
|
return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] };
|
|
167687
168137
|
}
|
|
@@ -167699,12 +168149,14 @@ var ts;
|
|
|
167699
168149
|
addInferredTypings(typeAcquisition.include, "Explicitly included types");
|
|
167700
168150
|
var exclude = typeAcquisition.exclude || [];
|
|
167701
168151
|
// Directories to search for package.json, bower.json and other typing information
|
|
167702
|
-
|
|
167703
|
-
|
|
167704
|
-
|
|
167705
|
-
|
|
167706
|
-
|
|
167707
|
-
|
|
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
|
+
}
|
|
167708
168160
|
if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
|
|
167709
168161
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
167710
168162
|
}
|