@typescript-deploys/pr-build 4.5.0-pr-45884-7 → 4.5.0-pr-46071-13
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/cs/diagnosticMessages.generated.json +24 -7
- package/lib/de/diagnosticMessages.generated.json +24 -7
- package/lib/es/diagnosticMessages.generated.json +24 -7
- package/lib/fr/diagnosticMessages.generated.json +24 -7
- package/lib/it/diagnosticMessages.generated.json +24 -7
- package/lib/ja/diagnosticMessages.generated.json +24 -7
- package/lib/ko/diagnosticMessages.generated.json +24 -7
- package/lib/lib.dom.d.ts +669 -1896
- package/lib/lib.dom.iterable.d.ts +16 -48
- package/lib/lib.es2021.d.ts +1 -0
- package/lib/lib.es2021.intl.d.ts +9 -0
- package/lib/lib.es5.d.ts +10 -10
- package/lib/lib.webworker.d.ts +183 -520
- package/lib/lib.webworker.iterable.d.ts +10 -30
- package/lib/pl/diagnosticMessages.generated.json +24 -7
- package/lib/protocol.d.ts +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +24 -7
- package/lib/ru/diagnosticMessages.generated.json +24 -7
- package/lib/tr/diagnosticMessages.generated.json +24 -7
- package/lib/tsc.js +841 -439
- package/lib/tsserver.js +1457 -661
- package/lib/tsserverlibrary.d.ts +14 -9
- package/lib/tsserverlibrary.js +1457 -661
- package/lib/typescript.d.ts +13 -9
- package/lib/typescript.js +1457 -661
- package/lib/typescriptServices.d.ts +13 -9
- package/lib/typescriptServices.js +1457 -661
- package/lib/typingsInstaller.js +965 -462
- package/lib/zh-cn/diagnosticMessages.generated.json +24 -7
- package/lib/zh-tw/diagnosticMessages.generated.json +24 -7
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20211001";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -4723,6 +4723,7 @@ var ts;
|
|
|
4723
4723
|
CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType";
|
|
4724
4724
|
CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped";
|
|
4725
4725
|
CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional";
|
|
4726
|
+
CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved";
|
|
4726
4727
|
CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
|
|
4727
4728
|
CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant";
|
|
4728
4729
|
CheckFlags[CheckFlags["Partial"] = 48] = "Partial";
|
|
@@ -4854,7 +4855,7 @@ var ts;
|
|
|
4854
4855
|
TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
|
|
4855
4856
|
// The following flags are used for different purposes during union and intersection type construction
|
|
4856
4857
|
/* @internal */
|
|
4857
|
-
TypeFlags[TypeFlags["
|
|
4858
|
+
TypeFlags[TypeFlags["IncludesMissingType"] = 262144] = "IncludesMissingType";
|
|
4858
4859
|
/* @internal */
|
|
4859
4860
|
TypeFlags[TypeFlags["IncludesNonWideningType"] = 4194304] = "IncludesNonWideningType";
|
|
4860
4861
|
/* @internal */
|
|
@@ -5142,6 +5143,7 @@ var ts;
|
|
|
5142
5143
|
// module kind).
|
|
5143
5144
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5144
5145
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5146
|
+
ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022";
|
|
5145
5147
|
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
|
|
5146
5148
|
// Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
|
|
5147
5149
|
ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
|
|
@@ -5497,9 +5499,10 @@ var ts;
|
|
|
5497
5499
|
ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 262144] = "MakeTemplateObject";
|
|
5498
5500
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 524288] = "ClassPrivateFieldGet";
|
|
5499
5501
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 1048576] = "ClassPrivateFieldSet";
|
|
5500
|
-
ExternalEmitHelpers[ExternalEmitHelpers["
|
|
5502
|
+
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldIn"] = 2097152] = "ClassPrivateFieldIn";
|
|
5503
|
+
ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 4194304] = "CreateBinding";
|
|
5501
5504
|
ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper";
|
|
5502
|
-
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] =
|
|
5505
|
+
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 4194304] = "LastEmitHelper";
|
|
5503
5506
|
// Helpers included by ES2015 for..of
|
|
5504
5507
|
ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes";
|
|
5505
5508
|
// Helpers included by ES2017 for..await..of
|
|
@@ -8058,7 +8061,7 @@ var ts;
|
|
|
8058
8061
|
Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
8059
8062
|
Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."),
|
|
8060
8063
|
Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."),
|
|
8061
|
-
|
|
8064
|
+
Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
|
|
8062
8065
|
Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."),
|
|
8063
8066
|
Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
|
|
8064
8067
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
@@ -8076,7 +8079,7 @@ var ts;
|
|
|
8076
8079
|
Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."),
|
|
8077
8080
|
Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"),
|
|
8078
8081
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
8079
|
-
|
|
8082
|
+
The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."),
|
|
8080
8083
|
A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
|
|
8081
8084
|
An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."),
|
|
8082
8085
|
This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."),
|
|
@@ -8107,7 +8110,7 @@ var ts;
|
|
|
8107
8110
|
await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
8108
8111
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8109
8112
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8110
|
-
|
|
8113
|
+
Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8111
8114
|
An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."),
|
|
8112
8115
|
An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."),
|
|
8113
8116
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
@@ -8159,7 +8162,7 @@ var ts;
|
|
|
8159
8162
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8160
8163
|
The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
|
|
8161
8164
|
for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module: diag(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module."),
|
|
8162
|
-
|
|
8165
|
+
Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8163
8166
|
Decorators_may_not_be_applied_to_this_parameters: diag(1433, ts.DiagnosticCategory.Error, "Decorators_may_not_be_applied_to_this_parameters_1433", "Decorators may not be applied to 'this' parameters."),
|
|
8164
8167
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8165
8168
|
Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, ts.DiagnosticCategory.Error, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
|
|
@@ -8176,14 +8179,17 @@ var ts;
|
|
|
8176
8179
|
_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isolatedModules_is_enabled: diag(1448, ts.DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isol_1448", "'{0}' resolves to a type-only declaration and must be re-exported using a type-only re-export when 'isolatedModules' is enabled."),
|
|
8177
8180
|
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."),
|
|
8178
8181
|
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"),
|
|
8182
|
+
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"),
|
|
8179
8183
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8180
|
-
|
|
8184
|
+
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8181
8185
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
8182
8186
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
8183
8187
|
Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8184
8188
|
Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8185
8189
|
Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8186
8190
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8191
|
+
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8192
|
+
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8187
8193
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8188
8194
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8189
8195
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -8242,7 +8248,7 @@ var ts;
|
|
|
8242
8248
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
|
8243
8249
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
|
8244
8250
|
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
|
8245
|
-
|
|
8251
|
+
The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."),
|
|
8246
8252
|
The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
|
|
8247
8253
|
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
8248
8254
|
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
@@ -12971,7 +12977,7 @@ var ts;
|
|
|
12971
12977
|
switch (node.kind) {
|
|
12972
12978
|
case 269 /* ImportSpecifier */:
|
|
12973
12979
|
case 274 /* ExportSpecifier */:
|
|
12974
|
-
return node.parent.parent.isTypeOnly;
|
|
12980
|
+
return node.isTypeOnly || node.parent.parent.isTypeOnly;
|
|
12975
12981
|
case 267 /* NamespaceImport */:
|
|
12976
12982
|
return node.parent.isTypeOnly;
|
|
12977
12983
|
case 266 /* ImportClause */:
|
|
@@ -13342,6 +13348,7 @@ var ts;
|
|
|
13342
13348
|
case 225 /* ClassExpression */:
|
|
13343
13349
|
case 212 /* FunctionExpression */:
|
|
13344
13350
|
case 79 /* Identifier */:
|
|
13351
|
+
case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
|
|
13345
13352
|
case 13 /* RegularExpressionLiteral */:
|
|
13346
13353
|
case 8 /* NumericLiteral */:
|
|
13347
13354
|
case 9 /* BigIntLiteral */:
|
|
@@ -15692,6 +15699,8 @@ var ts;
|
|
|
15692
15699
|
node = node.parent;
|
|
15693
15700
|
}
|
|
15694
15701
|
return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
|
|
15702
|
+
case 80 /* PrivateIdentifier */:
|
|
15703
|
+
return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */;
|
|
15695
15704
|
case 79 /* Identifier */:
|
|
15696
15705
|
if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
|
|
15697
15706
|
return true;
|
|
@@ -17358,6 +17367,7 @@ var ts;
|
|
|
17358
17367
|
case 108 /* ThisKeyword */:
|
|
17359
17368
|
case 106 /* SuperKeyword */:
|
|
17360
17369
|
case 79 /* Identifier */:
|
|
17370
|
+
case 80 /* PrivateIdentifier */:
|
|
17361
17371
|
case 104 /* NullKeyword */:
|
|
17362
17372
|
case 110 /* TrueKeyword */:
|
|
17363
17373
|
case 95 /* FalseKeyword */:
|
|
@@ -19605,6 +19615,7 @@ var ts;
|
|
|
19605
19615
|
case ts.ModuleKind.AMD:
|
|
19606
19616
|
case ts.ModuleKind.ES2015:
|
|
19607
19617
|
case ts.ModuleKind.ES2020:
|
|
19618
|
+
case ts.ModuleKind.ES2022:
|
|
19608
19619
|
case ts.ModuleKind.ESNext:
|
|
19609
19620
|
return true;
|
|
19610
19621
|
default:
|
|
@@ -19778,7 +19789,8 @@ var ts;
|
|
|
19778
19789
|
var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd));
|
|
19779
19790
|
var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd));
|
|
19780
19791
|
var isDirectory = false;
|
|
19781
|
-
while (
|
|
19792
|
+
while (aParts.length >= 2 && bParts.length >= 2 &&
|
|
19793
|
+
!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
|
|
19782
19794
|
!isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
|
|
19783
19795
|
getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
|
|
19784
19796
|
aParts.pop();
|
|
@@ -19790,7 +19802,7 @@ var ts;
|
|
|
19790
19802
|
// KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
|
|
19791
19803
|
// ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
|
|
19792
19804
|
function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
|
|
19793
|
-
return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
|
|
19805
|
+
return s !== undefined && (getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"));
|
|
19794
19806
|
}
|
|
19795
19807
|
function stripLeadingDirectorySeparator(s) {
|
|
19796
19808
|
return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
|
|
@@ -20421,10 +20433,6 @@ var ts;
|
|
|
20421
20433
|
|| !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
|
|
20422
20434
|
}
|
|
20423
20435
|
ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
|
|
20424
|
-
function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
|
|
20425
|
-
return typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
20426
|
-
}
|
|
20427
|
-
ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
|
|
20428
20436
|
function isShorthandPropertyNameUseSite(useSite) {
|
|
20429
20437
|
return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
|
|
20430
20438
|
}
|
|
@@ -20712,6 +20720,10 @@ var ts;
|
|
|
20712
20720
|
return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
|
|
20713
20721
|
}
|
|
20714
20722
|
ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
|
|
20723
|
+
function isFunctionExpressionOrArrowFunction(node) {
|
|
20724
|
+
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
20725
|
+
}
|
|
20726
|
+
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20715
20727
|
})(ts || (ts = {}));
|
|
20716
20728
|
/* @internal */
|
|
20717
20729
|
var ts;
|
|
@@ -24446,8 +24458,9 @@ var ts;
|
|
|
24446
24458
|
: node;
|
|
24447
24459
|
}
|
|
24448
24460
|
// @api
|
|
24449
|
-
function createImportSpecifier(propertyName, name) {
|
|
24461
|
+
function createImportSpecifier(isTypeOnly, propertyName, name) {
|
|
24450
24462
|
var node = createBaseNode(269 /* ImportSpecifier */);
|
|
24463
|
+
node.isTypeOnly = isTypeOnly;
|
|
24451
24464
|
node.propertyName = propertyName;
|
|
24452
24465
|
node.name = name;
|
|
24453
24466
|
node.transformFlags |=
|
|
@@ -24457,10 +24470,11 @@ var ts;
|
|
|
24457
24470
|
return node;
|
|
24458
24471
|
}
|
|
24459
24472
|
// @api
|
|
24460
|
-
function updateImportSpecifier(node, propertyName, name) {
|
|
24461
|
-
return node.
|
|
24473
|
+
function updateImportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24474
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24475
|
+
|| node.propertyName !== propertyName
|
|
24462
24476
|
|| node.name !== name
|
|
24463
|
-
? update(createImportSpecifier(propertyName, name), node)
|
|
24477
|
+
? update(createImportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24464
24478
|
: node;
|
|
24465
24479
|
}
|
|
24466
24480
|
// @api
|
|
@@ -24521,8 +24535,9 @@ var ts;
|
|
|
24521
24535
|
: node;
|
|
24522
24536
|
}
|
|
24523
24537
|
// @api
|
|
24524
|
-
function createExportSpecifier(propertyName, name) {
|
|
24538
|
+
function createExportSpecifier(isTypeOnly, propertyName, name) {
|
|
24525
24539
|
var node = createBaseNode(274 /* ExportSpecifier */);
|
|
24540
|
+
node.isTypeOnly = isTypeOnly;
|
|
24526
24541
|
node.propertyName = asName(propertyName);
|
|
24527
24542
|
node.name = asName(name);
|
|
24528
24543
|
node.transformFlags |=
|
|
@@ -24532,10 +24547,11 @@ var ts;
|
|
|
24532
24547
|
return node;
|
|
24533
24548
|
}
|
|
24534
24549
|
// @api
|
|
24535
|
-
function updateExportSpecifier(node, propertyName, name) {
|
|
24536
|
-
return node.
|
|
24550
|
+
function updateExportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24551
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24552
|
+
|| node.propertyName !== propertyName
|
|
24537
24553
|
|| node.name !== name
|
|
24538
|
-
? update(createExportSpecifier(propertyName, name), node)
|
|
24554
|
+
? update(createExportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24539
24555
|
: node;
|
|
24540
24556
|
}
|
|
24541
24557
|
// @api
|
|
@@ -25643,7 +25659,7 @@ var ts;
|
|
|
25643
25659
|
/*decorators*/ undefined,
|
|
25644
25660
|
/*modifiers*/ undefined,
|
|
25645
25661
|
/*isTypeOnly*/ false, createNamedExports([
|
|
25646
|
-
createExportSpecifier(/*propertyName*/ undefined, exportName)
|
|
25662
|
+
createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, exportName)
|
|
25647
25663
|
]));
|
|
25648
25664
|
}
|
|
25649
25665
|
//
|
|
@@ -26957,6 +26973,7 @@ var ts;
|
|
|
26957
26973
|
// Class Fields Helpers
|
|
26958
26974
|
createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
|
|
26959
26975
|
createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
|
|
26976
|
+
createClassPrivateFieldInHelper: createClassPrivateFieldInHelper
|
|
26960
26977
|
};
|
|
26961
26978
|
/**
|
|
26962
26979
|
* Gets an identifier for the name of an *unscoped* emit helper.
|
|
@@ -27167,6 +27184,10 @@ var ts;
|
|
|
27167
27184
|
}
|
|
27168
27185
|
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args);
|
|
27169
27186
|
}
|
|
27187
|
+
function createClassPrivateFieldInHelper(state, receiver) {
|
|
27188
|
+
context.requestEmitHelper(ts.classPrivateFieldInHelper);
|
|
27189
|
+
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]);
|
|
27190
|
+
}
|
|
27170
27191
|
}
|
|
27171
27192
|
ts.createEmitHelperFactory = createEmitHelperFactory;
|
|
27172
27193
|
/* @internal */
|
|
@@ -27524,6 +27545,24 @@ var ts;
|
|
|
27524
27545
|
scoped: false,
|
|
27525
27546
|
text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };"
|
|
27526
27547
|
};
|
|
27548
|
+
/**
|
|
27549
|
+
* Parameters:
|
|
27550
|
+
* @param state — One of the following:
|
|
27551
|
+
* - A WeakMap when the member is a private instance field.
|
|
27552
|
+
* - A WeakSet when the member is a private instance method or accessor.
|
|
27553
|
+
* - A function value that should be the undecorated class constructor when the member is a private static field, method, or accessor.
|
|
27554
|
+
* @param receiver — The object being checked if it has the private member.
|
|
27555
|
+
*
|
|
27556
|
+
* Usage:
|
|
27557
|
+
* This helper is used to transform `#field in expression` to
|
|
27558
|
+
* `__classPrivateFieldIn(<weakMap/weakSet/constructor>, expression)`
|
|
27559
|
+
*/
|
|
27560
|
+
ts.classPrivateFieldInHelper = {
|
|
27561
|
+
name: "typescript:classPrivateFieldIn",
|
|
27562
|
+
importName: "__classPrivateFieldIn",
|
|
27563
|
+
scoped: false,
|
|
27564
|
+
text: "\n var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n };"
|
|
27565
|
+
};
|
|
27527
27566
|
var allUnscopedEmitHelpers;
|
|
27528
27567
|
function getAllUnscopedEmitHelpers() {
|
|
27529
27568
|
return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
|
|
@@ -27548,6 +27587,7 @@ var ts;
|
|
|
27548
27587
|
ts.exportStarHelper,
|
|
27549
27588
|
ts.classPrivateFieldGetHelper,
|
|
27550
27589
|
ts.classPrivateFieldSetHelper,
|
|
27590
|
+
ts.classPrivateFieldInHelper,
|
|
27551
27591
|
ts.createBindingHelper,
|
|
27552
27592
|
ts.setModuleDefaultHelper
|
|
27553
27593
|
], function (helper) { return helper.name; }));
|
|
@@ -28886,8 +28926,8 @@ var ts;
|
|
|
28886
28926
|
// Alias the imports if the names are used somewhere in the file.
|
|
28887
28927
|
// NOTE: We don't need to care about global import collisions as this is a module.
|
|
28888
28928
|
namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
|
|
28889
|
-
? nodeFactory.createImportSpecifier(/*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28890
|
-
: nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28929
|
+
? nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28930
|
+
: nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28891
28931
|
var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
|
|
28892
28932
|
var emitNode = ts.getOrCreateEmitNode(parseNode);
|
|
28893
28933
|
emitNode.externalHelpers = true;
|
|
@@ -31029,7 +31069,7 @@ var ts;
|
|
|
31029
31069
|
parseErrorAtCurrentToken(blankDiagnostic);
|
|
31030
31070
|
}
|
|
31031
31071
|
else {
|
|
31032
|
-
parseErrorAtCurrentToken(nameDiagnostic,
|
|
31072
|
+
parseErrorAtCurrentToken(nameDiagnostic, scanner.getTokenValue());
|
|
31033
31073
|
}
|
|
31034
31074
|
}
|
|
31035
31075
|
function getSpaceSuggestion(expressionText) {
|
|
@@ -31308,7 +31348,6 @@ var ts;
|
|
|
31308
31348
|
case 88 /* DefaultKeyword */:
|
|
31309
31349
|
return nextTokenCanFollowDefaultKeyword();
|
|
31310
31350
|
case 124 /* StaticKeyword */:
|
|
31311
|
-
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
31312
31351
|
case 136 /* GetKeyword */:
|
|
31313
31352
|
case 148 /* SetKeyword */:
|
|
31314
31353
|
nextToken();
|
|
@@ -34473,6 +34512,8 @@ var ts;
|
|
|
34473
34512
|
break;
|
|
34474
34513
|
case 15 /* TemplateHead */:
|
|
34475
34514
|
return parseTemplateExpression(/* isTaggedTemplate */ false);
|
|
34515
|
+
case 80 /* PrivateIdentifier */:
|
|
34516
|
+
return parsePrivateIdentifier();
|
|
34476
34517
|
}
|
|
34477
34518
|
return parseIdentifier(ts.Diagnostics.Expression_expected);
|
|
34478
34519
|
}
|
|
@@ -35549,7 +35590,7 @@ var ts;
|
|
|
35549
35590
|
}
|
|
35550
35591
|
return list && createNodeArray(list, pos);
|
|
35551
35592
|
}
|
|
35552
|
-
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35593
|
+
function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) {
|
|
35553
35594
|
var pos = getNodePos();
|
|
35554
35595
|
var kind = token();
|
|
35555
35596
|
if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) {
|
|
@@ -35562,6 +35603,9 @@ var ts;
|
|
|
35562
35603
|
else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) {
|
|
35563
35604
|
return undefined;
|
|
35564
35605
|
}
|
|
35606
|
+
else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) {
|
|
35607
|
+
return undefined;
|
|
35608
|
+
}
|
|
35565
35609
|
else {
|
|
35566
35610
|
if (!parseAnyContextualModifier()) {
|
|
35567
35611
|
return undefined;
|
|
@@ -35578,8 +35622,10 @@ var ts;
|
|
|
35578
35622
|
*/
|
|
35579
35623
|
function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) {
|
|
35580
35624
|
var pos = getNodePos();
|
|
35581
|
-
var list, modifier;
|
|
35582
|
-
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) {
|
|
35625
|
+
var list, modifier, hasSeenStatic = false;
|
|
35626
|
+
while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) {
|
|
35627
|
+
if (modifier.kind === 124 /* StaticKeyword */)
|
|
35628
|
+
hasSeenStatic = true;
|
|
35583
35629
|
list = ts.append(list, modifier);
|
|
35584
35630
|
}
|
|
35585
35631
|
return list && createNodeArray(list, pos);
|
|
@@ -36012,27 +36058,74 @@ var ts;
|
|
|
36012
36058
|
var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
36013
36059
|
var checkIdentifierStart = scanner.getTokenPos();
|
|
36014
36060
|
var checkIdentifierEnd = scanner.getTextPos();
|
|
36015
|
-
var
|
|
36061
|
+
var isTypeOnly = false;
|
|
36016
36062
|
var propertyName;
|
|
36017
|
-
var
|
|
36018
|
-
|
|
36019
|
-
|
|
36020
|
-
|
|
36021
|
-
|
|
36022
|
-
|
|
36023
|
-
|
|
36024
|
-
|
|
36063
|
+
var canParseAsKeyword = true;
|
|
36064
|
+
var name = parseIdentifierName();
|
|
36065
|
+
if (name.escapedText === "type") {
|
|
36066
|
+
// If the first token of an import specifier is 'type', there are a lot of possibilities,
|
|
36067
|
+
// especially if we see 'as' afterwards:
|
|
36068
|
+
//
|
|
36069
|
+
// import { type } from "mod"; - isTypeOnly: false, name: type
|
|
36070
|
+
// import { type as } from "mod"; - isTypeOnly: true, name: as
|
|
36071
|
+
// import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type
|
|
36072
|
+
// import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as
|
|
36073
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36074
|
+
// { type as ...? }
|
|
36075
|
+
var firstAs = parseIdentifierName();
|
|
36076
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36077
|
+
// { type as as ...? }
|
|
36078
|
+
var secondAs = parseIdentifierName();
|
|
36079
|
+
if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36080
|
+
// { type as as something }
|
|
36081
|
+
isTypeOnly = true;
|
|
36082
|
+
propertyName = firstAs;
|
|
36083
|
+
name = parseNameWithKeywordCheck();
|
|
36084
|
+
canParseAsKeyword = false;
|
|
36085
|
+
}
|
|
36086
|
+
else {
|
|
36087
|
+
// { type as as }
|
|
36088
|
+
propertyName = name;
|
|
36089
|
+
name = secondAs;
|
|
36090
|
+
canParseAsKeyword = false;
|
|
36091
|
+
}
|
|
36092
|
+
}
|
|
36093
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36094
|
+
// { type as something }
|
|
36095
|
+
propertyName = name;
|
|
36096
|
+
canParseAsKeyword = false;
|
|
36097
|
+
name = parseNameWithKeywordCheck();
|
|
36098
|
+
}
|
|
36099
|
+
else {
|
|
36100
|
+
// { type as }
|
|
36101
|
+
isTypeOnly = true;
|
|
36102
|
+
name = firstAs;
|
|
36103
|
+
}
|
|
36104
|
+
}
|
|
36105
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36106
|
+
// { type something ...? }
|
|
36107
|
+
isTypeOnly = true;
|
|
36108
|
+
name = parseNameWithKeywordCheck();
|
|
36109
|
+
}
|
|
36025
36110
|
}
|
|
36026
|
-
|
|
36027
|
-
|
|
36111
|
+
if (canParseAsKeyword && token() === 127 /* AsKeyword */) {
|
|
36112
|
+
propertyName = name;
|
|
36113
|
+
parseExpected(127 /* AsKeyword */);
|
|
36114
|
+
name = parseNameWithKeywordCheck();
|
|
36028
36115
|
}
|
|
36029
36116
|
if (kind === 269 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
|
|
36030
36117
|
parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
|
|
36031
36118
|
}
|
|
36032
36119
|
var node = kind === 269 /* ImportSpecifier */
|
|
36033
|
-
? factory.createImportSpecifier(propertyName, name)
|
|
36034
|
-
: factory.createExportSpecifier(propertyName, name);
|
|
36120
|
+
? factory.createImportSpecifier(isTypeOnly, propertyName, name)
|
|
36121
|
+
: factory.createExportSpecifier(isTypeOnly, propertyName, name);
|
|
36035
36122
|
return finishNode(node, pos);
|
|
36123
|
+
function parseNameWithKeywordCheck() {
|
|
36124
|
+
checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
36125
|
+
checkIdentifierStart = scanner.getTokenPos();
|
|
36126
|
+
checkIdentifierEnd = scanner.getTextPos();
|
|
36127
|
+
return parseIdentifierName();
|
|
36128
|
+
}
|
|
36036
36129
|
}
|
|
36037
36130
|
function parseNamespaceExport(pos) {
|
|
36038
36131
|
return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
|
|
@@ -38237,6 +38330,7 @@ var ts;
|
|
|
38237
38330
|
es6: ts.ModuleKind.ES2015,
|
|
38238
38331
|
es2015: ts.ModuleKind.ES2015,
|
|
38239
38332
|
es2020: ts.ModuleKind.ES2020,
|
|
38333
|
+
es2022: ts.ModuleKind.ES2022,
|
|
38240
38334
|
esnext: ts.ModuleKind.ESNext,
|
|
38241
38335
|
node12: ts.ModuleKind.Node12,
|
|
38242
38336
|
nodenext: ts.ModuleKind.NodeNext,
|
|
@@ -39144,7 +39238,7 @@ var ts;
|
|
|
39144
39238
|
/* @internal */
|
|
39145
39239
|
ts.defaultInitCompilerOptions = {
|
|
39146
39240
|
module: ts.ModuleKind.CommonJS,
|
|
39147
|
-
target:
|
|
39241
|
+
target: 3 /* ES2016 */,
|
|
39148
39242
|
strict: true,
|
|
39149
39243
|
esModuleInterop: true,
|
|
39150
39244
|
forceConsistentCasingInFileNames: true,
|
|
@@ -39944,6 +40038,44 @@ var ts;
|
|
|
39944
40038
|
}
|
|
39945
40039
|
return result;
|
|
39946
40040
|
}
|
|
40041
|
+
/**
|
|
40042
|
+
* Generate a list of the compiler options whose value is not the default.
|
|
40043
|
+
* @param options compilerOptions to be evaluated.
|
|
40044
|
+
/** @internal */
|
|
40045
|
+
function getCompilerOptionsDiffValue(options, newLine) {
|
|
40046
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
40047
|
+
return getOverwrittenDefaultOptions();
|
|
40048
|
+
function makePadding(paddingLength) {
|
|
40049
|
+
return Array(paddingLength + 1).join(" ");
|
|
40050
|
+
}
|
|
40051
|
+
function getOverwrittenDefaultOptions() {
|
|
40052
|
+
var result = [];
|
|
40053
|
+
var tab = makePadding(2);
|
|
40054
|
+
commandOptionsWithoutBuild.forEach(function (cmd) {
|
|
40055
|
+
if (!compilerOptionsMap.has(cmd.name)) {
|
|
40056
|
+
return;
|
|
40057
|
+
}
|
|
40058
|
+
var newValue = compilerOptionsMap.get(cmd.name);
|
|
40059
|
+
var defaultValue = getDefaultValueForOption(cmd);
|
|
40060
|
+
if (newValue !== defaultValue) {
|
|
40061
|
+
result.push("" + tab + cmd.name + ": " + newValue);
|
|
40062
|
+
}
|
|
40063
|
+
else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) {
|
|
40064
|
+
result.push("" + tab + cmd.name + ": " + defaultValue);
|
|
40065
|
+
}
|
|
40066
|
+
});
|
|
40067
|
+
return result.join(newLine) + newLine;
|
|
40068
|
+
}
|
|
40069
|
+
}
|
|
40070
|
+
ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue;
|
|
40071
|
+
/**
|
|
40072
|
+
* Get the compiler options to be written into the tsconfig.json.
|
|
40073
|
+
* @param options commandlineOptions to be included in the compileOptions.
|
|
40074
|
+
*/
|
|
40075
|
+
function getSerializedCompilerOption(options) {
|
|
40076
|
+
var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
|
|
40077
|
+
return serializeCompilerOptions(compilerOptions);
|
|
40078
|
+
}
|
|
39947
40079
|
/**
|
|
39948
40080
|
* Generate tsconfig configuration when running command line "--init"
|
|
39949
40081
|
* @param options commandlineOptions to be generated into tsconfig.json
|
|
@@ -39951,28 +40083,8 @@ var ts;
|
|
|
39951
40083
|
*/
|
|
39952
40084
|
/* @internal */
|
|
39953
40085
|
function generateTSConfig(options, fileNames, newLine) {
|
|
39954
|
-
var
|
|
39955
|
-
var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
|
|
40086
|
+
var compilerOptionsMap = getSerializedCompilerOption(options);
|
|
39956
40087
|
return writeConfigurations();
|
|
39957
|
-
function getDefaultValueForOption(option) {
|
|
39958
|
-
switch (option.type) {
|
|
39959
|
-
case "number":
|
|
39960
|
-
return 1;
|
|
39961
|
-
case "boolean":
|
|
39962
|
-
return true;
|
|
39963
|
-
case "string":
|
|
39964
|
-
return option.isFilePath ? "./" : "";
|
|
39965
|
-
case "list":
|
|
39966
|
-
return [];
|
|
39967
|
-
case "object":
|
|
39968
|
-
return {};
|
|
39969
|
-
default:
|
|
39970
|
-
var iterResult = option.type.keys().next();
|
|
39971
|
-
if (!iterResult.done)
|
|
39972
|
-
return iterResult.value;
|
|
39973
|
-
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
39974
|
-
}
|
|
39975
|
-
}
|
|
39976
40088
|
function makePadding(paddingLength) {
|
|
39977
40089
|
return Array(paddingLength + 1).join(" ");
|
|
39978
40090
|
}
|
|
@@ -40959,6 +41071,25 @@ var ts;
|
|
|
40959
41071
|
}); // TODO: GH#18217
|
|
40960
41072
|
}
|
|
40961
41073
|
}
|
|
41074
|
+
function getDefaultValueForOption(option) {
|
|
41075
|
+
switch (option.type) {
|
|
41076
|
+
case "number":
|
|
41077
|
+
return 1;
|
|
41078
|
+
case "boolean":
|
|
41079
|
+
return true;
|
|
41080
|
+
case "string":
|
|
41081
|
+
return option.isFilePath ? "./" : "";
|
|
41082
|
+
case "list":
|
|
41083
|
+
return [];
|
|
41084
|
+
case "object":
|
|
41085
|
+
return {};
|
|
41086
|
+
default:
|
|
41087
|
+
var iterResult = option.type.keys().next();
|
|
41088
|
+
if (!iterResult.done)
|
|
41089
|
+
return iterResult.value;
|
|
41090
|
+
return ts.Debug.fail("Expected 'option.type' to have entries.");
|
|
41091
|
+
}
|
|
41092
|
+
}
|
|
40962
41093
|
})(ts || (ts = {}));
|
|
40963
41094
|
var ts;
|
|
40964
41095
|
(function (ts) {
|
|
@@ -41914,8 +42045,17 @@ var ts;
|
|
|
41914
42045
|
var _a, _b;
|
|
41915
42046
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41916
42047
|
var failedLookupLocations = [];
|
|
41917
|
-
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
41918
|
-
|
|
42048
|
+
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42049
|
+
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
42050
|
+
var state = {
|
|
42051
|
+
compilerOptions: compilerOptions,
|
|
42052
|
+
host: host,
|
|
42053
|
+
traceEnabled: traceEnabled,
|
|
42054
|
+
failedLookupLocations: failedLookupLocations,
|
|
42055
|
+
packageJsonInfoCache: cache,
|
|
42056
|
+
features: features,
|
|
42057
|
+
conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
|
|
42058
|
+
};
|
|
41919
42059
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
41920
42060
|
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
|
41921
42061
|
function tryResolve(extensions) {
|
|
@@ -46361,6 +46501,13 @@ var ts;
|
|
|
46361
46501
|
IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck";
|
|
46362
46502
|
IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck";
|
|
46363
46503
|
})(IntersectionState || (IntersectionState = {}));
|
|
46504
|
+
var RecursionFlags;
|
|
46505
|
+
(function (RecursionFlags) {
|
|
46506
|
+
RecursionFlags[RecursionFlags["None"] = 0] = "None";
|
|
46507
|
+
RecursionFlags[RecursionFlags["Source"] = 1] = "Source";
|
|
46508
|
+
RecursionFlags[RecursionFlags["Target"] = 2] = "Target";
|
|
46509
|
+
RecursionFlags[RecursionFlags["Both"] = 3] = "Both";
|
|
46510
|
+
})(RecursionFlags || (RecursionFlags = {}));
|
|
46364
46511
|
var MappedTypeModifiers;
|
|
46365
46512
|
(function (MappedTypeModifiers) {
|
|
46366
46513
|
MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly";
|
|
@@ -46853,6 +47000,7 @@ var ts;
|
|
|
46853
47000
|
getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
|
|
46854
47001
|
isDeclarationVisible: isDeclarationVisible,
|
|
46855
47002
|
isPropertyAccessible: isPropertyAccessible,
|
|
47003
|
+
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
46856
47004
|
};
|
|
46857
47005
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
46858
47006
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -46877,10 +47025,13 @@ var ts;
|
|
|
46877
47025
|
var undefinedProperties = new ts.Map();
|
|
46878
47026
|
var unknownSymbol = createSymbol(4 /* Property */, "unknown");
|
|
46879
47027
|
var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
|
|
47028
|
+
var unresolvedSymbols = new ts.Map();
|
|
47029
|
+
var errorTypes = new ts.Map();
|
|
46880
47030
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
46881
47031
|
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
46882
47032
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
46883
47033
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
47034
|
+
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
46884
47035
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
|
|
46885
47036
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46886
47037
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -47119,17 +47270,9 @@ var ts;
|
|
|
47119
47270
|
}
|
|
47120
47271
|
}
|
|
47121
47272
|
else {
|
|
47122
|
-
|
|
47123
|
-
|
|
47124
|
-
|
|
47125
|
-
var jsxPragma = file.pragmas.get("jsx");
|
|
47126
|
-
if (jsxPragma) {
|
|
47127
|
-
var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
|
|
47128
|
-
file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
|
|
47129
|
-
ts.visitNode(file.localJsxFactory, markAsSynthetic);
|
|
47130
|
-
if (file.localJsxFactory) {
|
|
47131
|
-
return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
|
|
47132
|
-
}
|
|
47273
|
+
var localJsxNamespace = getLocalJsxNamespace(file);
|
|
47274
|
+
if (localJsxNamespace) {
|
|
47275
|
+
return file.localJsxNamespace = localJsxNamespace;
|
|
47133
47276
|
}
|
|
47134
47277
|
}
|
|
47135
47278
|
}
|
|
@@ -47151,11 +47294,25 @@ var ts;
|
|
|
47151
47294
|
_jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
|
|
47152
47295
|
}
|
|
47153
47296
|
return _jsxNamespace;
|
|
47154
|
-
|
|
47155
|
-
|
|
47156
|
-
|
|
47297
|
+
}
|
|
47298
|
+
function getLocalJsxNamespace(file) {
|
|
47299
|
+
if (file.localJsxNamespace) {
|
|
47300
|
+
return file.localJsxNamespace;
|
|
47301
|
+
}
|
|
47302
|
+
var jsxPragma = file.pragmas.get("jsx");
|
|
47303
|
+
if (jsxPragma) {
|
|
47304
|
+
var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
|
|
47305
|
+
file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
|
|
47306
|
+
ts.visitNode(file.localJsxFactory, markAsSynthetic);
|
|
47307
|
+
if (file.localJsxFactory) {
|
|
47308
|
+
return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
|
|
47309
|
+
}
|
|
47157
47310
|
}
|
|
47158
47311
|
}
|
|
47312
|
+
function markAsSynthetic(node) {
|
|
47313
|
+
ts.setTextRangePosEnd(node, -1, -1);
|
|
47314
|
+
return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
|
|
47315
|
+
}
|
|
47159
47316
|
function getEmitResolver(sourceFile, cancellationToken) {
|
|
47160
47317
|
// Ensure we have all the type information in place for this file so that all the
|
|
47161
47318
|
// emitter questions of this resolver will return the right information.
|
|
@@ -48226,8 +48383,7 @@ var ts;
|
|
|
48226
48383
|
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48227
48384
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48228
48385
|
if (typeOnlyDeclaration) {
|
|
48229
|
-
var
|
|
48230
|
-
var message = isExport
|
|
48386
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48231
48387
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48232
48388
|
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48233
48389
|
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
@@ -48238,7 +48394,7 @@ var ts;
|
|
|
48238
48394
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48239
48395
|
if (!typeOnlyDeclaration)
|
|
48240
48396
|
return diagnostic;
|
|
48241
|
-
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration,
|
|
48397
|
+
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName));
|
|
48242
48398
|
}
|
|
48243
48399
|
function getIsDeferredContext(location, lastLocation) {
|
|
48244
48400
|
if (location.kind !== 213 /* ArrowFunction */ && location.kind !== 212 /* FunctionExpression */) {
|
|
@@ -48562,15 +48718,13 @@ var ts;
|
|
|
48562
48718
|
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
|
|
48563
48719
|
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) {
|
|
48564
48720
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
|
|
48565
|
-
var isExport =
|
|
48721
|
+
var isExport = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
48566
48722
|
var message = isExport
|
|
48567
48723
|
? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
|
|
48568
48724
|
: ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
|
|
48569
48725
|
var relatedMessage = isExport
|
|
48570
48726
|
? ts.Diagnostics._0_was_exported_here
|
|
48571
48727
|
: ts.Diagnostics._0_was_imported_here;
|
|
48572
|
-
// Non-null assertion is safe because the optionality comes from ImportClause,
|
|
48573
|
-
// but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
|
|
48574
48728
|
var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
|
|
48575
48729
|
ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
|
|
48576
48730
|
}
|
|
@@ -48585,7 +48739,21 @@ var ts;
|
|
|
48585
48739
|
function isSyntacticDefault(node) {
|
|
48586
48740
|
return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node));
|
|
48587
48741
|
}
|
|
48588
|
-
function
|
|
48742
|
+
function getUsageModeForExpression(usage) {
|
|
48743
|
+
return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined;
|
|
48744
|
+
}
|
|
48745
|
+
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
48746
|
+
return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
|
|
48747
|
+
}
|
|
48748
|
+
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
48749
|
+
var usageMode = file && getUsageModeForExpression(usage);
|
|
48750
|
+
if (file && usageMode !== undefined) {
|
|
48751
|
+
var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
48752
|
+
if (usageMode === ts.ModuleKind.ESNext || result) {
|
|
48753
|
+
return result;
|
|
48754
|
+
}
|
|
48755
|
+
// fallthrough on cjs usages so we imply defaults for interop'd imports, too
|
|
48756
|
+
}
|
|
48589
48757
|
if (!allowSyntheticDefaultImports) {
|
|
48590
48758
|
return false;
|
|
48591
48759
|
}
|
|
@@ -48627,7 +48795,7 @@ var ts;
|
|
|
48627
48795
|
exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
|
|
48628
48796
|
}
|
|
48629
48797
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48630
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
|
|
48798
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
|
|
48631
48799
|
if (!exportDefaultSymbol && !hasSyntheticDefault) {
|
|
48632
48800
|
if (hasExportAssignmentSymbol(moduleSymbol)) {
|
|
48633
48801
|
var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
@@ -48767,7 +48935,7 @@ var ts;
|
|
|
48767
48935
|
var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
|
|
48768
48936
|
if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
|
|
48769
48937
|
var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
48770
|
-
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
|
|
48938
|
+
if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
|
|
48771
48939
|
symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
|
|
48772
48940
|
}
|
|
48773
48941
|
}
|
|
@@ -48986,13 +49154,13 @@ var ts;
|
|
|
48986
49154
|
* and issue an error if so.
|
|
48987
49155
|
*
|
|
48988
49156
|
* @param aliasDeclaration The alias declaration not marked as type-only
|
|
49157
|
+
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
49158
|
+
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
49159
|
+
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
48989
49160
|
* has already been marked as not resolving to a type-only alias. Used when recursively resolving qualified
|
|
48990
49161
|
* names of import aliases, e.g. `import C = a.b.C`. If namespace `a` is not found to be type-only, the
|
|
48991
49162
|
* import declaration will initially be marked as not resolving to a type-only symbol. But, namespace `b`
|
|
48992
49163
|
* must still be checked for a type-only marker, overwriting the previous negative result if found.
|
|
48993
|
-
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
48994
|
-
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
48995
|
-
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
48996
49164
|
*/
|
|
48997
49165
|
function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
|
|
48998
49166
|
if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration))
|
|
@@ -49291,10 +49459,10 @@ var ts;
|
|
|
49291
49459
|
var currentSourceFile = ts.getSourceFileOfNode(location);
|
|
49292
49460
|
var contextSpecifier = ts.isStringLiteralLike(location)
|
|
49293
49461
|
? location
|
|
49294
|
-
: ((_a =
|
|
49295
|
-
((_b =
|
|
49296
|
-
((_c =
|
|
49297
|
-
((_d =
|
|
49462
|
+
: ((_a = ts.findAncestor(location, ts.isImportCall)) === null || _a === void 0 ? void 0 : _a.arguments[0]) ||
|
|
49463
|
+
((_b = ts.findAncestor(location, ts.isImportDeclaration)) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) ||
|
|
49464
|
+
((_c = ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) ||
|
|
49465
|
+
((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
|
|
49298
49466
|
((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
|
|
49299
49467
|
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49300
49468
|
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
|
|
@@ -49308,7 +49476,7 @@ var ts;
|
|
|
49308
49476
|
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
|
|
49309
49477
|
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
|
|
49310
49478
|
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49311
|
-
error(errorNode, ts.Diagnostics.
|
|
49479
|
+
error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
|
|
49312
49480
|
}
|
|
49313
49481
|
}
|
|
49314
49482
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
@@ -49458,7 +49626,7 @@ var ts;
|
|
|
49458
49626
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49459
49627
|
}
|
|
49460
49628
|
if (sigs && sigs.length) {
|
|
49461
|
-
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
|
|
49629
|
+
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
|
|
49462
49630
|
// Create a new symbol which has the module's type less the call and construct signatures
|
|
49463
49631
|
var result = createSymbol(symbol.flags, symbol.escapedName);
|
|
49464
49632
|
result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
|
|
@@ -50333,7 +50501,9 @@ var ts;
|
|
|
50333
50501
|
var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
|
|
50334
50502
|
if (typeNode === undefined)
|
|
50335
50503
|
return ts.Debug.fail("should always get typenode");
|
|
50336
|
-
|
|
50504
|
+
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
|
|
50505
|
+
// Otherwise, we always strip comments out.
|
|
50506
|
+
var options = { removeComments: type !== unresolvedType };
|
|
50337
50507
|
var printer = ts.createPrinter(options);
|
|
50338
50508
|
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
|
|
50339
50509
|
printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
|
|
@@ -50479,6 +50649,12 @@ var ts;
|
|
|
50479
50649
|
type = getReducedType(type);
|
|
50480
50650
|
}
|
|
50481
50651
|
if (type.flags & 1 /* Any */) {
|
|
50652
|
+
if (type.aliasSymbol) {
|
|
50653
|
+
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
|
|
50654
|
+
}
|
|
50655
|
+
if (type === unresolvedType) {
|
|
50656
|
+
return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
|
|
50657
|
+
}
|
|
50482
50658
|
context.approximateLength += 3;
|
|
50483
50659
|
return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
|
|
50484
50660
|
}
|
|
@@ -51567,6 +51743,10 @@ var ts;
|
|
|
51567
51743
|
}
|
|
51568
51744
|
return specifier;
|
|
51569
51745
|
}
|
|
51746
|
+
function symbolToEntityNameNode(symbol) {
|
|
51747
|
+
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
|
|
51748
|
+
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
51749
|
+
}
|
|
51570
51750
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
51571
51751
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
51572
51752
|
var isTypeOf = meaning === 111551 /* Value */;
|
|
@@ -51853,7 +52033,7 @@ var ts;
|
|
|
51853
52033
|
* so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
|
|
51854
52034
|
*/
|
|
51855
52035
|
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
51856
|
-
if (type
|
|
52036
|
+
if (!isErrorType(type) && enclosingDeclaration) {
|
|
51857
52037
|
var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
|
|
51858
52038
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
51859
52039
|
// try to reuse the existing annotation
|
|
@@ -51876,7 +52056,7 @@ var ts;
|
|
|
51876
52056
|
return result;
|
|
51877
52057
|
}
|
|
51878
52058
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
51879
|
-
if (type
|
|
52059
|
+
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
51880
52060
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
51881
52061
|
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
|
|
51882
52062
|
var annotated = getTypeFromTypeNode(annotation);
|
|
@@ -51983,7 +52163,7 @@ var ts;
|
|
|
51983
52163
|
/*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
51984
52164
|
}
|
|
51985
52165
|
}
|
|
51986
|
-
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
|
|
52166
|
+
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
|
|
51987
52167
|
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51988
52168
|
}
|
|
51989
52169
|
if (ts.isLiteralImportTypeNode(node)) {
|
|
@@ -52113,7 +52293,7 @@ var ts;
|
|
|
52113
52293
|
ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration(
|
|
52114
52294
|
/*decorators*/ undefined,
|
|
52115
52295
|
/*modifiers*/ undefined,
|
|
52116
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*alias*/ undefined, id); })),
|
|
52296
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id); })),
|
|
52117
52297
|
/*moduleSpecifier*/ undefined)], false))));
|
|
52118
52298
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true);
|
|
52119
52299
|
}
|
|
@@ -52341,7 +52521,7 @@ var ts;
|
|
|
52341
52521
|
addResult(ts.factory.createExportDeclaration(
|
|
52342
52522
|
/*decorators*/ undefined,
|
|
52343
52523
|
/*modifiers*/ undefined,
|
|
52344
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0 /* None */);
|
|
52524
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */);
|
|
52345
52525
|
context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
|
|
52346
52526
|
}
|
|
52347
52527
|
else {
|
|
@@ -52374,7 +52554,7 @@ var ts;
|
|
|
52374
52554
|
addResult(ts.factory.createExportDeclaration(
|
|
52375
52555
|
/*decorators*/ undefined,
|
|
52376
52556
|
/*modifiers*/ undefined,
|
|
52377
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */);
|
|
52557
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */);
|
|
52378
52558
|
needsExportDeclaration = false;
|
|
52379
52559
|
needsPostExportDefault = false;
|
|
52380
52560
|
}
|
|
@@ -52432,7 +52612,7 @@ var ts;
|
|
|
52432
52612
|
addResult(ts.factory.createExportDeclaration(
|
|
52433
52613
|
/*decorators*/ undefined,
|
|
52434
52614
|
/*modifiers*/ undefined,
|
|
52435
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
52615
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
52436
52616
|
}
|
|
52437
52617
|
}
|
|
52438
52618
|
function includePrivateSymbol(symbol) {
|
|
@@ -52554,7 +52734,7 @@ var ts;
|
|
|
52554
52734
|
var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true);
|
|
52555
52735
|
includePrivateSymbol(target || s);
|
|
52556
52736
|
var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
|
|
52557
|
-
return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name);
|
|
52737
|
+
return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name);
|
|
52558
52738
|
})))]);
|
|
52559
52739
|
addResult(ts.factory.createModuleDeclaration(
|
|
52560
52740
|
/*decorators*/ undefined,
|
|
@@ -52645,7 +52825,7 @@ var ts;
|
|
|
52645
52825
|
var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(
|
|
52646
52826
|
/*decorators*/ undefined,
|
|
52647
52827
|
/*modifiers*/ undefined,
|
|
52648
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52828
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52649
52829
|
var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
|
|
52650
52830
|
fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
|
|
52651
52831
|
addResult(fakespace, modifierFlags); // namespaces can never be default exported
|
|
@@ -52796,7 +52976,8 @@ var ts;
|
|
|
52796
52976
|
var propertyName = node.propertyName;
|
|
52797
52977
|
addResult(ts.factory.createImportDeclaration(
|
|
52798
52978
|
/*decorators*/ undefined,
|
|
52799
|
-
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52979
|
+
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52980
|
+
/*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1),
|
|
52800
52981
|
/*importClause*/ undefined), 0 /* None */);
|
|
52801
52982
|
break;
|
|
52802
52983
|
}
|
|
@@ -52880,7 +53061,8 @@ var ts;
|
|
|
52880
53061
|
/*modifiers*/ undefined, ts.factory.createImportClause(
|
|
52881
53062
|
/*isTypeOnly*/ false,
|
|
52882
53063
|
/*importClause*/ undefined, ts.factory.createNamedImports([
|
|
52883
|
-
ts.factory.createImportSpecifier(
|
|
53064
|
+
ts.factory.createImportSpecifier(
|
|
53065
|
+
/*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
|
|
52884
53066
|
])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
|
|
52885
53067
|
/*assertClause*/ undefined), 0 /* None */);
|
|
52886
53068
|
break;
|
|
@@ -52916,7 +53098,7 @@ var ts;
|
|
|
52916
53098
|
addResult(ts.factory.createExportDeclaration(
|
|
52917
53099
|
/*decorators*/ undefined,
|
|
52918
53100
|
/*modifiers*/ undefined,
|
|
52919
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
53101
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
52920
53102
|
}
|
|
52921
53103
|
/**
|
|
52922
53104
|
* Returns `true` if an export assignment or declaration was produced for the symbol
|
|
@@ -53634,6 +53816,11 @@ var ts;
|
|
|
53634
53816
|
function isTypeAny(type) {
|
|
53635
53817
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
53636
53818
|
}
|
|
53819
|
+
function isErrorType(type) {
|
|
53820
|
+
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
|
|
53821
|
+
// a reference to an unresolved symbol. We want those to behave like the errorType.
|
|
53822
|
+
return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
|
|
53823
|
+
}
|
|
53637
53824
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
53638
53825
|
// assigned by contextual typing.
|
|
53639
53826
|
function getTypeForBindingElementParent(node) {
|
|
@@ -54151,7 +54338,7 @@ var ts;
|
|
|
54151
54338
|
if (!declaredType) {
|
|
54152
54339
|
return type;
|
|
54153
54340
|
}
|
|
54154
|
-
else if (declaredType
|
|
54341
|
+
else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
|
|
54155
54342
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
|
|
54156
54343
|
}
|
|
54157
54344
|
}
|
|
@@ -55045,7 +55232,7 @@ var ts;
|
|
|
55045
55232
|
for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
|
|
55046
55233
|
var node = implementsTypeNodes_1[_b];
|
|
55047
55234
|
var implementsType = getTypeFromTypeNode(node);
|
|
55048
|
-
if (implementsType
|
|
55235
|
+
if (!isErrorType(implementsType)) {
|
|
55049
55236
|
if (resolvedImplementsTypes === ts.emptyArray) {
|
|
55050
55237
|
resolvedImplementsTypes = [implementsType];
|
|
55051
55238
|
}
|
|
@@ -55125,7 +55312,7 @@ var ts;
|
|
|
55125
55312
|
}
|
|
55126
55313
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
55127
55314
|
}
|
|
55128
|
-
if (baseType
|
|
55315
|
+
if (isErrorType(baseType)) {
|
|
55129
55316
|
return type.resolvedBaseTypes = ts.emptyArray;
|
|
55130
55317
|
}
|
|
55131
55318
|
var reducedBaseType = getReducedType(baseType);
|
|
@@ -55181,7 +55368,7 @@ var ts;
|
|
|
55181
55368
|
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
|
|
55182
55369
|
var node = _c[_b];
|
|
55183
55370
|
var baseType = getReducedType(getTypeFromTypeNode(node));
|
|
55184
|
-
if (baseType
|
|
55371
|
+
if (!isErrorType(baseType)) {
|
|
55185
55372
|
if (isValidBaseType(baseType)) {
|
|
55186
55373
|
if (type !== baseType && !hasBaseType(baseType, type)) {
|
|
55187
55374
|
if (type.resolvedBaseTypes === ts.emptyArray) {
|
|
@@ -56406,6 +56593,23 @@ var ts;
|
|
|
56406
56593
|
function getIsLateCheckFlag(s) {
|
|
56407
56594
|
return ts.getCheckFlags(s) & 4096 /* Late */;
|
|
56408
56595
|
}
|
|
56596
|
+
function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
|
|
56597
|
+
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
|
|
56598
|
+
var prop = _a[_i];
|
|
56599
|
+
cb(getLiteralTypeFromProperty(prop, include));
|
|
56600
|
+
}
|
|
56601
|
+
if (type.flags & 1 /* Any */) {
|
|
56602
|
+
cb(stringType);
|
|
56603
|
+
}
|
|
56604
|
+
else {
|
|
56605
|
+
for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) {
|
|
56606
|
+
var info = _c[_b];
|
|
56607
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
56608
|
+
cb(info.keyType);
|
|
56609
|
+
}
|
|
56610
|
+
}
|
|
56611
|
+
}
|
|
56612
|
+
}
|
|
56409
56613
|
/** Resolve the members of a mapped type { [P in K]: T } */
|
|
56410
56614
|
function resolveMappedTypeMembers(type) {
|
|
56411
56615
|
var members = ts.createSymbolTable();
|
|
@@ -56423,21 +56627,7 @@ var ts;
|
|
|
56423
56627
|
var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
56424
56628
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
56425
56629
|
// We have a { [P in keyof T]: X }
|
|
56426
|
-
|
|
56427
|
-
var prop = _a[_i];
|
|
56428
|
-
addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
|
|
56429
|
-
}
|
|
56430
|
-
if (modifiersType.flags & 1 /* Any */) {
|
|
56431
|
-
addMemberForKeyType(stringType);
|
|
56432
|
-
}
|
|
56433
|
-
else {
|
|
56434
|
-
for (var _b = 0, _c = getIndexInfosOfType(modifiersType); _b < _c.length; _b++) {
|
|
56435
|
-
var info = _c[_b];
|
|
56436
|
-
if (!keyofStringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
56437
|
-
addMemberForKeyType(info.keyType);
|
|
56438
|
-
}
|
|
56439
|
-
}
|
|
56440
|
-
}
|
|
56630
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
|
|
56441
56631
|
}
|
|
56442
56632
|
else {
|
|
56443
56633
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
@@ -57023,7 +57213,7 @@ var ts;
|
|
|
57023
57213
|
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
|
|
57024
57214
|
var current = _c[_i];
|
|
57025
57215
|
var type = getApparentType(current);
|
|
57026
|
-
if (!(type
|
|
57216
|
+
if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
|
|
57027
57217
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
57028
57218
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
57029
57219
|
if (prop) {
|
|
@@ -57132,7 +57322,7 @@ var ts;
|
|
|
57132
57322
|
else if (type !== firstType) {
|
|
57133
57323
|
checkFlags |= 64 /* HasNonUniformType */;
|
|
57134
57324
|
}
|
|
57135
|
-
if (isLiteralType(type)) {
|
|
57325
|
+
if (isLiteralType(type) || isPatternLiteralType(type)) {
|
|
57136
57326
|
checkFlags |= 128 /* HasLiteralType */;
|
|
57137
57327
|
}
|
|
57138
57328
|
if (type.flags & 131072 /* Never */) {
|
|
@@ -57973,7 +58163,7 @@ var ts;
|
|
|
57973
58163
|
}
|
|
57974
58164
|
else {
|
|
57975
58165
|
var type = getTypeFromTypeNode(constraintDeclaration);
|
|
57976
|
-
if (type.flags & 1 /* Any */ && type
|
|
58166
|
+
if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
|
|
57977
58167
|
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
|
|
57978
58168
|
// use unknown otherwise
|
|
57979
58169
|
type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
|
|
@@ -58145,6 +58335,18 @@ var ts;
|
|
|
58145
58335
|
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
|
58146
58336
|
*/
|
|
58147
58337
|
function getTypeFromTypeAliasReference(node, symbol) {
|
|
58338
|
+
if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
|
|
58339
|
+
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
58340
|
+
var id = getAliasId(symbol, typeArguments);
|
|
58341
|
+
var errorType_1 = errorTypes.get(id);
|
|
58342
|
+
if (!errorType_1) {
|
|
58343
|
+
errorType_1 = createIntrinsicType(1 /* Any */, "error");
|
|
58344
|
+
errorType_1.aliasSymbol = symbol;
|
|
58345
|
+
errorType_1.aliasTypeArguments = typeArguments;
|
|
58346
|
+
errorTypes.set(id, errorType_1);
|
|
58347
|
+
}
|
|
58348
|
+
return errorType_1;
|
|
58349
|
+
}
|
|
58148
58350
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
58149
58351
|
var typeParameters = getSymbolLinks(symbol).typeParameters;
|
|
58150
58352
|
if (typeParameters) {
|
|
@@ -58186,11 +58388,37 @@ var ts;
|
|
|
58186
58388
|
}
|
|
58187
58389
|
return undefined;
|
|
58188
58390
|
}
|
|
58189
|
-
function
|
|
58190
|
-
|
|
58391
|
+
function getSymbolPath(symbol) {
|
|
58392
|
+
return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
|
|
58393
|
+
}
|
|
58394
|
+
function getUnresolvedSymbolForEntityName(name) {
|
|
58395
|
+
var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
|
|
58396
|
+
name.kind === 205 /* PropertyAccessExpression */ ? name.name :
|
|
58397
|
+
name;
|
|
58398
|
+
var text = identifier.escapedText;
|
|
58399
|
+
if (text) {
|
|
58400
|
+
var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
|
|
58401
|
+
name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
|
|
58402
|
+
undefined;
|
|
58403
|
+
var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
|
|
58404
|
+
var result = unresolvedSymbols.get(path);
|
|
58405
|
+
if (!result) {
|
|
58406
|
+
unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
|
|
58407
|
+
result.parent = parentSymbol;
|
|
58408
|
+
result.declaredType = unresolvedType;
|
|
58409
|
+
}
|
|
58410
|
+
return result;
|
|
58411
|
+
}
|
|
58412
|
+
return unknownSymbol;
|
|
58413
|
+
}
|
|
58414
|
+
function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
|
|
58415
|
+
var name = getTypeReferenceName(typeReference);
|
|
58416
|
+
if (!name) {
|
|
58191
58417
|
return unknownSymbol;
|
|
58192
58418
|
}
|
|
58193
|
-
|
|
58419
|
+
var symbol = resolveEntityName(name, meaning, ignoreErrors);
|
|
58420
|
+
return symbol && symbol !== unknownSymbol ? symbol :
|
|
58421
|
+
ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
|
|
58194
58422
|
}
|
|
58195
58423
|
function getTypeReferenceType(node, symbol) {
|
|
58196
58424
|
if (symbol === unknownSymbol) {
|
|
@@ -58215,7 +58443,7 @@ var ts;
|
|
|
58215
58443
|
}
|
|
58216
58444
|
else {
|
|
58217
58445
|
// Resolve the type reference as a Type for the purpose of reporting errors.
|
|
58218
|
-
resolveTypeReferenceName(
|
|
58446
|
+
resolveTypeReferenceName(node, 788968 /* Type */);
|
|
58219
58447
|
return getTypeOfSymbol(symbol);
|
|
58220
58448
|
}
|
|
58221
58449
|
}
|
|
@@ -58359,18 +58587,18 @@ var ts;
|
|
|
58359
58587
|
if (isJSDocTypeReference(node)) {
|
|
58360
58588
|
type = getIntendedTypeFromJSDocTypeReference(node);
|
|
58361
58589
|
if (!type) {
|
|
58362
|
-
symbol = resolveTypeReferenceName(
|
|
58590
|
+
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
|
|
58363
58591
|
if (symbol === unknownSymbol) {
|
|
58364
|
-
symbol = resolveTypeReferenceName(
|
|
58592
|
+
symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
|
|
58365
58593
|
}
|
|
58366
58594
|
else {
|
|
58367
|
-
resolveTypeReferenceName(
|
|
58595
|
+
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
|
|
58368
58596
|
}
|
|
58369
58597
|
type = getTypeReferenceType(node, symbol);
|
|
58370
58598
|
}
|
|
58371
58599
|
}
|
|
58372
58600
|
if (!type) {
|
|
58373
|
-
symbol = resolveTypeReferenceName(
|
|
58601
|
+
symbol = resolveTypeReferenceName(node, meaning);
|
|
58374
58602
|
type = getTypeReferenceType(node, symbol);
|
|
58375
58603
|
}
|
|
58376
58604
|
// Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
|
|
@@ -58631,7 +58859,7 @@ var ts;
|
|
|
58631
58859
|
function mayResolveTypeAlias(node) {
|
|
58632
58860
|
switch (node.kind) {
|
|
58633
58861
|
case 177 /* TypeReference */:
|
|
58634
|
-
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node
|
|
58862
|
+
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
|
|
58635
58863
|
case 180 /* TypeQuery */:
|
|
58636
58864
|
return true;
|
|
58637
58865
|
case 192 /* TypeOperator */:
|
|
@@ -58906,8 +59134,6 @@ var ts;
|
|
|
58906
59134
|
// We ignore 'never' types in unions
|
|
58907
59135
|
if (!(flags & 131072 /* Never */)) {
|
|
58908
59136
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58909
|
-
if (flags & 469499904 /* StructuredOrInstantiable */)
|
|
58910
|
-
includes |= 262144 /* IncludesStructuredOrInstantiable */;
|
|
58911
59137
|
if (type === wildcardType)
|
|
58912
59138
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58913
59139
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -59213,13 +59439,19 @@ var ts;
|
|
|
59213
59439
|
if (type === wildcardType)
|
|
59214
59440
|
includes |= 8388608 /* IncludesWildcard */;
|
|
59215
59441
|
}
|
|
59216
|
-
else if (
|
|
59217
|
-
if (
|
|
59218
|
-
|
|
59219
|
-
|
|
59220
|
-
|
|
59442
|
+
else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
59443
|
+
if (exactOptionalPropertyTypes && type === missingType) {
|
|
59444
|
+
includes |= 262144 /* IncludesMissingType */;
|
|
59445
|
+
type = undefinedType;
|
|
59446
|
+
}
|
|
59447
|
+
if (!typeSet.has(type.id.toString())) {
|
|
59448
|
+
if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) {
|
|
59449
|
+
// We have seen two distinct unit types which means we should reduce to an
|
|
59450
|
+
// empty intersection. Adding TypeFlags.NonPrimitive causes that to happen.
|
|
59451
|
+
includes |= 67108864 /* NonPrimitive */;
|
|
59452
|
+
}
|
|
59453
|
+
typeSet.set(type.id.toString(), type);
|
|
59221
59454
|
}
|
|
59222
|
-
typeSet.set(type.id.toString(), type);
|
|
59223
59455
|
}
|
|
59224
59456
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
59225
59457
|
}
|
|
@@ -59292,14 +59524,13 @@ var ts;
|
|
|
59292
59524
|
}
|
|
59293
59525
|
return false;
|
|
59294
59526
|
}
|
|
59295
|
-
function
|
|
59296
|
-
|
|
59297
|
-
|
|
59298
|
-
|
|
59299
|
-
|
|
59300
|
-
return
|
|
59527
|
+
function eachIsUnionContaining(types, flag) {
|
|
59528
|
+
return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
|
|
59529
|
+
}
|
|
59530
|
+
function removeFromEach(types, flag) {
|
|
59531
|
+
for (var i = 0; i < types.length; i++) {
|
|
59532
|
+
types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
|
|
59301
59533
|
}
|
|
59302
|
-
return false;
|
|
59303
59534
|
}
|
|
59304
59535
|
// If the given list of types contains more than one union of primitive types, replace the
|
|
59305
59536
|
// first with a union containing an intersection of those primitive types, then remove the
|
|
@@ -59408,6 +59639,9 @@ var ts;
|
|
|
59408
59639
|
if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
|
|
59409
59640
|
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
|
|
59410
59641
|
}
|
|
59642
|
+
if (includes & 262144 /* IncludesMissingType */) {
|
|
59643
|
+
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
59644
|
+
}
|
|
59411
59645
|
if (typeSet.length === 0) {
|
|
59412
59646
|
return unknownType;
|
|
59413
59647
|
}
|
|
@@ -59424,10 +59658,13 @@ var ts;
|
|
|
59424
59658
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
59425
59659
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
59426
59660
|
}
|
|
59427
|
-
else if (
|
|
59428
|
-
|
|
59661
|
+
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
59662
|
+
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
59663
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
59664
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
59429
59665
|
}
|
|
59430
|
-
else if (
|
|
59666
|
+
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
59667
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
59431
59668
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
59432
59669
|
}
|
|
59433
59670
|
else {
|
|
@@ -59507,18 +59744,56 @@ var ts;
|
|
|
59507
59744
|
type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) :
|
|
59508
59745
|
type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false));
|
|
59509
59746
|
}
|
|
59510
|
-
|
|
59511
|
-
|
|
59512
|
-
|
|
59513
|
-
|
|
59514
|
-
|
|
59515
|
-
|
|
59516
|
-
|
|
59517
|
-
|
|
59518
|
-
var
|
|
59519
|
-
|
|
59520
|
-
|
|
59521
|
-
|
|
59747
|
+
/**
|
|
59748
|
+
* This roughly mirrors `resolveMappedTypeMembers` in the nongeneric case, except only reports a union of the keys calculated,
|
|
59749
|
+
* rather than manufacturing the properties. We can't just fetch the `constraintType` since that would ignore mappings
|
|
59750
|
+
* and mapping the `constraintType` directly ignores how mapped types map _properties_ and not keys (thus ignoring subtype
|
|
59751
|
+
* reduction in the constraintType) when possible.
|
|
59752
|
+
* @param noIndexSignatures Indicates if _string_ index signatures should be elided. (other index signatures are always reported)
|
|
59753
|
+
*/
|
|
59754
|
+
function getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) {
|
|
59755
|
+
var typeParameter = getTypeParameterFromMappedType(type);
|
|
59756
|
+
var constraintType = getConstraintTypeFromMappedType(type);
|
|
59757
|
+
var nameType = getNameTypeFromMappedType(type.target || type);
|
|
59758
|
+
if (!nameType && !noIndexSignatures) {
|
|
59759
|
+
// no mapping and no filtering required, just quickly bail to returning the constraint in the common case
|
|
59760
|
+
return constraintType;
|
|
59761
|
+
}
|
|
59762
|
+
var keyTypes = [];
|
|
59763
|
+
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
59764
|
+
// We have a { [P in keyof T]: X }
|
|
59765
|
+
// `getApparentType` on the T in a generic mapped type can trigger a circularity
|
|
59766
|
+
// (conditionals and `infer` types create a circular dependency in the constraint resolution)
|
|
59767
|
+
// so we only eagerly manifest the keys if the constraint is nongeneric
|
|
59768
|
+
if (!isGenericIndexType(constraintType)) {
|
|
59769
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
|
|
59770
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType);
|
|
59771
|
+
}
|
|
59772
|
+
else {
|
|
59773
|
+
// we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later
|
|
59774
|
+
// since it's not safe to resolve the shape of modifier type
|
|
59775
|
+
return getIndexTypeForGenericType(type, stringsOnly);
|
|
59776
|
+
}
|
|
59777
|
+
}
|
|
59778
|
+
else {
|
|
59779
|
+
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
59780
|
+
}
|
|
59781
|
+
if (isGenericIndexType(constraintType)) { // include the generic component in the resulting type
|
|
59782
|
+
forEachType(constraintType, addMemberForKeyType);
|
|
59783
|
+
}
|
|
59784
|
+
// we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType,
|
|
59785
|
+
// so we can return the union that preserves aliases/origin data if possible
|
|
59786
|
+
var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes);
|
|
59787
|
+
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
59788
|
+
return constraintType;
|
|
59789
|
+
}
|
|
59790
|
+
return result;
|
|
59791
|
+
function addMemberForKeyType(keyType) {
|
|
59792
|
+
var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType;
|
|
59793
|
+
// `keyof` currently always returns `string | number` for concrete `string` index signatures - the below ternary keeps that behavior for mapped types
|
|
59794
|
+
// See `getLiteralTypeFromProperties` where there's a similar ternary to cause the same behavior.
|
|
59795
|
+
keyTypes.push(propNameType === stringType ? stringOrNumberType : propNameType);
|
|
59796
|
+
}
|
|
59522
59797
|
}
|
|
59523
59798
|
// Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N<P>]: X }, to simply N<K>. This however presumes
|
|
59524
59799
|
// that N distributes over union types, i.e. that N<A | B | C> is equivalent to N<A> | N<B> | N<C>. Specifically, we only
|
|
@@ -59576,7 +59851,7 @@ var ts;
|
|
|
59576
59851
|
return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59577
59852
|
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59578
59853
|
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
59579
|
-
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) :
|
|
59854
|
+
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
59580
59855
|
type === wildcardType ? wildcardType :
|
|
59581
59856
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
59582
59857
|
type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType :
|
|
@@ -61160,7 +61435,7 @@ var ts;
|
|
|
61160
61435
|
var mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
61161
61436
|
if (typeVariable !== mappedTypeVariable) {
|
|
61162
61437
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
61163
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t
|
|
61438
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
61164
61439
|
if (!type.declaration.nameType) {
|
|
61165
61440
|
if (isArrayType(t)) {
|
|
61166
61441
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -61202,7 +61477,7 @@ var ts;
|
|
|
61202
61477
|
}
|
|
61203
61478
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
61204
61479
|
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
|
|
61205
|
-
return elementType
|
|
61480
|
+
return isErrorType(elementType) ? errorType :
|
|
61206
61481
|
createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
61207
61482
|
}
|
|
61208
61483
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
@@ -61441,7 +61716,7 @@ var ts;
|
|
|
61441
61716
|
return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body);
|
|
61442
61717
|
}
|
|
61443
61718
|
function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
|
|
61444
|
-
return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
|
|
61719
|
+
return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
|
|
61445
61720
|
isContextSensitiveFunctionLikeDeclaration(func);
|
|
61446
61721
|
}
|
|
61447
61722
|
function getTypeWithoutSignatures(type) {
|
|
@@ -62313,7 +62588,8 @@ var ts;
|
|
|
62313
62588
|
var sourceStack;
|
|
62314
62589
|
var targetStack;
|
|
62315
62590
|
var maybeCount = 0;
|
|
62316
|
-
var
|
|
62591
|
+
var sourceDepth = 0;
|
|
62592
|
+
var targetDepth = 0;
|
|
62317
62593
|
var expandingFlags = 0 /* None */;
|
|
62318
62594
|
var overflow = false;
|
|
62319
62595
|
var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid
|
|
@@ -62321,12 +62597,12 @@ var ts;
|
|
|
62321
62597
|
var incompatibleStack = [];
|
|
62322
62598
|
var inPropertyCheck = false;
|
|
62323
62599
|
ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
62324
|
-
var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage);
|
|
62600
|
+
var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage);
|
|
62325
62601
|
if (incompatibleStack.length) {
|
|
62326
62602
|
reportIncompatibleStack();
|
|
62327
62603
|
}
|
|
62328
62604
|
if (overflow) {
|
|
62329
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth:
|
|
62605
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth });
|
|
62330
62606
|
var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
|
62331
62607
|
if (errorOutputContainer) {
|
|
62332
62608
|
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
|
|
@@ -62553,6 +62829,10 @@ var ts;
|
|
|
62553
62829
|
}
|
|
62554
62830
|
}
|
|
62555
62831
|
message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
|
|
62832
|
+
var typeLengthLimit = 30;
|
|
62833
|
+
if (!errorInfo && compilerOptions.pretty && (sourceType.length > typeLengthLimit || targetType.length > typeLengthLimit)) {
|
|
62834
|
+
message = formatMessageForTypes(message, typeLengthLimit, sourceType, targetType);
|
|
62835
|
+
}
|
|
62556
62836
|
}
|
|
62557
62837
|
}
|
|
62558
62838
|
else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1
|
|
@@ -62562,6 +62842,15 @@ var ts;
|
|
|
62562
62842
|
}
|
|
62563
62843
|
reportError(message, generalizedSourceType, targetType);
|
|
62564
62844
|
}
|
|
62845
|
+
/** Move a printed type to be on its own line if it is longer than 30 characters */
|
|
62846
|
+
function formatMessageForTypes(diagnostic, typeLengthLimit, source, target) {
|
|
62847
|
+
var message = diagnostic.message;
|
|
62848
|
+
if (source.length > typeLengthLimit)
|
|
62849
|
+
message = message.replace(" '{0}' ", ":\n{0}\n\n");
|
|
62850
|
+
if (target.length > typeLengthLimit)
|
|
62851
|
+
message = message.replace(" '{1}'", ":\n{1}").replace(".", "");
|
|
62852
|
+
return __assign(__assign({}, diagnostic), { message: message });
|
|
62853
|
+
}
|
|
62565
62854
|
function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
|
|
62566
62855
|
var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
|
|
62567
62856
|
var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
|
|
@@ -62606,13 +62895,17 @@ var ts;
|
|
|
62606
62895
|
}
|
|
62607
62896
|
return true;
|
|
62608
62897
|
}
|
|
62898
|
+
function isRelatedToWorker(source, target, reportErrors) {
|
|
62899
|
+
return isRelatedTo(source, target, 3 /* Both */, reportErrors);
|
|
62900
|
+
}
|
|
62609
62901
|
/**
|
|
62610
62902
|
* Compare two types and return
|
|
62611
62903
|
* * Ternary.True if they are related with no assumptions,
|
|
62612
62904
|
* * Ternary.Maybe if they are related with assumptions of other relationships, or
|
|
62613
62905
|
* * Ternary.False if they are not related.
|
|
62614
62906
|
*/
|
|
62615
|
-
function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
|
|
62907
|
+
function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) {
|
|
62908
|
+
if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; }
|
|
62616
62909
|
if (reportErrors === void 0) { reportErrors = false; }
|
|
62617
62910
|
if (intersectionState === void 0) { intersectionState = 0 /* None */; }
|
|
62618
62911
|
// Before normalization: if `source` is type an object type, and `target` is primitive,
|
|
@@ -62633,7 +62926,7 @@ var ts;
|
|
|
62633
62926
|
if (source === target)
|
|
62634
62927
|
return -1 /* True */;
|
|
62635
62928
|
if (relation === identityRelation) {
|
|
62636
|
-
return isIdenticalTo(source, target);
|
|
62929
|
+
return isIdenticalTo(source, target, recursionFlags);
|
|
62637
62930
|
}
|
|
62638
62931
|
// We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common,
|
|
62639
62932
|
// and otherwise, for type parameters in large unions, causes us to need to compare the union to itself,
|
|
@@ -62684,8 +62977,8 @@ var ts;
|
|
|
62684
62977
|
var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
|
|
62685
62978
|
var calls = getSignaturesOfType(source, 0 /* Call */);
|
|
62686
62979
|
var constructs = getSignaturesOfType(source, 1 /* Construct */);
|
|
62687
|
-
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) ||
|
|
62688
|
-
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) {
|
|
62980
|
+
if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) ||
|
|
62981
|
+
constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
62689
62982
|
reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
|
|
62690
62983
|
}
|
|
62691
62984
|
else {
|
|
@@ -62702,11 +62995,11 @@ var ts;
|
|
|
62702
62995
|
// and we need to handle "each" relations before "some" relations for the same kind of type.
|
|
62703
62996
|
if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
|
|
62704
62997
|
result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
|
|
62705
|
-
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck
|
|
62998
|
+
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
|
|
62706
62999
|
structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
|
|
62707
63000
|
}
|
|
62708
63001
|
if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
|
|
62709
|
-
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
|
|
63002
|
+
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
|
|
62710
63003
|
resetErrorInfo(saveErrorInfo);
|
|
62711
63004
|
}
|
|
62712
63005
|
}
|
|
@@ -62728,7 +63021,7 @@ var ts;
|
|
|
62728
63021
|
if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) {
|
|
62729
63022
|
if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
62730
63023
|
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
62731
|
-
if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63024
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
62732
63025
|
resetErrorInfo(saveErrorInfo);
|
|
62733
63026
|
}
|
|
62734
63027
|
}
|
|
@@ -62752,7 +63045,7 @@ var ts;
|
|
|
62752
63045
|
if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
62753
63046
|
isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) {
|
|
62754
63047
|
inPropertyCheck = true;
|
|
62755
|
-
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck
|
|
63048
|
+
result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags);
|
|
62756
63049
|
inPropertyCheck = false;
|
|
62757
63050
|
}
|
|
62758
63051
|
reportErrorResults(source, target, result, isComparingJsxAttributes);
|
|
@@ -62784,7 +63077,7 @@ var ts;
|
|
|
62784
63077
|
var targetTypes = target.types;
|
|
62785
63078
|
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
62786
63079
|
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
62787
|
-
if (intrinsicAttributes
|
|
63080
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
62788
63081
|
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
62789
63082
|
// do not report top error
|
|
62790
63083
|
return result;
|
|
@@ -62827,7 +63120,7 @@ var ts;
|
|
|
62827
63120
|
}
|
|
62828
63121
|
}
|
|
62829
63122
|
}
|
|
62830
|
-
function isIdenticalTo(source, target) {
|
|
63123
|
+
function isIdenticalTo(source, target, recursionFlags) {
|
|
62831
63124
|
if (source.flags !== target.flags)
|
|
62832
63125
|
return 0 /* False */;
|
|
62833
63126
|
if (source.flags & 67358815 /* Singleton */)
|
|
@@ -62840,7 +63133,7 @@ var ts;
|
|
|
62840
63133
|
}
|
|
62841
63134
|
return result_7;
|
|
62842
63135
|
}
|
|
62843
|
-
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None
|
|
63136
|
+
return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags);
|
|
62844
63137
|
}
|
|
62845
63138
|
function getTypeOfPropertyInTypes(types, name) {
|
|
62846
63139
|
var appendPropType = function (propTypes, type) {
|
|
@@ -62921,7 +63214,7 @@ var ts;
|
|
|
62921
63214
|
}
|
|
62922
63215
|
return { value: true };
|
|
62923
63216
|
}
|
|
62924
|
-
if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
|
|
63217
|
+
if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) {
|
|
62925
63218
|
if (reportErrors) {
|
|
62926
63219
|
reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
|
|
62927
63220
|
}
|
|
@@ -62961,7 +63254,7 @@ var ts;
|
|
|
62961
63254
|
}
|
|
62962
63255
|
var match = getMatchingUnionConstituentForType(target, source);
|
|
62963
63256
|
if (match) {
|
|
62964
|
-
var related = isRelatedTo(source, match, /*reportErrors*/ false);
|
|
63257
|
+
var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false);
|
|
62965
63258
|
if (related) {
|
|
62966
63259
|
return related;
|
|
62967
63260
|
}
|
|
@@ -62969,14 +63262,14 @@ var ts;
|
|
|
62969
63262
|
}
|
|
62970
63263
|
for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
|
|
62971
63264
|
var type = targetTypes_1[_i];
|
|
62972
|
-
var related = isRelatedTo(source, type, /*reportErrors*/ false);
|
|
63265
|
+
var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false);
|
|
62973
63266
|
if (related) {
|
|
62974
63267
|
return related;
|
|
62975
63268
|
}
|
|
62976
63269
|
}
|
|
62977
63270
|
if (reportErrors) {
|
|
62978
63271
|
var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
|
|
62979
|
-
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
|
|
63272
|
+
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true);
|
|
62980
63273
|
}
|
|
62981
63274
|
return 0 /* False */;
|
|
62982
63275
|
}
|
|
@@ -62985,7 +63278,7 @@ var ts;
|
|
|
62985
63278
|
var targetTypes = target.types;
|
|
62986
63279
|
for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
|
|
62987
63280
|
var targetType = targetTypes_2[_i];
|
|
62988
|
-
var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63281
|
+
var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
62989
63282
|
if (!related) {
|
|
62990
63283
|
return 0 /* False */;
|
|
62991
63284
|
}
|
|
@@ -63000,7 +63293,7 @@ var ts;
|
|
|
63000
63293
|
}
|
|
63001
63294
|
var len = sourceTypes.length;
|
|
63002
63295
|
for (var i = 0; i < len; i++) {
|
|
63003
|
-
var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
|
|
63296
|
+
var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState);
|
|
63004
63297
|
if (related) {
|
|
63005
63298
|
return related;
|
|
63006
63299
|
}
|
|
@@ -63030,13 +63323,13 @@ var ts;
|
|
|
63030
63323
|
// union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`,
|
|
63031
63324
|
// the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}`
|
|
63032
63325
|
// - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union
|
|
63033
|
-
var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
63326
|
+
var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
63034
63327
|
if (related_1) {
|
|
63035
63328
|
result &= related_1;
|
|
63036
63329
|
continue;
|
|
63037
63330
|
}
|
|
63038
63331
|
}
|
|
63039
|
-
var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63332
|
+
var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63040
63333
|
if (!related) {
|
|
63041
63334
|
return 0 /* False */;
|
|
63042
63335
|
}
|
|
@@ -63068,31 +63361,31 @@ var ts;
|
|
|
63068
63361
|
// Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_.
|
|
63069
63362
|
// We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by
|
|
63070
63363
|
// the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be)
|
|
63071
|
-
related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t);
|
|
63364
|
+
related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t);
|
|
63072
63365
|
}
|
|
63073
63366
|
else if (variance === 1 /* Covariant */) {
|
|
63074
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63367
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63075
63368
|
}
|
|
63076
63369
|
else if (variance === 2 /* Contravariant */) {
|
|
63077
|
-
related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63370
|
+
related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63078
63371
|
}
|
|
63079
63372
|
else if (variance === 3 /* Bivariant */) {
|
|
63080
63373
|
// In the bivariant case we first compare contravariantly without reporting
|
|
63081
63374
|
// errors. Then, if that doesn't succeed, we compare covariantly with error
|
|
63082
63375
|
// reporting. Thus, error elaboration will be based on the the covariant check,
|
|
63083
63376
|
// which is generally easier to reason about.
|
|
63084
|
-
related = isRelatedTo(t, s, /*reportErrors*/ false);
|
|
63377
|
+
related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false);
|
|
63085
63378
|
if (!related) {
|
|
63086
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63379
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63087
63380
|
}
|
|
63088
63381
|
}
|
|
63089
63382
|
else {
|
|
63090
63383
|
// In the invariant case we first compare covariantly, and only when that
|
|
63091
63384
|
// succeeds do we proceed to compare contravariantly. Thus, error elaboration
|
|
63092
63385
|
// will typically be based on the covariant check.
|
|
63093
|
-
related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63386
|
+
related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63094
63387
|
if (related) {
|
|
63095
|
-
related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63388
|
+
related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63096
63389
|
}
|
|
63097
63390
|
}
|
|
63098
63391
|
if (!related) {
|
|
@@ -63108,7 +63401,7 @@ var ts;
|
|
|
63108
63401
|
// Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are
|
|
63109
63402
|
// equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion
|
|
63110
63403
|
// and issue an error. Otherwise, actually compare the structure of the two types.
|
|
63111
|
-
function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
63404
|
+
function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) {
|
|
63112
63405
|
if (overflow) {
|
|
63113
63406
|
return 0 /* False */;
|
|
63114
63407
|
}
|
|
@@ -63152,7 +63445,7 @@ var ts;
|
|
|
63152
63445
|
return 3 /* Maybe */;
|
|
63153
63446
|
}
|
|
63154
63447
|
}
|
|
63155
|
-
if (
|
|
63448
|
+
if (sourceDepth === 100 || targetDepth === 100) {
|
|
63156
63449
|
overflow = true;
|
|
63157
63450
|
return 0 /* False */;
|
|
63158
63451
|
}
|
|
@@ -63160,13 +63453,18 @@ var ts;
|
|
|
63160
63453
|
var maybeStart = maybeCount;
|
|
63161
63454
|
maybeKeys[maybeCount] = id;
|
|
63162
63455
|
maybeCount++;
|
|
63163
|
-
|
|
63164
|
-
|
|
63165
|
-
|
|
63456
|
+
if (recursionFlags & 1 /* Source */) {
|
|
63457
|
+
sourceStack[sourceDepth] = source;
|
|
63458
|
+
sourceDepth++;
|
|
63459
|
+
}
|
|
63460
|
+
if (recursionFlags & 2 /* Target */) {
|
|
63461
|
+
targetStack[targetDepth] = target;
|
|
63462
|
+
targetDepth++;
|
|
63463
|
+
}
|
|
63166
63464
|
var saveExpandingFlags = expandingFlags;
|
|
63167
|
-
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack,
|
|
63465
|
+
if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
|
|
63168
63466
|
expandingFlags |= 1 /* Source */;
|
|
63169
|
-
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack,
|
|
63467
|
+
if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
|
|
63170
63468
|
expandingFlags |= 2 /* Target */;
|
|
63171
63469
|
var originalHandler;
|
|
63172
63470
|
var propagatingVarianceFlags = 0;
|
|
@@ -63183,7 +63481,8 @@ var ts;
|
|
|
63183
63481
|
sourceIdStack: sourceStack.map(function (t) { return t.id; }),
|
|
63184
63482
|
targetId: target.id,
|
|
63185
63483
|
targetIdStack: targetStack.map(function (t) { return t.id; }),
|
|
63186
|
-
depth:
|
|
63484
|
+
depth: sourceDepth,
|
|
63485
|
+
targetDepth: targetDepth
|
|
63187
63486
|
});
|
|
63188
63487
|
}
|
|
63189
63488
|
var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */;
|
|
@@ -63191,9 +63490,14 @@ var ts;
|
|
|
63191
63490
|
outofbandVarianceMarkerHandler = originalHandler;
|
|
63192
63491
|
}
|
|
63193
63492
|
expandingFlags = saveExpandingFlags;
|
|
63194
|
-
|
|
63493
|
+
if (recursionFlags & 1 /* Source */) {
|
|
63494
|
+
sourceDepth--;
|
|
63495
|
+
}
|
|
63496
|
+
if (recursionFlags & 2 /* Target */) {
|
|
63497
|
+
targetDepth--;
|
|
63498
|
+
}
|
|
63195
63499
|
if (result) {
|
|
63196
|
-
if (result === -1 /* True */ ||
|
|
63500
|
+
if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
|
|
63197
63501
|
if (result === -1 /* True */ || result === 3 /* Maybe */) {
|
|
63198
63502
|
// If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe
|
|
63199
63503
|
// results as having succeeded once we reach depth 0, but never record Ternary.Unknown results.
|
|
@@ -63247,7 +63551,7 @@ var ts;
|
|
|
63247
63551
|
if (constraints !== source.types) {
|
|
63248
63552
|
source = getIntersectionType(constraints);
|
|
63249
63553
|
if (!(source.flags & 2097152 /* Intersection */)) {
|
|
63250
|
-
return isRelatedTo(source, target, /*reportErrors*/ false);
|
|
63554
|
+
return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false);
|
|
63251
63555
|
}
|
|
63252
63556
|
}
|
|
63253
63557
|
}
|
|
@@ -63269,22 +63573,22 @@ var ts;
|
|
|
63269
63573
|
var flags = source.flags & target.flags;
|
|
63270
63574
|
if (relation === identityRelation && !(flags & 524288 /* Object */)) {
|
|
63271
63575
|
if (flags & 4194304 /* Index */) {
|
|
63272
|
-
return isRelatedTo(source.type, target.type, /*reportErrors*/ false);
|
|
63576
|
+
return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false);
|
|
63273
63577
|
}
|
|
63274
63578
|
var result_8 = 0 /* False */;
|
|
63275
63579
|
if (flags & 8388608 /* IndexedAccess */) {
|
|
63276
|
-
if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) {
|
|
63277
|
-
if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) {
|
|
63580
|
+
if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63581
|
+
if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63278
63582
|
return result_8;
|
|
63279
63583
|
}
|
|
63280
63584
|
}
|
|
63281
63585
|
}
|
|
63282
63586
|
if (flags & 16777216 /* Conditional */) {
|
|
63283
63587
|
if (source.root.isDistributive === target.root.isDistributive) {
|
|
63284
|
-
if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) {
|
|
63285
|
-
if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) {
|
|
63286
|
-
if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) {
|
|
63287
|
-
if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) {
|
|
63588
|
+
if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63589
|
+
if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63590
|
+
if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
63591
|
+
if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) {
|
|
63288
63592
|
return result_8;
|
|
63289
63593
|
}
|
|
63290
63594
|
}
|
|
@@ -63293,7 +63597,7 @@ var ts;
|
|
|
63293
63597
|
}
|
|
63294
63598
|
}
|
|
63295
63599
|
if (flags & 33554432 /* Substitution */) {
|
|
63296
|
-
return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false);
|
|
63600
|
+
return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false);
|
|
63297
63601
|
}
|
|
63298
63602
|
return 0 /* False */;
|
|
63299
63603
|
}
|
|
@@ -63318,47 +63622,71 @@ var ts;
|
|
|
63318
63622
|
}
|
|
63319
63623
|
// For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T],
|
|
63320
63624
|
// and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
|
|
63321
|
-
if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
|
|
63322
|
-
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
|
|
63625
|
+
if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) ||
|
|
63626
|
+
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) {
|
|
63323
63627
|
return result;
|
|
63324
63628
|
}
|
|
63325
63629
|
if (target.flags & 262144 /* TypeParameter */) {
|
|
63326
63630
|
// A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q].
|
|
63327
|
-
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
|
|
63631
|
+
if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) {
|
|
63328
63632
|
if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) {
|
|
63329
63633
|
var templateType = getTemplateTypeFromMappedType(source);
|
|
63330
63634
|
var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
|
|
63331
|
-
if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
|
|
63635
|
+
if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) {
|
|
63332
63636
|
return result;
|
|
63333
63637
|
}
|
|
63334
63638
|
}
|
|
63335
63639
|
}
|
|
63336
63640
|
}
|
|
63337
63641
|
else if (target.flags & 4194304 /* Index */) {
|
|
63338
|
-
var
|
|
63642
|
+
var targetType_1 = target.type;
|
|
63339
63643
|
// A keyof S is related to a keyof T if T is related to S.
|
|
63340
63644
|
if (source.flags & 4194304 /* Index */) {
|
|
63341
|
-
if (result = isRelatedTo(
|
|
63645
|
+
if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) {
|
|
63342
63646
|
return result;
|
|
63343
63647
|
}
|
|
63344
63648
|
}
|
|
63345
|
-
if (isTupleType(
|
|
63649
|
+
if (isTupleType(targetType_1)) {
|
|
63346
63650
|
// An index type can have a tuple type target when the tuple type contains variadic elements.
|
|
63347
63651
|
// Check if the source is related to the known keys of the tuple type.
|
|
63348
|
-
if (result = isRelatedTo(source, getKnownKeysOfTupleType(
|
|
63652
|
+
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) {
|
|
63349
63653
|
return result;
|
|
63350
63654
|
}
|
|
63351
63655
|
}
|
|
63352
63656
|
else {
|
|
63353
63657
|
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
|
|
63354
63658
|
// simplified form of T or, if T doesn't simplify, the constraint of T.
|
|
63355
|
-
var constraint = getSimplifiedTypeOrConstraint(
|
|
63659
|
+
var constraint = getSimplifiedTypeOrConstraint(targetType_1);
|
|
63356
63660
|
if (constraint) {
|
|
63357
63661
|
// We require Ternary.True here such that circular constraints don't cause
|
|
63358
63662
|
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
|
63359
63663
|
// 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
|
|
63360
63664
|
// related to other types.
|
|
63361
|
-
if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1 /* True */) {
|
|
63665
|
+
if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) {
|
|
63666
|
+
return -1 /* True */;
|
|
63667
|
+
}
|
|
63668
|
+
}
|
|
63669
|
+
else if (isGenericMappedType(targetType_1)) {
|
|
63670
|
+
// generic mapped types that don't simplify or have a constraint still have a very simple set of keys we can compare against
|
|
63671
|
+
// - their nameType or constraintType.
|
|
63672
|
+
// In many ways, this comparison is a deferred version of what `getIndexTypeForMappedType` does to actually resolve the keys for _non_-generic types
|
|
63673
|
+
var nameType_1 = getNameTypeFromMappedType(targetType_1);
|
|
63674
|
+
var constraintType = getConstraintTypeFromMappedType(targetType_1);
|
|
63675
|
+
var targetKeys = void 0;
|
|
63676
|
+
if (nameType_1 && isMappedTypeWithKeyofConstraintDeclaration(targetType_1)) {
|
|
63677
|
+
// we need to get the apparent mappings and union them with the generic mappings, since some properties may be
|
|
63678
|
+
// missing from the `constraintType` which will otherwise be mapped in the object
|
|
63679
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1));
|
|
63680
|
+
var mappedKeys_1 = [];
|
|
63681
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */,
|
|
63682
|
+
/*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); });
|
|
63683
|
+
// We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side)
|
|
63684
|
+
targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false));
|
|
63685
|
+
}
|
|
63686
|
+
else {
|
|
63687
|
+
targetKeys = nameType_1 || constraintType;
|
|
63688
|
+
}
|
|
63689
|
+
if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) {
|
|
63362
63690
|
return -1 /* True */;
|
|
63363
63691
|
}
|
|
63364
63692
|
}
|
|
@@ -63368,8 +63696,8 @@ var ts;
|
|
|
63368
63696
|
if (source.flags & 8388608 /* IndexedAccess */) {
|
|
63369
63697
|
// Relate components directly before falling back to constraint relationships
|
|
63370
63698
|
// A type S[K] is related to a type T[J] if S is related to T and K is related to J.
|
|
63371
|
-
if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
|
|
63372
|
-
result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
|
|
63699
|
+
if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) {
|
|
63700
|
+
result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors);
|
|
63373
63701
|
}
|
|
63374
63702
|
if (result) {
|
|
63375
63703
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -63394,7 +63722,7 @@ var ts;
|
|
|
63394
63722
|
// create a new chain for the constraint error
|
|
63395
63723
|
resetErrorInfo(saveErrorInfo);
|
|
63396
63724
|
}
|
|
63397
|
-
if (result = isRelatedTo(source, constraint, reportErrors)) {
|
|
63725
|
+
if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) {
|
|
63398
63726
|
return result;
|
|
63399
63727
|
}
|
|
63400
63728
|
// prefer the shorter chain of the constraint comparison chain, and the direct comparison chain
|
|
@@ -63434,13 +63762,14 @@ var ts;
|
|
|
63434
63762
|
// A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`.
|
|
63435
63763
|
if (includeOptional
|
|
63436
63764
|
? !(filteredByApplicability.flags & 131072 /* Never */)
|
|
63437
|
-
: isRelatedTo(targetKeys, sourceKeys)) {
|
|
63765
|
+
: isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) {
|
|
63766
|
+
var templateType_1 = getTemplateTypeFromMappedType(target);
|
|
63438
63767
|
var typeParameter = getTypeParameterFromMappedType(target);
|
|
63439
63768
|
// Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj`
|
|
63440
63769
|
// to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`.
|
|
63441
|
-
var nonNullComponent = extractTypesOfKind(
|
|
63770
|
+
var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */);
|
|
63442
63771
|
if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) {
|
|
63443
|
-
if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
|
|
63772
|
+
if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) {
|
|
63444
63773
|
return result;
|
|
63445
63774
|
}
|
|
63446
63775
|
}
|
|
@@ -63460,7 +63789,7 @@ var ts;
|
|
|
63460
63789
|
: typeParameter;
|
|
63461
63790
|
var indexedAccessType = getIndexedAccessType(source, indexingType);
|
|
63462
63791
|
// Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type.
|
|
63463
|
-
if (result = isRelatedTo(indexedAccessType,
|
|
63792
|
+
if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) {
|
|
63464
63793
|
return result;
|
|
63465
63794
|
}
|
|
63466
63795
|
}
|
|
@@ -63487,10 +63816,11 @@ var ts;
|
|
|
63487
63816
|
newParam.mapper = distributionMapper;
|
|
63488
63817
|
}
|
|
63489
63818
|
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
|
|
63490
|
-
var
|
|
63491
|
-
|
|
63492
|
-
|
|
63493
|
-
|
|
63819
|
+
var expanding = isDeeplyNestedType(target, targetStack, targetDepth);
|
|
63820
|
+
var localResult = expanding ? 3 /* Maybe */ : undefined;
|
|
63821
|
+
if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false))) {
|
|
63822
|
+
if (!skipFalse && !expanding) {
|
|
63823
|
+
localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false);
|
|
63494
63824
|
}
|
|
63495
63825
|
}
|
|
63496
63826
|
if (localResult) {
|
|
@@ -63500,6 +63830,9 @@ var ts;
|
|
|
63500
63830
|
}
|
|
63501
63831
|
else if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
63502
63832
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
63833
|
+
if (relation === comparableRelation) {
|
|
63834
|
+
return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */;
|
|
63835
|
+
}
|
|
63503
63836
|
// Report unreliable variance for type variables referenced in template literal type placeholders.
|
|
63504
63837
|
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
|
|
63505
63838
|
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
@@ -63515,34 +63848,33 @@ var ts;
|
|
|
63515
63848
|
var constraint = getConstraintOfType(source);
|
|
63516
63849
|
if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
63517
63850
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
63518
|
-
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
|
|
63851
|
+
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
63519
63852
|
resetErrorInfo(saveErrorInfo);
|
|
63520
63853
|
return result;
|
|
63521
63854
|
}
|
|
63522
63855
|
}
|
|
63523
63856
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
63524
|
-
else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63857
|
+
else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
63525
63858
|
resetErrorInfo(saveErrorInfo);
|
|
63526
63859
|
return result;
|
|
63527
63860
|
}
|
|
63528
63861
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
63529
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
63862
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
63530
63863
|
resetErrorInfo(saveErrorInfo);
|
|
63531
63864
|
return result;
|
|
63532
63865
|
}
|
|
63533
63866
|
}
|
|
63534
63867
|
}
|
|
63535
63868
|
else if (source.flags & 4194304 /* Index */) {
|
|
63536
|
-
if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
|
|
63869
|
+
if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) {
|
|
63537
63870
|
resetErrorInfo(saveErrorInfo);
|
|
63538
63871
|
return result;
|
|
63539
63872
|
}
|
|
63540
63873
|
}
|
|
63541
|
-
else if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
63874
|
+
else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) {
|
|
63542
63875
|
if (!(target.flags & 134217728 /* TemplateLiteral */)) {
|
|
63543
|
-
var
|
|
63544
|
-
|
|
63545
|
-
if (result = isRelatedTo(constraint, target, reportErrors)) {
|
|
63876
|
+
var constraint = getBaseConstraintOfType(source);
|
|
63877
|
+
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
63546
63878
|
resetErrorInfo(saveErrorInfo);
|
|
63547
63879
|
return result;
|
|
63548
63880
|
}
|
|
@@ -63550,14 +63882,14 @@ var ts;
|
|
|
63550
63882
|
}
|
|
63551
63883
|
else if (source.flags & 268435456 /* StringMapping */) {
|
|
63552
63884
|
if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
|
|
63553
|
-
if (result = isRelatedTo(source.type, target.type, reportErrors)) {
|
|
63885
|
+
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
63554
63886
|
resetErrorInfo(saveErrorInfo);
|
|
63555
63887
|
return result;
|
|
63556
63888
|
}
|
|
63557
63889
|
}
|
|
63558
63890
|
else {
|
|
63559
63891
|
var constraint = getBaseConstraintOfType(source);
|
|
63560
|
-
if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
|
|
63892
|
+
if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) {
|
|
63561
63893
|
resetErrorInfo(saveErrorInfo);
|
|
63562
63894
|
return result;
|
|
63563
63895
|
}
|
|
@@ -63565,27 +63897,32 @@ var ts;
|
|
|
63565
63897
|
}
|
|
63566
63898
|
else if (source.flags & 16777216 /* Conditional */) {
|
|
63567
63899
|
if (target.flags & 16777216 /* Conditional */) {
|
|
63568
|
-
//
|
|
63569
|
-
//
|
|
63570
|
-
//
|
|
63571
|
-
|
|
63572
|
-
|
|
63573
|
-
|
|
63574
|
-
|
|
63575
|
-
|
|
63576
|
-
var
|
|
63577
|
-
|
|
63578
|
-
|
|
63579
|
-
|
|
63580
|
-
|
|
63581
|
-
|
|
63582
|
-
|
|
63583
|
-
|
|
63584
|
-
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
|
|
63900
|
+
// If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
|
|
63901
|
+
// the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
|
|
63902
|
+
// types, which might expand forever.
|
|
63903
|
+
if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
|
|
63904
|
+
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
|
|
63905
|
+
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
|
|
63906
|
+
// and Y1 is related to Y2.
|
|
63907
|
+
var sourceParams = source.root.inferTypeParameters;
|
|
63908
|
+
var sourceExtends = source.extendsType;
|
|
63909
|
+
var mapper = void 0;
|
|
63910
|
+
if (sourceParams) {
|
|
63911
|
+
// If the source has infer type parameters, we instantiate them in the context of the target
|
|
63912
|
+
var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker);
|
|
63913
|
+
inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */);
|
|
63914
|
+
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
|
|
63915
|
+
mapper = ctx.mapper;
|
|
63585
63916
|
}
|
|
63586
|
-
if (
|
|
63587
|
-
|
|
63588
|
-
|
|
63917
|
+
if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
|
|
63918
|
+
(isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) {
|
|
63919
|
+
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) {
|
|
63920
|
+
result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors);
|
|
63921
|
+
}
|
|
63922
|
+
if (result) {
|
|
63923
|
+
resetErrorInfo(saveErrorInfo);
|
|
63924
|
+
return result;
|
|
63925
|
+
}
|
|
63589
63926
|
}
|
|
63590
63927
|
}
|
|
63591
63928
|
}
|
|
@@ -63594,19 +63931,23 @@ var ts;
|
|
|
63594
63931
|
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
|
|
63595
63932
|
var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
|
|
63596
63933
|
if (distributiveConstraint) {
|
|
63597
|
-
if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
|
|
63934
|
+
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
63598
63935
|
resetErrorInfo(saveErrorInfo);
|
|
63599
63936
|
return result;
|
|
63600
63937
|
}
|
|
63601
63938
|
}
|
|
63602
63939
|
}
|
|
63603
|
-
//
|
|
63604
|
-
//
|
|
63605
|
-
|
|
63606
|
-
|
|
63607
|
-
|
|
63608
|
-
|
|
63609
|
-
|
|
63940
|
+
// We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
|
|
63941
|
+
// on the comparison.
|
|
63942
|
+
if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
|
|
63943
|
+
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
|
|
63944
|
+
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
|
|
63945
|
+
var defaultConstraint = getDefaultConstraintOfConditionalType(source);
|
|
63946
|
+
if (defaultConstraint) {
|
|
63947
|
+
if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) {
|
|
63948
|
+
resetErrorInfo(saveErrorInfo);
|
|
63949
|
+
return result;
|
|
63950
|
+
}
|
|
63610
63951
|
}
|
|
63611
63952
|
}
|
|
63612
63953
|
}
|
|
@@ -63650,7 +63991,7 @@ var ts;
|
|
|
63650
63991
|
}
|
|
63651
63992
|
else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
|
|
63652
63993
|
if (relation !== identityRelation) {
|
|
63653
|
-
return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors);
|
|
63994
|
+
return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors);
|
|
63654
63995
|
}
|
|
63655
63996
|
else {
|
|
63656
63997
|
// By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple
|
|
@@ -63772,10 +64113,10 @@ var ts;
|
|
|
63772
64113
|
var result_11;
|
|
63773
64114
|
var targetConstraint = getConstraintTypeFromMappedType(target);
|
|
63774
64115
|
var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
|
|
63775
|
-
if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
|
|
64116
|
+
if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
|
|
63776
64117
|
var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
|
|
63777
64118
|
if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
|
|
63778
|
-
return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
|
|
64119
|
+
return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
|
|
63779
64120
|
}
|
|
63780
64121
|
}
|
|
63781
64122
|
}
|
|
@@ -63907,7 +64248,7 @@ var ts;
|
|
|
63907
64248
|
var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */);
|
|
63908
64249
|
var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
|
|
63909
64250
|
var effectiveSource = getTypeOfSourceProperty(sourceProp);
|
|
63910
|
-
return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64251
|
+
return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
63911
64252
|
}
|
|
63912
64253
|
function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
|
|
63913
64254
|
var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
|
|
@@ -64089,7 +64430,7 @@ var ts;
|
|
|
64089
64430
|
var targetType = targetTypeArguments[i];
|
|
64090
64431
|
var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) :
|
|
64091
64432
|
removeMissingType(targetType, !!(targetFlags & 2 /* Optional */));
|
|
64092
|
-
var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64433
|
+
var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState);
|
|
64093
64434
|
if (!related) {
|
|
64094
64435
|
if (reportErrors && (targetArity > 1 || sourceArity > 1)) {
|
|
64095
64436
|
if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
|
|
@@ -64283,7 +64624,7 @@ var ts;
|
|
|
64283
64624
|
* See signatureAssignableTo, compareSignaturesIdentical
|
|
64284
64625
|
*/
|
|
64285
64626
|
function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
|
|
64286
|
-
return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter,
|
|
64627
|
+
return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers));
|
|
64287
64628
|
}
|
|
64288
64629
|
function signaturesIdenticalTo(source, target, kind) {
|
|
64289
64630
|
var sourceSignatures = getSignaturesOfType(source, kind);
|
|
@@ -64316,7 +64657,7 @@ var ts;
|
|
|
64316
64657
|
var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */)
|
|
64317
64658
|
? propType
|
|
64318
64659
|
: getTypeWithFacts(propType, 524288 /* NEUndefined */);
|
|
64319
|
-
var related = isRelatedTo(type, targetInfo.type, reportErrors);
|
|
64660
|
+
var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors);
|
|
64320
64661
|
if (!related) {
|
|
64321
64662
|
if (reportErrors) {
|
|
64322
64663
|
reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
|
|
@@ -64339,7 +64680,7 @@ var ts;
|
|
|
64339
64680
|
return result;
|
|
64340
64681
|
}
|
|
64341
64682
|
function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) {
|
|
64342
|
-
var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors);
|
|
64683
|
+
var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors);
|
|
64343
64684
|
if (!related && reportErrors) {
|
|
64344
64685
|
if (sourceInfo.keyType === targetInfo.keyType) {
|
|
64345
64686
|
reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
|
|
@@ -64360,7 +64701,7 @@ var ts;
|
|
|
64360
64701
|
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
64361
64702
|
var targetInfo = indexInfos_3[_i];
|
|
64362
64703
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
64363
|
-
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) :
|
|
64704
|
+
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
64364
64705
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
64365
64706
|
if (!related) {
|
|
64366
64707
|
return 0 /* False */;
|
|
@@ -64392,7 +64733,7 @@ var ts;
|
|
|
64392
64733
|
for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) {
|
|
64393
64734
|
var targetInfo = targetInfos_1[_i];
|
|
64394
64735
|
var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType);
|
|
64395
|
-
if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
|
|
64736
|
+
if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) {
|
|
64396
64737
|
return 0 /* False */;
|
|
64397
64738
|
}
|
|
64398
64739
|
}
|
|
@@ -65806,6 +66147,17 @@ var ts;
|
|
|
65806
66147
|
function isFromInferenceBlockedSource(type) {
|
|
65807
66148
|
return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
|
|
65808
66149
|
}
|
|
66150
|
+
function templateLiteralTypesDefinitelyUnrelated(source, target) {
|
|
66151
|
+
// Two template literal types with diffences in their starting or ending text spans are definitely unrelated.
|
|
66152
|
+
var sourceStart = source.texts[0];
|
|
66153
|
+
var targetStart = target.texts[0];
|
|
66154
|
+
var sourceEnd = source.texts[source.texts.length - 1];
|
|
66155
|
+
var targetEnd = target.texts[target.texts.length - 1];
|
|
66156
|
+
var startLen = Math.min(sourceStart.length, targetStart.length);
|
|
66157
|
+
var endLen = Math.min(sourceEnd.length, targetEnd.length);
|
|
66158
|
+
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
|
66159
|
+
sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen);
|
|
66160
|
+
}
|
|
65809
66161
|
function isValidBigIntString(s) {
|
|
65810
66162
|
var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false);
|
|
65811
66163
|
var success = true;
|
|
@@ -66392,8 +66744,16 @@ var ts;
|
|
|
66392
66744
|
function inferToTemplateLiteralType(source, target) {
|
|
66393
66745
|
var matches = inferTypesFromTemplateLiteralType(source, target);
|
|
66394
66746
|
var types = target.types;
|
|
66395
|
-
|
|
66396
|
-
|
|
66747
|
+
// When the target template literal contains only placeholders (meaning that inference is intended to extract
|
|
66748
|
+
// single characters and remainder strings) and inference fails to produce matches, we want to infer 'never' for
|
|
66749
|
+
// each placeholder such that instantiation with the inferred value(s) produces 'never', a type for which an
|
|
66750
|
+
// assignment check will fail. If we make no inferences, we'll likely end up with the constraint 'string' which,
|
|
66751
|
+
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
66752
|
+
// succeed. That would be a pointless and confusing outcome.
|
|
66753
|
+
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
66754
|
+
for (var i = 0; i < types.length; i++) {
|
|
66755
|
+
inferFromTypes(matches ? matches[i] : neverType, types[i]);
|
|
66756
|
+
}
|
|
66397
66757
|
}
|
|
66398
66758
|
}
|
|
66399
66759
|
function inferFromObjectTypes(source, target) {
|
|
@@ -66860,7 +67220,7 @@ var ts;
|
|
|
66860
67220
|
if (prop.isDiscriminantProperty === undefined) {
|
|
66861
67221
|
prop.isDiscriminantProperty =
|
|
66862
67222
|
(prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ &&
|
|
66863
|
-
!
|
|
67223
|
+
!isGenericType(getTypeOfSymbol(prop));
|
|
66864
67224
|
}
|
|
66865
67225
|
return !!prop.isDiscriminantProperty;
|
|
66866
67226
|
}
|
|
@@ -67379,17 +67739,19 @@ var ts;
|
|
|
67379
67739
|
function extractTypesOfKind(type, kind) {
|
|
67380
67740
|
return filterType(type, function (t) { return (t.flags & kind) !== 0; });
|
|
67381
67741
|
}
|
|
67382
|
-
// Return a new type in which occurrences of the string and
|
|
67383
|
-
// typeWithPrimitives have been replaced with occurrences of
|
|
67384
|
-
//
|
|
67742
|
+
// Return a new type in which occurrences of the string, number and bigint primitives and placeholder template
|
|
67743
|
+
// literal types in typeWithPrimitives have been replaced with occurrences of compatible and more specific types
|
|
67744
|
+
// from typeWithLiterals. This is essentially a limited form of intersection between the two types. We avoid a
|
|
67745
|
+
// true intersection because it is more costly and, when applied to union types, generates a large number of
|
|
67746
|
+
// types we don't actually care about.
|
|
67385
67747
|
function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
|
|
67386
|
-
if (
|
|
67387
|
-
|
|
67388
|
-
isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) {
|
|
67748
|
+
if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) &&
|
|
67749
|
+
maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) {
|
|
67389
67750
|
return mapType(typeWithPrimitives, function (t) {
|
|
67390
|
-
return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) :
|
|
67391
|
-
t
|
|
67392
|
-
t.flags &
|
|
67751
|
+
return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) :
|
|
67752
|
+
isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) :
|
|
67753
|
+
t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) :
|
|
67754
|
+
t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t;
|
|
67393
67755
|
});
|
|
67394
67756
|
}
|
|
67395
67757
|
return typeWithPrimitives;
|
|
@@ -67470,10 +67832,10 @@ var ts;
|
|
|
67470
67832
|
isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */);
|
|
67471
67833
|
return isLengthPushOrUnshift || isElementAssignment;
|
|
67472
67834
|
}
|
|
67473
|
-
function isDeclarationWithExplicitTypeAnnotation(
|
|
67474
|
-
return (
|
|
67475
|
-
|
|
67476
|
-
|
|
67835
|
+
function isDeclarationWithExplicitTypeAnnotation(node) {
|
|
67836
|
+
return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) &&
|
|
67837
|
+
!!(ts.getEffectiveTypeAnnotationNode(node) ||
|
|
67838
|
+
ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
|
|
67477
67839
|
}
|
|
67478
67840
|
function getExplicitTypeOfSymbol(symbol, diagnostic) {
|
|
67479
67841
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) {
|
|
@@ -68190,7 +68552,7 @@ var ts;
|
|
|
68190
68552
|
var narrowedPropType = narrowType(propType);
|
|
68191
68553
|
return filterType(type, function (t) {
|
|
68192
68554
|
var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
|
|
68193
|
-
return !(
|
|
68555
|
+
return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType);
|
|
68194
68556
|
});
|
|
68195
68557
|
}
|
|
68196
68558
|
function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) {
|
|
@@ -68299,6 +68661,9 @@ var ts;
|
|
|
68299
68661
|
case 102 /* InstanceOfKeyword */:
|
|
68300
68662
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
68301
68663
|
case 101 /* InKeyword */:
|
|
68664
|
+
if (ts.isPrivateIdentifier(expr.left)) {
|
|
68665
|
+
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
68666
|
+
}
|
|
68302
68667
|
var target = getReferenceCandidate(expr.right);
|
|
68303
68668
|
var leftType = getTypeOfNode(expr.left);
|
|
68304
68669
|
if (leftType.flags & 128 /* StringLiteral */) {
|
|
@@ -68328,6 +68693,22 @@ var ts;
|
|
|
68328
68693
|
}
|
|
68329
68694
|
return type;
|
|
68330
68695
|
}
|
|
68696
|
+
function narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue) {
|
|
68697
|
+
var target = getReferenceCandidate(expr.right);
|
|
68698
|
+
if (!isMatchingReference(reference, target)) {
|
|
68699
|
+
return type;
|
|
68700
|
+
}
|
|
68701
|
+
ts.Debug.assertNode(expr.left, ts.isPrivateIdentifier);
|
|
68702
|
+
var symbol = getSymbolForPrivateIdentifierExpression(expr.left);
|
|
68703
|
+
if (symbol === undefined) {
|
|
68704
|
+
return type;
|
|
68705
|
+
}
|
|
68706
|
+
var classSymbol = symbol.parent;
|
|
68707
|
+
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
68708
|
+
? getTypeOfSymbol(classSymbol)
|
|
68709
|
+
: getDeclaredTypeOfSymbol(classSymbol);
|
|
68710
|
+
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
|
68711
|
+
}
|
|
68331
68712
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
68332
68713
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
68333
68714
|
// When operator is === and type of value excludes undefined, null and undefined is removed from type of obj in true branch.
|
|
@@ -68354,6 +68735,9 @@ var ts;
|
|
|
68354
68735
|
assumeTrue = !assumeTrue;
|
|
68355
68736
|
}
|
|
68356
68737
|
var valueType = getTypeOfExpression(value);
|
|
68738
|
+
if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) {
|
|
68739
|
+
return getUnionType([nullType, undefinedType]);
|
|
68740
|
+
}
|
|
68357
68741
|
if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) {
|
|
68358
68742
|
if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) {
|
|
68359
68743
|
return valueType;
|
|
@@ -68637,16 +69021,7 @@ var ts;
|
|
|
68637
69021
|
}
|
|
68638
69022
|
function getNarrowedType(type, candidate, assumeTrue, isRelated) {
|
|
68639
69023
|
if (!assumeTrue) {
|
|
68640
|
-
return filterType(type, function (t) {
|
|
68641
|
-
if (!isRelated(t, candidate)) {
|
|
68642
|
-
return true;
|
|
68643
|
-
}
|
|
68644
|
-
var constraint = getBaseConstraintOfType(t);
|
|
68645
|
-
if (constraint && constraint !== t) {
|
|
68646
|
-
return !isRelated(constraint, candidate);
|
|
68647
|
-
}
|
|
68648
|
-
return false;
|
|
68649
|
-
});
|
|
69024
|
+
return filterType(type, function (t) { return !isRelated(t, candidate); });
|
|
68650
69025
|
}
|
|
68651
69026
|
// If the current type is a union type, remove all constituents that couldn't be instances of
|
|
68652
69027
|
// the candidate type. If one or more constituents remain, return a union of those.
|
|
@@ -69758,8 +70133,7 @@ var ts;
|
|
|
69758
70133
|
if (result) {
|
|
69759
70134
|
return result;
|
|
69760
70135
|
}
|
|
69761
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
|
|
69762
|
-
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
70136
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69763
70137
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
69764
70138
|
}
|
|
69765
70139
|
}
|
|
@@ -69782,8 +70156,8 @@ var ts;
|
|
|
69782
70156
|
}
|
|
69783
70157
|
if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function
|
|
69784
70158
|
// Get the awaited type without the `Awaited<T>` alias
|
|
69785
|
-
var contextualAwaitedType = mapType(contextualReturnType,
|
|
69786
|
-
return contextualAwaitedType && getUnionType([
|
|
70159
|
+
var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias);
|
|
70160
|
+
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
|
|
69787
70161
|
}
|
|
69788
70162
|
return contextualReturnType; // Regular function or Generator function
|
|
69789
70163
|
}
|
|
@@ -69793,8 +70167,8 @@ var ts;
|
|
|
69793
70167
|
function getContextualTypeForAwaitOperand(node, contextFlags) {
|
|
69794
70168
|
var contextualType = getContextualType(node, contextFlags);
|
|
69795
70169
|
if (contextualType) {
|
|
69796
|
-
var contextualAwaitedType =
|
|
69797
|
-
return contextualAwaitedType && getUnionType([
|
|
70170
|
+
var contextualAwaitedType = getAwaitedTypeNoAlias(contextualType);
|
|
70171
|
+
return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
|
|
69798
70172
|
}
|
|
69799
70173
|
return undefined;
|
|
69800
70174
|
}
|
|
@@ -70089,9 +70463,9 @@ var ts;
|
|
|
70089
70463
|
return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName);
|
|
70090
70464
|
}
|
|
70091
70465
|
if (element.name) {
|
|
70092
|
-
var
|
|
70466
|
+
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
70093
70467
|
// We avoid calling getApplicableIndexInfo here because it performs potentially expensive intersection reduction.
|
|
70094
|
-
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t),
|
|
70468
|
+
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType_2)) === null || _a === void 0 ? void 0 : _a.type; }, /*noReductions*/ true);
|
|
70095
70469
|
}
|
|
70096
70470
|
}
|
|
70097
70471
|
return undefined;
|
|
@@ -70340,7 +70714,7 @@ var ts;
|
|
|
70340
70714
|
var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
|
|
70341
70715
|
propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
|
|
70342
70716
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70343
|
-
if (intrinsicAttribs
|
|
70717
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70344
70718
|
propsType = intersectTypes(intrinsicAttribs, propsType);
|
|
70345
70719
|
}
|
|
70346
70720
|
return propsType;
|
|
@@ -70433,7 +70807,7 @@ var ts;
|
|
|
70433
70807
|
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
|
70434
70808
|
var apparentAttributesType = attributesType;
|
|
70435
70809
|
var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
|
|
70436
|
-
if (intrinsicClassAttribs
|
|
70810
|
+
if (!isErrorType(intrinsicClassAttribs)) {
|
|
70437
70811
|
var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
|
70438
70812
|
var hostClassType = getReturnTypeOfSignature(sig);
|
|
70439
70813
|
apparentAttributesType = intersectTypes(typeParams
|
|
@@ -70441,7 +70815,7 @@ var ts;
|
|
|
70441
70815
|
: intrinsicClassAttribs, apparentAttributesType);
|
|
70442
70816
|
}
|
|
70443
70817
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70444
|
-
if (intrinsicAttribs
|
|
70818
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70445
70819
|
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
|
70446
70820
|
}
|
|
70447
70821
|
return apparentAttributesType;
|
|
@@ -70549,12 +70923,9 @@ var ts;
|
|
|
70549
70923
|
}
|
|
70550
70924
|
return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
|
|
70551
70925
|
}
|
|
70552
|
-
function isFunctionExpressionOrArrowFunction(node) {
|
|
70553
|
-
return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
|
|
70554
|
-
}
|
|
70555
70926
|
function getContextualSignatureForFunctionLikeDeclaration(node) {
|
|
70556
70927
|
// Only function expressions, arrow functions, and object literal methods are contextually typed.
|
|
70557
|
-
return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
|
|
70928
|
+
return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
|
|
70558
70929
|
? getContextualSignature(node)
|
|
70559
70930
|
: undefined;
|
|
70560
70931
|
}
|
|
@@ -70909,7 +71280,7 @@ var ts;
|
|
|
70909
71280
|
checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
|
|
70910
71281
|
}
|
|
70911
71282
|
offset = propertiesArray.length;
|
|
70912
|
-
if (spread
|
|
71283
|
+
if (isErrorType(spread)) {
|
|
70913
71284
|
continue;
|
|
70914
71285
|
}
|
|
70915
71286
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
@@ -70966,7 +71337,7 @@ var ts;
|
|
|
70966
71337
|
}
|
|
70967
71338
|
}
|
|
70968
71339
|
}
|
|
70969
|
-
if (spread
|
|
71340
|
+
if (isErrorType(spread)) {
|
|
70970
71341
|
return errorType;
|
|
70971
71342
|
}
|
|
70972
71343
|
if (spread !== emptyObjectType) {
|
|
@@ -71233,7 +71604,7 @@ var ts;
|
|
|
71233
71604
|
var links = getNodeLinks(node);
|
|
71234
71605
|
if (!links.resolvedSymbol) {
|
|
71235
71606
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
|
|
71236
|
-
if (intrinsicElementsType
|
|
71607
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
71237
71608
|
// Property case
|
|
71238
71609
|
if (!ts.isIdentifier(node.tagName))
|
|
71239
71610
|
return ts.Debug.fail();
|
|
@@ -71396,7 +71767,7 @@ var ts;
|
|
|
71396
71767
|
// var CustomTag: "h1" = "h1";
|
|
71397
71768
|
// <CustomTag> Hello World </CustomTag>
|
|
71398
71769
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
|
|
71399
|
-
if (intrinsicElementsType
|
|
71770
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
71400
71771
|
var stringLiteralTypeName = type.value;
|
|
71401
71772
|
var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
|
|
71402
71773
|
if (intrinsicProp) {
|
|
@@ -71464,7 +71835,7 @@ var ts;
|
|
|
71464
71835
|
}
|
|
71465
71836
|
function getJsxElementClassTypeAt(location) {
|
|
71466
71837
|
var type = getJsxType(JsxNames.ElementClass, location);
|
|
71467
|
-
if (type
|
|
71838
|
+
if (isErrorType(type))
|
|
71468
71839
|
return undefined;
|
|
71469
71840
|
return type;
|
|
71470
71841
|
}
|
|
@@ -71521,6 +71892,14 @@ var ts;
|
|
|
71521
71892
|
markAliasSymbolAsReferenced(jsxFactorySym);
|
|
71522
71893
|
}
|
|
71523
71894
|
}
|
|
71895
|
+
// For JsxFragment, mark jsx pragma as referenced via resolveName
|
|
71896
|
+
if (ts.isJsxOpeningFragment(node)) {
|
|
71897
|
+
var file = ts.getSourceFileOfNode(node);
|
|
71898
|
+
var localJsxNamespace = getLocalJsxNamespace(file);
|
|
71899
|
+
if (localJsxNamespace) {
|
|
71900
|
+
resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true);
|
|
71901
|
+
}
|
|
71902
|
+
}
|
|
71524
71903
|
}
|
|
71525
71904
|
if (isNodeOpeningLikeElement) {
|
|
71526
71905
|
var jsxOpeningLikeNode = node;
|
|
@@ -71770,7 +72149,7 @@ var ts;
|
|
|
71770
72149
|
}
|
|
71771
72150
|
function checkNonNullNonVoidType(type, node) {
|
|
71772
72151
|
var nonNullType = checkNonNullType(type, node);
|
|
71773
|
-
if (nonNullType
|
|
72152
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
71774
72153
|
error(node, ts.Diagnostics.Object_is_possibly_undefined);
|
|
71775
72154
|
}
|
|
71776
72155
|
return nonNullType;
|
|
@@ -71805,6 +72184,36 @@ var ts;
|
|
|
71805
72184
|
}
|
|
71806
72185
|
}
|
|
71807
72186
|
}
|
|
72187
|
+
function checkGrammarPrivateIdentifierExpression(privId) {
|
|
72188
|
+
if (!ts.getContainingClass(privId)) {
|
|
72189
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
72190
|
+
}
|
|
72191
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72192
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.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);
|
|
72193
|
+
}
|
|
72194
|
+
if (!getSymbolForPrivateIdentifierExpression(privId)) {
|
|
72195
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId));
|
|
72196
|
+
}
|
|
72197
|
+
return false;
|
|
72198
|
+
}
|
|
72199
|
+
function checkPrivateIdentifierExpression(privId) {
|
|
72200
|
+
checkGrammarPrivateIdentifierExpression(privId);
|
|
72201
|
+
var symbol = getSymbolForPrivateIdentifierExpression(privId);
|
|
72202
|
+
if (symbol) {
|
|
72203
|
+
markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false);
|
|
72204
|
+
}
|
|
72205
|
+
return anyType;
|
|
72206
|
+
}
|
|
72207
|
+
function getSymbolForPrivateIdentifierExpression(privId) {
|
|
72208
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72209
|
+
return undefined;
|
|
72210
|
+
}
|
|
72211
|
+
var links = getNodeLinks(privId);
|
|
72212
|
+
if (links.resolvedSymbol === undefined) {
|
|
72213
|
+
links.resolvedSymbol = lookupSymbolForPrivateIdentifierDeclaration(privId.escapedText, privId);
|
|
72214
|
+
}
|
|
72215
|
+
return links.resolvedSymbol;
|
|
72216
|
+
}
|
|
71808
72217
|
function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
|
|
71809
72218
|
return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
|
|
71810
72219
|
}
|
|
@@ -71887,7 +72296,7 @@ var ts;
|
|
|
71887
72296
|
}
|
|
71888
72297
|
if (isAnyLike) {
|
|
71889
72298
|
if (lexicallyScopedSymbol) {
|
|
71890
|
-
return apparentType;
|
|
72299
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71891
72300
|
}
|
|
71892
72301
|
if (!ts.getContainingClass(right)) {
|
|
71893
72302
|
grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -71911,7 +72320,8 @@ var ts;
|
|
|
71911
72320
|
if (ts.isIdentifier(left) && parentSymbol) {
|
|
71912
72321
|
markAliasReferenced(parentSymbol, node);
|
|
71913
72322
|
}
|
|
71914
|
-
return apparentType;
|
|
72323
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
72324
|
+
;
|
|
71915
72325
|
}
|
|
71916
72326
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
71917
72327
|
}
|
|
@@ -72370,7 +72780,7 @@ var ts;
|
|
|
72370
72780
|
}
|
|
72371
72781
|
function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
|
|
72372
72782
|
// Short-circuiting for improved performance.
|
|
72373
|
-
if (
|
|
72783
|
+
if (isTypeAny(type)) {
|
|
72374
72784
|
return true;
|
|
72375
72785
|
}
|
|
72376
72786
|
var prop = getPropertyOfType(type, propertyName);
|
|
@@ -72388,7 +72798,7 @@ var ts;
|
|
|
72388
72798
|
*/
|
|
72389
72799
|
function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
|
|
72390
72800
|
// Short-circuiting for improved performance.
|
|
72391
|
-
if (
|
|
72801
|
+
if (isTypeAny(containingType)) {
|
|
72392
72802
|
return true;
|
|
72393
72803
|
}
|
|
72394
72804
|
// A #private property access in an optional chain is an error dealt with by the parser.
|
|
@@ -72459,7 +72869,7 @@ var ts;
|
|
|
72459
72869
|
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
|
|
72460
72870
|
var indexExpression = node.argumentExpression;
|
|
72461
72871
|
var indexType = checkExpression(indexExpression);
|
|
72462
|
-
if (objectType
|
|
72872
|
+
if (isErrorType(objectType) || objectType === silentNeverType) {
|
|
72463
72873
|
return objectType;
|
|
72464
72874
|
}
|
|
72465
72875
|
if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
|
|
@@ -72704,7 +73114,7 @@ var ts;
|
|
|
72704
73114
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
72705
73115
|
// return type of 'wrap'.
|
|
72706
73116
|
if (node.kind !== 164 /* Decorator */) {
|
|
72707
|
-
var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
73117
|
+
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
72708
73118
|
if (contextualType) {
|
|
72709
73119
|
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
72710
73120
|
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
@@ -73162,7 +73572,7 @@ var ts;
|
|
|
73162
73572
|
return false;
|
|
73163
73573
|
var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false);
|
|
73164
73574
|
var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
|
|
73165
|
-
if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
|
|
73575
|
+
if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
|
|
73166
73576
|
return false;
|
|
73167
73577
|
}
|
|
73168
73578
|
var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
|
|
@@ -73653,7 +74063,7 @@ var ts;
|
|
|
73653
74063
|
}
|
|
73654
74064
|
return anySignature;
|
|
73655
74065
|
}
|
|
73656
|
-
if (superType
|
|
74066
|
+
if (!isErrorType(superType)) {
|
|
73657
74067
|
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
|
|
73658
74068
|
// with the type arguments specified in the extends clause.
|
|
73659
74069
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
|
|
@@ -73681,7 +74091,7 @@ var ts;
|
|
|
73681
74091
|
return silentNeverSignature;
|
|
73682
74092
|
}
|
|
73683
74093
|
var apparentType = getApparentType(funcType);
|
|
73684
|
-
if (apparentType
|
|
74094
|
+
if (isErrorType(apparentType)) {
|
|
73685
74095
|
// Another error has already been reported
|
|
73686
74096
|
return resolveErrorCall(node);
|
|
73687
74097
|
}
|
|
@@ -73697,7 +74107,7 @@ var ts;
|
|
|
73697
74107
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
73698
74108
|
// The unknownType indicates that an error already occurred (and was reported). No
|
|
73699
74109
|
// need to report another error in this case.
|
|
73700
|
-
if (funcType
|
|
74110
|
+
if (!isErrorType(funcType) && node.typeArguments) {
|
|
73701
74111
|
error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
73702
74112
|
}
|
|
73703
74113
|
return resolveUntypedCall(node);
|
|
@@ -73774,7 +74184,7 @@ var ts;
|
|
|
73774
74184
|
// signatures for overload resolution. The result type of the function call becomes
|
|
73775
74185
|
// the result type of the operation.
|
|
73776
74186
|
expressionType = getApparentType(expressionType);
|
|
73777
|
-
if (expressionType
|
|
74187
|
+
if (isErrorType(expressionType)) {
|
|
73778
74188
|
// Another error has already been reported
|
|
73779
74189
|
return resolveErrorCall(node);
|
|
73780
74190
|
}
|
|
@@ -73989,7 +74399,7 @@ var ts;
|
|
|
73989
74399
|
function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
|
|
73990
74400
|
var tagType = checkExpression(node.tag);
|
|
73991
74401
|
var apparentType = getApparentType(tagType);
|
|
73992
|
-
if (apparentType
|
|
74402
|
+
if (isErrorType(apparentType)) {
|
|
73993
74403
|
// Another error has already been reported
|
|
73994
74404
|
return resolveErrorCall(node);
|
|
73995
74405
|
}
|
|
@@ -74035,7 +74445,7 @@ var ts;
|
|
|
74035
74445
|
function resolveDecorator(node, candidatesOutArray, checkMode) {
|
|
74036
74446
|
var funcType = checkExpression(node.expression);
|
|
74037
74447
|
var apparentType = getApparentType(funcType);
|
|
74038
|
-
if (apparentType
|
|
74448
|
+
if (isErrorType(apparentType)) {
|
|
74039
74449
|
return resolveErrorCall(node);
|
|
74040
74450
|
}
|
|
74041
74451
|
var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
|
@@ -74090,7 +74500,7 @@ var ts;
|
|
|
74090
74500
|
}
|
|
74091
74501
|
var exprTypes = checkExpression(node.tagName);
|
|
74092
74502
|
var apparentType = getApparentType(exprTypes);
|
|
74093
|
-
if (apparentType
|
|
74503
|
+
if (isErrorType(apparentType)) {
|
|
74094
74504
|
return resolveErrorCall(node);
|
|
74095
74505
|
}
|
|
74096
74506
|
var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
|
|
@@ -74406,18 +74816,18 @@ var ts;
|
|
|
74406
74816
|
if (moduleSymbol) {
|
|
74407
74817
|
var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
|
|
74408
74818
|
if (esModuleSymbol) {
|
|
74409
|
-
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
|
|
74819
|
+
return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
|
|
74410
74820
|
}
|
|
74411
74821
|
}
|
|
74412
74822
|
return createPromiseReturnType(node, anyType);
|
|
74413
74823
|
}
|
|
74414
|
-
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74824
|
+
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
|
|
74415
74825
|
var _a;
|
|
74416
|
-
if (allowSyntheticDefaultImports && type && type
|
|
74826
|
+
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74417
74827
|
var synthType = type;
|
|
74418
74828
|
if (!synthType.syntheticType) {
|
|
74419
74829
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
74420
|
-
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false);
|
|
74830
|
+
var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
|
|
74421
74831
|
if (hasSyntheticDefault) {
|
|
74422
74832
|
var memberTable = ts.createSymbolTable();
|
|
74423
74833
|
var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
|
|
@@ -74506,13 +74916,11 @@ var ts;
|
|
|
74506
74916
|
case 205 /* PropertyAccessExpression */:
|
|
74507
74917
|
case 206 /* ElementAccessExpression */:
|
|
74508
74918
|
var expr = node.expression;
|
|
74509
|
-
|
|
74510
|
-
|
|
74511
|
-
|
|
74512
|
-
symbol = resolveAlias(symbol);
|
|
74513
|
-
}
|
|
74514
|
-
return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */);
|
|
74919
|
+
var symbol = getTypeOfNode(expr).symbol;
|
|
74920
|
+
if (symbol && symbol.flags & 2097152 /* Alias */) {
|
|
74921
|
+
symbol = resolveAlias(symbol);
|
|
74515
74922
|
}
|
|
74923
|
+
return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */);
|
|
74516
74924
|
}
|
|
74517
74925
|
return false;
|
|
74518
74926
|
}
|
|
@@ -74527,7 +74935,7 @@ var ts;
|
|
|
74527
74935
|
checkSourceElement(type);
|
|
74528
74936
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
74529
74937
|
var targetType = getTypeFromTypeNode(type);
|
|
74530
|
-
if (produceDiagnostics && targetType
|
|
74938
|
+
if (produceDiagnostics && !isErrorType(targetType)) {
|
|
74531
74939
|
var widenedType = getWidenedType(exprType);
|
|
74532
74940
|
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
74533
74941
|
checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
|
|
@@ -74560,7 +74968,7 @@ var ts;
|
|
|
74560
74968
|
return getGlobalImportMetaExpressionType();
|
|
74561
74969
|
case 103 /* NewKeyword */:
|
|
74562
74970
|
var type = checkNewTargetMetaProperty(node);
|
|
74563
|
-
return type
|
|
74971
|
+
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
|
|
74564
74972
|
default:
|
|
74565
74973
|
ts.Debug.assertNever(node.keywordToken);
|
|
74566
74974
|
}
|
|
@@ -74581,16 +74989,14 @@ var ts;
|
|
|
74581
74989
|
}
|
|
74582
74990
|
}
|
|
74583
74991
|
function checkImportMetaProperty(node) {
|
|
74584
|
-
if (moduleKind
|
|
74585
|
-
if (
|
|
74586
|
-
|
|
74587
|
-
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74588
|
-
}
|
|
74589
|
-
}
|
|
74590
|
-
else {
|
|
74591
|
-
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74992
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74993
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74994
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74592
74995
|
}
|
|
74593
74996
|
}
|
|
74997
|
+
else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) {
|
|
74998
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
74999
|
+
}
|
|
74594
75000
|
var file = ts.getSourceFileOfNode(node);
|
|
74595
75001
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
74596
75002
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
@@ -74895,7 +75301,8 @@ var ts;
|
|
|
74895
75301
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
74896
75302
|
if (globalPromiseType !== emptyGenericType) {
|
|
74897
75303
|
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
|
|
74898
|
-
|
|
75304
|
+
// Unwrap an `Awaited<T>` to `T` to improve inference.
|
|
75305
|
+
promisedType = getAwaitedTypeNoAlias(unwrapAwaitedType(promisedType)) || unknownType;
|
|
74899
75306
|
return createTypeReference(globalPromiseType, [promisedType]);
|
|
74900
75307
|
}
|
|
74901
75308
|
return unknownType;
|
|
@@ -74905,7 +75312,8 @@ var ts;
|
|
|
74905
75312
|
var globalPromiseLikeType = getGlobalPromiseLikeType(/*reportErrors*/ true);
|
|
74906
75313
|
if (globalPromiseLikeType !== emptyGenericType) {
|
|
74907
75314
|
// if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type
|
|
74908
|
-
|
|
75315
|
+
// Unwrap an `Awaited<T>` to `T` to improve inference.
|
|
75316
|
+
promisedType = getAwaitedTypeNoAlias(unwrapAwaitedType(promisedType)) || unknownType;
|
|
74909
75317
|
return createTypeReference(globalPromiseLikeType, [promisedType]);
|
|
74910
75318
|
}
|
|
74911
75319
|
return unknownType;
|
|
@@ -74953,7 +75361,7 @@ var ts;
|
|
|
74953
75361
|
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
|
74954
75362
|
// return type of the body should be unwrapped to its awaited type, which we will wrap in
|
|
74955
75363
|
// the native Promise<T> type later in this function.
|
|
74956
|
-
returnType = checkAwaitedType(returnType, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75364
|
+
returnType = unwrapAwaitedType(checkAwaitedType(returnType, /*withAlias*/ false, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member));
|
|
74957
75365
|
}
|
|
74958
75366
|
}
|
|
74959
75367
|
else if (isGenerator) { // Generator or AsyncGenerator function
|
|
@@ -75171,7 +75579,7 @@ var ts;
|
|
|
75171
75579
|
// Promise/A+ compatible implementation will always assimilate any foreign promise, so the
|
|
75172
75580
|
// return type of the body should be unwrapped to its awaited type, which should be wrapped in
|
|
75173
75581
|
// the native Promise<T> type by the caller.
|
|
75174
|
-
type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75582
|
+
type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member));
|
|
75175
75583
|
}
|
|
75176
75584
|
if (type.flags & 131072 /* Never */) {
|
|
75177
75585
|
hasReturnOfTypeNever = true;
|
|
@@ -75356,7 +75764,7 @@ var ts;
|
|
|
75356
75764
|
var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
|
|
75357
75765
|
if (returnOrPromisedType) {
|
|
75358
75766
|
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function
|
|
75359
|
-
var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75767
|
+
var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75360
75768
|
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
|
|
75361
75769
|
}
|
|
75362
75770
|
else { // Normal function
|
|
@@ -75531,9 +75939,9 @@ var ts;
|
|
|
75531
75939
|
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module);
|
|
75532
75940
|
diagnostics.add(diagnostic);
|
|
75533
75941
|
}
|
|
75534
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75942
|
+
if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75535
75943
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
75536
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75944
|
+
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
|
|
75537
75945
|
diagnostics.add(diagnostic);
|
|
75538
75946
|
}
|
|
75539
75947
|
}
|
|
@@ -75557,8 +75965,8 @@ var ts;
|
|
|
75557
75965
|
}
|
|
75558
75966
|
}
|
|
75559
75967
|
var operandType = checkExpression(node.expression);
|
|
75560
|
-
var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75561
|
-
if (awaitedType === operandType && awaitedType
|
|
75968
|
+
var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75969
|
+
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
75562
75970
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
|
|
75563
75971
|
}
|
|
75564
75972
|
return awaitedType;
|
|
@@ -75707,11 +76115,29 @@ var ts;
|
|
|
75707
76115
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75708
76116
|
return silentNeverType;
|
|
75709
76117
|
}
|
|
75710
|
-
|
|
76118
|
+
if (ts.isPrivateIdentifier(left)) {
|
|
76119
|
+
if (languageVersion < 99 /* ESNext */) {
|
|
76120
|
+
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
76121
|
+
}
|
|
76122
|
+
// Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type
|
|
76123
|
+
// which provides us with the opportunity to emit more detailed errors
|
|
76124
|
+
if (!getNodeLinks(left).resolvedSymbol && ts.getContainingClass(left)) {
|
|
76125
|
+
var isUncheckedJS = isUncheckedJSSuggestion(left, rightType.symbol, /*excludeClasses*/ true);
|
|
76126
|
+
reportNonexistentProperty(left, rightType, isUncheckedJS);
|
|
76127
|
+
}
|
|
76128
|
+
}
|
|
76129
|
+
else {
|
|
76130
|
+
leftType = checkNonNullType(leftType, left);
|
|
76131
|
+
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
76132
|
+
// Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
|
|
76133
|
+
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
76134
|
+
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
76135
|
+
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol);
|
|
76136
|
+
}
|
|
76137
|
+
}
|
|
75711
76138
|
rightType = checkNonNullType(rightType, right);
|
|
75712
76139
|
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
75713
|
-
// The in operator requires the
|
|
75714
|
-
// and the right operand to be
|
|
76140
|
+
// The in operator requires the right operand to be
|
|
75715
76141
|
//
|
|
75716
76142
|
// 1. assignable to the non-primitive type,
|
|
75717
76143
|
// 2. an unconstrained type parameter,
|
|
@@ -75729,10 +76155,6 @@ var ts;
|
|
|
75729
76155
|
// unless *all* instantiations would result in an error.
|
|
75730
76156
|
//
|
|
75731
76157
|
// The result is always of the Boolean primitive type.
|
|
75732
|
-
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
75733
|
-
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
75734
|
-
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
|
75735
|
-
}
|
|
75736
76158
|
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
75737
76159
|
if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
75738
76160
|
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
@@ -76199,7 +76621,7 @@ var ts;
|
|
|
76199
76621
|
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
|
|
76200
76622
|
// Otherwise, the result is of type Any.
|
|
76201
76623
|
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
|
76202
|
-
resultType = leftType
|
|
76624
|
+
resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
|
|
76203
76625
|
}
|
|
76204
76626
|
// Symbols are not allowed at all in arithmetic expressions
|
|
76205
76627
|
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
|
|
@@ -76412,8 +76834,8 @@ var ts;
|
|
|
76412
76834
|
var wouldWorkWithAwait = false;
|
|
76413
76835
|
var errNode = errorNode || operatorToken;
|
|
76414
76836
|
if (isRelated) {
|
|
76415
|
-
var awaitedLeftType =
|
|
76416
|
-
var awaitedRightType =
|
|
76837
|
+
var awaitedLeftType = getAwaitedTypeNoAlias(leftType);
|
|
76838
|
+
var awaitedRightType = getAwaitedTypeNoAlias(rightType);
|
|
76417
76839
|
wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
|
|
76418
76840
|
&& !!(awaitedLeftType && awaitedRightType)
|
|
76419
76841
|
&& isRelated(awaitedLeftType, awaitedRightType);
|
|
@@ -76957,7 +77379,7 @@ var ts;
|
|
|
76957
77379
|
}
|
|
76958
77380
|
}
|
|
76959
77381
|
function checkParenthesizedExpression(node, checkMode) {
|
|
76960
|
-
if (ts.isJSDocTypeAssertion(node)) {
|
|
77382
|
+
if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) {
|
|
76961
77383
|
var type = ts.getJSDocTypeAssertionType(node);
|
|
76962
77384
|
return checkAssertionWorker(type, type, node.expression, checkMode);
|
|
76963
77385
|
}
|
|
@@ -76978,6 +77400,8 @@ var ts;
|
|
|
76978
77400
|
switch (kind) {
|
|
76979
77401
|
case 79 /* Identifier */:
|
|
76980
77402
|
return checkIdentifier(node, checkMode);
|
|
77403
|
+
case 80 /* PrivateIdentifier */:
|
|
77404
|
+
return checkPrivateIdentifierExpression(node);
|
|
76981
77405
|
case 108 /* ThisKeyword */:
|
|
76982
77406
|
return checkThisExpression(node);
|
|
76983
77407
|
case 106 /* SuperKeyword */:
|
|
@@ -77677,7 +78101,7 @@ var ts;
|
|
|
77677
78101
|
}
|
|
77678
78102
|
function getTypeParametersForTypeReference(node) {
|
|
77679
78103
|
var type = getTypeFromTypeReference(node);
|
|
77680
|
-
if (type
|
|
78104
|
+
if (!isErrorType(type)) {
|
|
77681
78105
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
77682
78106
|
if (symbol) {
|
|
77683
78107
|
return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
|
|
@@ -77693,7 +78117,7 @@ var ts;
|
|
|
77693
78117
|
}
|
|
77694
78118
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
77695
78119
|
var type = getTypeFromTypeReference(node);
|
|
77696
|
-
if (type
|
|
78120
|
+
if (!isErrorType(type)) {
|
|
77697
78121
|
if (node.typeArguments && produceDiagnostics) {
|
|
77698
78122
|
var typeParameters = getTypeParametersForTypeReference(node);
|
|
77699
78123
|
if (typeParameters) {
|
|
@@ -78297,12 +78721,15 @@ var ts;
|
|
|
78297
78721
|
/**
|
|
78298
78722
|
* Gets the "awaited type" of a type.
|
|
78299
78723
|
* @param type The type to await.
|
|
78724
|
+
* @param withAlias When `true`, wraps the "awaited type" in `Awaited<T>` if needed.
|
|
78300
78725
|
* @remarks The "awaited type" of an expression is its "promised type" if the expression is a
|
|
78301
78726
|
* Promise-like type; otherwise, it is the type of the expression. This is used to reflect
|
|
78302
78727
|
* The runtime behavior of the `await` keyword.
|
|
78303
78728
|
*/
|
|
78304
|
-
function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
|
|
78305
|
-
var awaitedType =
|
|
78729
|
+
function checkAwaitedType(type, withAlias, errorNode, diagnosticMessage, arg0) {
|
|
78730
|
+
var awaitedType = withAlias ?
|
|
78731
|
+
getAwaitedType(type, errorNode, diagnosticMessage, arg0) :
|
|
78732
|
+
getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0);
|
|
78306
78733
|
return awaitedType || errorType;
|
|
78307
78734
|
}
|
|
78308
78735
|
/**
|
|
@@ -78324,9 +78751,10 @@ var ts;
|
|
|
78324
78751
|
}
|
|
78325
78752
|
return false;
|
|
78326
78753
|
}
|
|
78754
|
+
/**
|
|
78755
|
+
* For a generic `Awaited<T>`, gets `T`.
|
|
78756
|
+
*/
|
|
78327
78757
|
function unwrapAwaitedType(type) {
|
|
78328
|
-
if (!type)
|
|
78329
|
-
return undefined;
|
|
78330
78758
|
return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) :
|
|
78331
78759
|
isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] :
|
|
78332
78760
|
type;
|
|
@@ -78375,6 +78803,15 @@ var ts;
|
|
|
78375
78803
|
* This is used to reflect the runtime behavior of the `await` keyword.
|
|
78376
78804
|
*/
|
|
78377
78805
|
function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
|
|
78806
|
+
var awaitedType = getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0);
|
|
78807
|
+
return awaitedType && createAwaitedTypeIfNeeded(awaitedType);
|
|
78808
|
+
}
|
|
78809
|
+
/**
|
|
78810
|
+
* Gets the "awaited type" of a type without introducing an `Awaited<T>` wrapper.
|
|
78811
|
+
*
|
|
78812
|
+
* @see {@link getAwaitedType}
|
|
78813
|
+
*/
|
|
78814
|
+
function getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0) {
|
|
78378
78815
|
if (isTypeAny(type)) {
|
|
78379
78816
|
return type;
|
|
78380
78817
|
}
|
|
@@ -78385,13 +78822,12 @@ var ts;
|
|
|
78385
78822
|
// If we've already cached an awaited type, return a possible `Awaited<T>` for it.
|
|
78386
78823
|
var typeAsAwaitable = type;
|
|
78387
78824
|
if (typeAsAwaitable.awaitedTypeOfType) {
|
|
78388
|
-
return
|
|
78825
|
+
return typeAsAwaitable.awaitedTypeOfType;
|
|
78389
78826
|
}
|
|
78390
78827
|
// For a union, get a union of the awaited types of each constituent.
|
|
78391
78828
|
if (type.flags & 1048576 /* Union */) {
|
|
78392
|
-
var mapper = errorNode ? function (constituentType) { return
|
|
78393
|
-
typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
78394
|
-
return typeAsAwaitable.awaitedTypeOfType && createAwaitedTypeIfNeeded(typeAsAwaitable.awaitedTypeOfType);
|
|
78829
|
+
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
|
|
78830
|
+
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
78395
78831
|
}
|
|
78396
78832
|
var promisedType = getPromisedTypeOfPromise(type);
|
|
78397
78833
|
if (promisedType) {
|
|
@@ -78437,12 +78873,12 @@ var ts;
|
|
|
78437
78873
|
// Keep track of the type we're about to unwrap to avoid bad recursive promise types.
|
|
78438
78874
|
// See the comments above for more information.
|
|
78439
78875
|
awaitedTypeStack.push(type.id);
|
|
78440
|
-
var awaitedType =
|
|
78876
|
+
var awaitedType = getAwaitedTypeNoAlias(promisedType, errorNode, diagnosticMessage, arg0);
|
|
78441
78877
|
awaitedTypeStack.pop();
|
|
78442
78878
|
if (!awaitedType) {
|
|
78443
78879
|
return undefined;
|
|
78444
78880
|
}
|
|
78445
|
-
return
|
|
78881
|
+
return typeAsAwaitable.awaitedTypeOfType = awaitedType;
|
|
78446
78882
|
}
|
|
78447
78883
|
// The type was not a promise, so it could not be unwrapped any further.
|
|
78448
78884
|
// As long as the type does not have a callable "then" property, it is
|
|
@@ -78466,7 +78902,7 @@ var ts;
|
|
|
78466
78902
|
}
|
|
78467
78903
|
return undefined;
|
|
78468
78904
|
}
|
|
78469
|
-
return
|
|
78905
|
+
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
78470
78906
|
}
|
|
78471
78907
|
/**
|
|
78472
78908
|
* Checks the return type of an async function to ensure it is a compatible
|
|
@@ -78507,21 +78943,21 @@ var ts;
|
|
|
78507
78943
|
//
|
|
78508
78944
|
var returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78509
78945
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78510
|
-
if (returnType
|
|
78946
|
+
if (isErrorType(returnType)) {
|
|
78511
78947
|
return;
|
|
78512
78948
|
}
|
|
78513
78949
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
78514
78950
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
|
|
78515
78951
|
// The promise type was not a valid type reference to the global promise type, so we
|
|
78516
78952
|
// report an error and return the unknown type.
|
|
78517
|
-
error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(
|
|
78953
|
+
error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
78518
78954
|
return;
|
|
78519
78955
|
}
|
|
78520
78956
|
}
|
|
78521
78957
|
else {
|
|
78522
78958
|
// Always mark the type node as referenced if it points to a value
|
|
78523
78959
|
markTypeNodeAsReferenced(returnTypeNode);
|
|
78524
|
-
if (returnType
|
|
78960
|
+
if (isErrorType(returnType)) {
|
|
78525
78961
|
return;
|
|
78526
78962
|
}
|
|
78527
78963
|
var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
|
|
@@ -78531,7 +78967,7 @@ var ts;
|
|
|
78531
78967
|
}
|
|
78532
78968
|
var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
|
|
78533
78969
|
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
|
|
78534
|
-
if (promiseConstructorType
|
|
78970
|
+
if (isErrorType(promiseConstructorType)) {
|
|
78535
78971
|
if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
|
|
78536
78972
|
error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
78537
78973
|
}
|
|
@@ -78558,7 +78994,7 @@ var ts;
|
|
|
78558
78994
|
return;
|
|
78559
78995
|
}
|
|
78560
78996
|
}
|
|
78561
|
-
checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
78997
|
+
checkAwaitedType(returnType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
78562
78998
|
}
|
|
78563
78999
|
/** Check a decorator */
|
|
78564
79000
|
function checkDecorator(node) {
|
|
@@ -78840,6 +79276,12 @@ var ts;
|
|
|
78840
79276
|
}
|
|
78841
79277
|
}
|
|
78842
79278
|
}
|
|
79279
|
+
function checkJSDocAccessibilityModifiers(node) {
|
|
79280
|
+
var host = ts.getJSDocHost(node);
|
|
79281
|
+
if (host && ts.isPrivateIdentifierClassElementDeclaration(host)) {
|
|
79282
|
+
error(node, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
|
|
79283
|
+
}
|
|
79284
|
+
}
|
|
78843
79285
|
function getIdentifierFromEntityNameExpression(node) {
|
|
78844
79286
|
switch (node.kind) {
|
|
78845
79287
|
case 79 /* Identifier */:
|
|
@@ -79583,7 +80025,7 @@ var ts;
|
|
|
79583
80025
|
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
|
79584
80026
|
// initializer is consistent with type associated with the node
|
|
79585
80027
|
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
|
79586
|
-
if (type
|
|
80028
|
+
if (!isErrorType(type) && !isErrorType(declarationType) &&
|
|
79587
80029
|
!isTypeIdenticalTo(type, declarationType) &&
|
|
79588
80030
|
!(symbol.flags & 67108864 /* Assignment */)) {
|
|
79589
80031
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
|
|
@@ -80586,7 +81028,7 @@ var ts;
|
|
|
80586
81028
|
var isGenerator = !!(functionFlags & 1 /* Generator */);
|
|
80587
81029
|
var isAsync = !!(functionFlags & 2 /* Async */);
|
|
80588
81030
|
return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType :
|
|
80589
|
-
isAsync ?
|
|
81031
|
+
isAsync ? getAwaitedTypeNoAlias(returnType) || errorType :
|
|
80590
81032
|
returnType;
|
|
80591
81033
|
}
|
|
80592
81034
|
function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
|
|
@@ -80626,7 +81068,7 @@ var ts;
|
|
|
80626
81068
|
else if (getReturnTypeFromAnnotation(container)) {
|
|
80627
81069
|
var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
|
|
80628
81070
|
var unwrappedExprType = functionFlags & 2 /* Async */
|
|
80629
|
-
? checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
|
|
81071
|
+
? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)
|
|
80630
81072
|
: exprType;
|
|
80631
81073
|
if (unwrappedReturnType) {
|
|
80632
81074
|
// If the function has a return type, but promisedType is
|
|
@@ -81081,7 +81523,7 @@ var ts;
|
|
|
81081
81523
|
checkTypeReferenceNode(typeRefNode);
|
|
81082
81524
|
if (produceDiagnostics) {
|
|
81083
81525
|
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
81084
|
-
if (t
|
|
81526
|
+
if (!isErrorType(t)) {
|
|
81085
81527
|
if (isValidBaseType(t)) {
|
|
81086
81528
|
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
81087
81529
|
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
@@ -82130,7 +82572,7 @@ var ts;
|
|
|
82130
82572
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
82131
82573
|
}
|
|
82132
82574
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
82133
|
-
checkExternalEmitHelpers(node,
|
|
82575
|
+
checkExternalEmitHelpers(node, 4194304 /* CreateBinding */);
|
|
82134
82576
|
}
|
|
82135
82577
|
checkGrammarExportDeclaration(node);
|
|
82136
82578
|
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
|
|
@@ -82175,11 +82617,15 @@ var ts;
|
|
|
82175
82617
|
}
|
|
82176
82618
|
function checkGrammarExportDeclaration(node) {
|
|
82177
82619
|
var _a;
|
|
82178
|
-
|
|
82179
|
-
|
|
82180
|
-
|
|
82620
|
+
if (node.isTypeOnly) {
|
|
82621
|
+
if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 272 /* NamedExports */) {
|
|
82622
|
+
return checkGrammarNamedImportsOrExports(node.exportClause);
|
|
82623
|
+
}
|
|
82624
|
+
else {
|
|
82625
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
|
|
82626
|
+
}
|
|
82181
82627
|
}
|
|
82182
|
-
return
|
|
82628
|
+
return false;
|
|
82183
82629
|
}
|
|
82184
82630
|
function checkGrammarModuleElementContext(node, errorMessage) {
|
|
82185
82631
|
var isInAppropriateContext = node.parent.kind === 303 /* SourceFile */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 260 /* ModuleDeclaration */;
|
|
@@ -82489,6 +82935,10 @@ var ts;
|
|
|
82489
82935
|
return;
|
|
82490
82936
|
case 307 /* JSDocTypeExpression */:
|
|
82491
82937
|
return checkSourceElement(node.type);
|
|
82938
|
+
case 331 /* JSDocPublicTag */:
|
|
82939
|
+
case 333 /* JSDocProtectedTag */:
|
|
82940
|
+
case 332 /* JSDocPrivateTag */:
|
|
82941
|
+
return checkJSDocAccessibilityModifiers(node);
|
|
82492
82942
|
case 193 /* IndexedAccessType */:
|
|
82493
82943
|
return checkIndexedAccessType(node);
|
|
82494
82944
|
case 194 /* MappedType */:
|
|
@@ -83099,6 +83549,9 @@ var ts;
|
|
|
83099
83549
|
}
|
|
83100
83550
|
return result;
|
|
83101
83551
|
}
|
|
83552
|
+
else if (ts.isPrivateIdentifier(name)) {
|
|
83553
|
+
return getSymbolForPrivateIdentifierExpression(name);
|
|
83554
|
+
}
|
|
83102
83555
|
else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) {
|
|
83103
83556
|
var links = getNodeLinks(name);
|
|
83104
83557
|
if (links.resolvedSymbol) {
|
|
@@ -83121,7 +83574,8 @@ var ts;
|
|
|
83121
83574
|
}
|
|
83122
83575
|
else if (isTypeReferenceIdentifier(name)) {
|
|
83123
83576
|
var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
|
|
83124
|
-
|
|
83577
|
+
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
|
|
83578
|
+
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
|
|
83125
83579
|
}
|
|
83126
83580
|
if (name.parent.kind === 176 /* TypePredicate */) {
|
|
83127
83581
|
return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
|
|
@@ -83348,7 +83802,7 @@ var ts;
|
|
|
83348
83802
|
var symbol = getSymbolAtLocation(node);
|
|
83349
83803
|
if (symbol) {
|
|
83350
83804
|
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
|
83351
|
-
return declaredType
|
|
83805
|
+
return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
|
|
83352
83806
|
}
|
|
83353
83807
|
}
|
|
83354
83808
|
if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
@@ -83846,7 +84300,7 @@ var ts;
|
|
|
83846
84300
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83847
84301
|
}
|
|
83848
84302
|
var type = getDeclaredTypeOfSymbol(typeSymbol);
|
|
83849
|
-
if (type
|
|
84303
|
+
if (isErrorType(type)) {
|
|
83850
84304
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83851
84305
|
}
|
|
83852
84306
|
else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
@@ -84358,7 +84812,7 @@ var ts;
|
|
|
84358
84812
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
84359
84813
|
if (helpersModule !== unknownSymbol) {
|
|
84360
84814
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
84361
|
-
for (var helper = 1 /* FirstEmitHelper */; helper <=
|
|
84815
|
+
for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) {
|
|
84362
84816
|
if (uncheckedHelpers & helper) {
|
|
84363
84817
|
var name = getHelperName(helper);
|
|
84364
84818
|
var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */);
|
|
@@ -84410,7 +84864,8 @@ var ts;
|
|
|
84410
84864
|
case 262144 /* MakeTemplateObject */: return "__makeTemplateObject";
|
|
84411
84865
|
case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet";
|
|
84412
84866
|
case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet";
|
|
84413
|
-
case 2097152 /*
|
|
84867
|
+
case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn";
|
|
84868
|
+
case 4194304 /* CreateBinding */: return "__createBinding";
|
|
84414
84869
|
default: return ts.Debug.fail("Unrecognized helper");
|
|
84415
84870
|
}
|
|
84416
84871
|
}
|
|
@@ -85179,8 +85634,8 @@ var ts;
|
|
|
85179
85634
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
85180
85635
|
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module));
|
|
85181
85636
|
}
|
|
85182
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85183
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85637
|
+
if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85638
|
+
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
|
|
85184
85639
|
}
|
|
85185
85640
|
}
|
|
85186
85641
|
}
|
|
@@ -85849,14 +86304,27 @@ var ts;
|
|
|
85849
86304
|
return ambientModulesCache;
|
|
85850
86305
|
}
|
|
85851
86306
|
function checkGrammarImportClause(node) {
|
|
86307
|
+
var _a;
|
|
85852
86308
|
if (node.isTypeOnly && node.name && node.namedBindings) {
|
|
85853
86309
|
return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
|
|
85854
86310
|
}
|
|
86311
|
+
if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamedImports */) {
|
|
86312
|
+
return checkGrammarNamedImportsOrExports(node.namedBindings);
|
|
86313
|
+
}
|
|
85855
86314
|
return false;
|
|
85856
86315
|
}
|
|
86316
|
+
function checkGrammarNamedImportsOrExports(namedBindings) {
|
|
86317
|
+
return !!ts.forEach(namedBindings.elements, function (specifier) {
|
|
86318
|
+
if (specifier.isTypeOnly) {
|
|
86319
|
+
return grammarErrorOnFirstToken(specifier, specifier.kind === 269 /* ImportSpecifier */
|
|
86320
|
+
? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement
|
|
86321
|
+
: ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement);
|
|
86322
|
+
}
|
|
86323
|
+
});
|
|
86324
|
+
}
|
|
85857
86325
|
function checkGrammarImportCallExpression(node) {
|
|
85858
86326
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
85859
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
86327
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext);
|
|
85860
86328
|
}
|
|
85861
86329
|
if (node.typeArguments) {
|
|
85862
86330
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -86585,7 +87053,7 @@ var ts;
|
|
|
86585
87053
|
return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
|
|
86586
87054
|
case 269 /* ImportSpecifier */:
|
|
86587
87055
|
ts.Debug.type(node);
|
|
86588
|
-
return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
87056
|
+
return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86589
87057
|
case 270 /* ExportAssignment */:
|
|
86590
87058
|
ts.Debug.type(node);
|
|
86591
87059
|
return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -86597,7 +87065,7 @@ var ts;
|
|
|
86597
87065
|
return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
|
|
86598
87066
|
case 274 /* ExportSpecifier */:
|
|
86599
87067
|
ts.Debug.type(node);
|
|
86600
|
-
return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
87068
|
+
return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86601
87069
|
// Module references
|
|
86602
87070
|
case 276 /* ExternalModuleReference */:
|
|
86603
87071
|
ts.Debug.type(node);
|
|
@@ -86970,7 +87438,7 @@ var ts;
|
|
|
86970
87438
|
}
|
|
86971
87439
|
ts.createSourceMapGenerator = createSourceMapGenerator;
|
|
86972
87440
|
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
|
86973
|
-
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)
|
|
87441
|
+
var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
|
86974
87442
|
var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
|
86975
87443
|
function getLineInfo(text, lineStarts) {
|
|
86976
87444
|
return {
|
|
@@ -90262,6 +90730,7 @@ var ts;
|
|
|
90262
90730
|
|| (isExternalModuleExport(node)
|
|
90263
90731
|
&& moduleKind !== ts.ModuleKind.ES2015
|
|
90264
90732
|
&& moduleKind !== ts.ModuleKind.ES2020
|
|
90733
|
+
&& moduleKind !== ts.ModuleKind.ES2022
|
|
90265
90734
|
&& moduleKind !== ts.ModuleKind.ESNext
|
|
90266
90735
|
&& moduleKind !== ts.ModuleKind.System);
|
|
90267
90736
|
}
|
|
@@ -90538,9 +91007,11 @@ var ts;
|
|
|
90538
91007
|
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90539
91008
|
}
|
|
90540
91009
|
else {
|
|
90541
|
-
// Elide named imports if all of its import specifiers are elided.
|
|
91010
|
+
// Elide named imports if all of its import specifiers are elided and settings allow.
|
|
91011
|
+
var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
91012
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
90542
91013
|
var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
|
|
90543
|
-
return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
91014
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
90544
91015
|
}
|
|
90545
91016
|
}
|
|
90546
91017
|
/**
|
|
@@ -90549,7 +91020,7 @@ var ts;
|
|
|
90549
91020
|
* @param node The import specifier node.
|
|
90550
91021
|
*/
|
|
90551
91022
|
function visitImportSpecifier(node) {
|
|
90552
|
-
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
91023
|
+
return !node.isTypeOnly && shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90553
91024
|
}
|
|
90554
91025
|
/**
|
|
90555
91026
|
* Visits an export assignment, eliding it if it does not contain a clause that resolves
|
|
@@ -90578,12 +91049,10 @@ var ts;
|
|
|
90578
91049
|
// type checker doesn't know about any exports
|
|
90579
91050
|
return node;
|
|
90580
91051
|
}
|
|
90581
|
-
if (!resolver.isValueAliasDeclaration(node)) {
|
|
90582
|
-
// Elide the export declaration if it does not export a value.
|
|
90583
|
-
return undefined;
|
|
90584
|
-
}
|
|
90585
91052
|
// Elide the export declaration if all of its named exports are elided.
|
|
90586
|
-
var
|
|
91053
|
+
var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
91054
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
91055
|
+
var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings);
|
|
90587
91056
|
return exportClause
|
|
90588
91057
|
? factory.updateExportDeclaration(node,
|
|
90589
91058
|
/*decorators*/ undefined,
|
|
@@ -90596,16 +91065,16 @@ var ts;
|
|
|
90596
91065
|
*
|
|
90597
91066
|
* @param node The named exports node.
|
|
90598
91067
|
*/
|
|
90599
|
-
function visitNamedExports(node) {
|
|
91068
|
+
function visitNamedExports(node, allowEmpty) {
|
|
90600
91069
|
// Elide the named exports if all of its export specifiers were elided.
|
|
90601
91070
|
var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
|
|
90602
|
-
return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
91071
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
90603
91072
|
}
|
|
90604
91073
|
function visitNamespaceExports(node) {
|
|
90605
91074
|
return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
|
|
90606
91075
|
}
|
|
90607
|
-
function visitNamedExportBindings(node) {
|
|
90608
|
-
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
|
|
91076
|
+
function visitNamedExportBindings(node, allowEmpty) {
|
|
91077
|
+
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node, allowEmpty);
|
|
90609
91078
|
}
|
|
90610
91079
|
/**
|
|
90611
91080
|
* Visits an export specifier, eliding it if it does not resolve to a value.
|
|
@@ -90614,7 +91083,7 @@ var ts;
|
|
|
90614
91083
|
*/
|
|
90615
91084
|
function visitExportSpecifier(node) {
|
|
90616
91085
|
// Elide an export specifier if it does not reference a value.
|
|
90617
|
-
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
91086
|
+
return !node.isTypeOnly && resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
90618
91087
|
}
|
|
90619
91088
|
/**
|
|
90620
91089
|
* Determines whether to emit an import equals declaration.
|
|
@@ -91104,14 +91573,37 @@ var ts;
|
|
|
91104
91573
|
}
|
|
91105
91574
|
/**
|
|
91106
91575
|
* If we visit a private name, this means it is an undeclared private name.
|
|
91107
|
-
* Replace it with an empty identifier to indicate a problem with the code
|
|
91576
|
+
* Replace it with an empty identifier to indicate a problem with the code,
|
|
91577
|
+
* unless we are in a statement position - otherwise this will not trigger
|
|
91578
|
+
* a SyntaxError.
|
|
91108
91579
|
*/
|
|
91109
91580
|
function visitPrivateIdentifier(node) {
|
|
91110
91581
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
91111
91582
|
return node;
|
|
91112
91583
|
}
|
|
91584
|
+
if (ts.isStatement(node.parent)) {
|
|
91585
|
+
return node;
|
|
91586
|
+
}
|
|
91113
91587
|
return ts.setOriginalNode(factory.createIdentifier(""), node);
|
|
91114
91588
|
}
|
|
91589
|
+
/**
|
|
91590
|
+
* Visits `#id in expr`
|
|
91591
|
+
*/
|
|
91592
|
+
function visitPrivateIdentifierInInExpression(node) {
|
|
91593
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
91594
|
+
return node;
|
|
91595
|
+
}
|
|
91596
|
+
var privId = node.left;
|
|
91597
|
+
ts.Debug.assertNode(privId, ts.isPrivateIdentifier);
|
|
91598
|
+
ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */);
|
|
91599
|
+
var info = accessPrivateIdentifier(privId);
|
|
91600
|
+
if (info) {
|
|
91601
|
+
var receiver = ts.visitNode(node.right, visitor, ts.isExpression);
|
|
91602
|
+
return ts.setOriginalNode(context.getEmitHelperFactory().createClassPrivateFieldInHelper(info.brandCheckIdentifier, receiver), node);
|
|
91603
|
+
}
|
|
91604
|
+
// Private name has not been declared. Subsequent transformers will handle this error
|
|
91605
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91606
|
+
}
|
|
91115
91607
|
/**
|
|
91116
91608
|
* Visits the members of a class that has fields.
|
|
91117
91609
|
*
|
|
@@ -91498,6 +91990,9 @@ var ts;
|
|
|
91498
91990
|
}
|
|
91499
91991
|
}
|
|
91500
91992
|
}
|
|
91993
|
+
if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
|
|
91994
|
+
return visitPrivateIdentifierInInExpression(node);
|
|
91995
|
+
}
|
|
91501
91996
|
return ts.visitEachChild(node, visitor, context);
|
|
91502
91997
|
}
|
|
91503
91998
|
function createPrivateIdentifierAssignment(info, receiver, right, operator) {
|
|
@@ -94189,7 +94684,7 @@ var ts;
|
|
|
94189
94684
|
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
|
|
94190
94685
|
}
|
|
94191
94686
|
var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
|
|
94192
|
-
var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
|
|
94687
|
+
var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName);
|
|
94193
94688
|
generatedName.generatedImportReference = specifier;
|
|
94194
94689
|
specifierSourceImports.set(name, specifier);
|
|
94195
94690
|
return generatedName;
|
|
@@ -94591,7 +95086,8 @@ var ts;
|
|
|
94591
95086
|
}
|
|
94592
95087
|
}
|
|
94593
95088
|
function visitJsxExpression(node) {
|
|
94594
|
-
|
|
95089
|
+
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
95090
|
+
return node.dotDotDotToken ? factory.createSpreadElement(expression) : expression;
|
|
94595
95091
|
}
|
|
94596
95092
|
}
|
|
94597
95093
|
ts.transformJsx = transformJsx;
|
|
@@ -103904,7 +104400,7 @@ var ts;
|
|
|
103904
104400
|
/*modifiers*/ undefined, factory.createImportClause(
|
|
103905
104401
|
/*isTypeOnly*/ false,
|
|
103906
104402
|
/*name*/ undefined, factory.createNamedImports([
|
|
103907
|
-
factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
|
|
104403
|
+
factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName)
|
|
103908
104404
|
])), factory.createStringLiteral("module"));
|
|
103909
104405
|
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
103910
104406
|
var requireStatement = factory.createVariableStatement(
|
|
@@ -103944,7 +104440,7 @@ var ts;
|
|
|
103944
104440
|
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
103945
104441
|
statements = ts.append(statements, factory.createExportDeclaration(
|
|
103946
104442
|
/*decorators*/ undefined,
|
|
103947
|
-
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104443
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))])));
|
|
103948
104444
|
}
|
|
103949
104445
|
return statements;
|
|
103950
104446
|
}
|
|
@@ -103972,7 +104468,7 @@ var ts;
|
|
|
103972
104468
|
var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(
|
|
103973
104469
|
/*decorators*/ undefined,
|
|
103974
104470
|
/*modifiers*/ undefined,
|
|
103975
|
-
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
|
|
104471
|
+
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, synthName, oldIdentifier)]));
|
|
103976
104472
|
ts.setOriginalNode(exportDecl, node);
|
|
103977
104473
|
return [importDecl, exportDecl];
|
|
103978
104474
|
}
|
|
@@ -105539,7 +106035,7 @@ var ts;
|
|
|
105539
106035
|
/*modifiers*/ undefined,
|
|
105540
106036
|
/*isTypeOnly*/ false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
|
|
105541
106037
|
var gen = _a[0], exp = _a[1];
|
|
105542
|
-
return factory.createExportSpecifier(gen, exp);
|
|
106038
|
+
return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp);
|
|
105543
106039
|
}))));
|
|
105544
106040
|
}
|
|
105545
106041
|
var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */);
|
|
@@ -105913,6 +106409,7 @@ var ts;
|
|
|
105913
106409
|
function getModuleTransformer(moduleKind) {
|
|
105914
106410
|
switch (moduleKind) {
|
|
105915
106411
|
case ts.ModuleKind.ESNext:
|
|
106412
|
+
case ts.ModuleKind.ES2022:
|
|
105916
106413
|
case ts.ModuleKind.ES2020:
|
|
105917
106414
|
case ts.ModuleKind.ES2015:
|
|
105918
106415
|
return ts.transformECMAScriptModule;
|
|
@@ -107918,6 +108415,8 @@ var ts;
|
|
|
107918
108415
|
// Identifiers
|
|
107919
108416
|
case 79 /* Identifier */:
|
|
107920
108417
|
return emitIdentifier(node);
|
|
108418
|
+
case 80 /* PrivateIdentifier */:
|
|
108419
|
+
return emitPrivateIdentifier(node);
|
|
107921
108420
|
// Expressions
|
|
107922
108421
|
case 203 /* ArrayLiteralExpression */:
|
|
107923
108422
|
return emitArrayLiteralExpression(node);
|
|
@@ -109476,6 +109975,10 @@ var ts;
|
|
|
109476
109975
|
writePunctuation("}");
|
|
109477
109976
|
}
|
|
109478
109977
|
function emitImportOrExportSpecifier(node) {
|
|
109978
|
+
if (node.isTypeOnly) {
|
|
109979
|
+
writeKeyword("type");
|
|
109980
|
+
writeSpace();
|
|
109981
|
+
}
|
|
109479
109982
|
if (node.propertyName) {
|
|
109480
109983
|
emit(node.propertyName);
|
|
109481
109984
|
writeSpace();
|
|
@@ -114628,9 +115131,9 @@ var ts;
|
|
|
114628
115131
|
}
|
|
114629
115132
|
}
|
|
114630
115133
|
function pathForLibFile(libFileName) {
|
|
114631
|
-
// Support resolving to lib.dom.d.ts -> @typescript/dom, and
|
|
114632
|
-
// lib.dom.iterable.d.ts -> @typescript/dom/iterable
|
|
114633
|
-
// lib.es2015.symbol.wellknown.d.ts -> @typescript/es2015/symbol-wellknown
|
|
115134
|
+
// Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
|
|
115135
|
+
// lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
|
|
115136
|
+
// lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
|
|
114634
115137
|
var components = libFileName.split(".");
|
|
114635
115138
|
var path = components[1];
|
|
114636
115139
|
var i = 2;
|
|
@@ -114639,7 +115142,7 @@ var ts;
|
|
|
114639
115142
|
i++;
|
|
114640
115143
|
}
|
|
114641
115144
|
var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts");
|
|
114642
|
-
var localOverrideModuleResult = ts.resolveModuleName("@typescript/" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
115145
|
+
var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
114643
115146
|
if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) {
|
|
114644
115147
|
return localOverrideModuleResult.resolvedModule.resolvedFileName;
|
|
114645
115148
|
}
|
|
@@ -118497,7 +119000,7 @@ var ts;
|
|
|
118497
119000
|
var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
|
|
118498
119001
|
var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
|
|
118499
119002
|
// For classic resolution, only allow importing from node_modules/@types, not other node_modules
|
|
118500
|
-
return ts.getEmitModuleResolutionKind(options)
|
|
119003
|
+
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
|
|
118501
119004
|
function tryDirectoryWithPackageJson(packageRootIndex) {
|
|
118502
119005
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
118503
119006
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|