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