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