typescript 4.5.0-dev.20210923 → 4.5.0-dev.20210927
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 +2 -1
- package/lib/es/diagnosticMessages.generated.json +2 -1
- package/lib/fr/diagnosticMessages.generated.json +2 -1
- package/lib/it/diagnosticMessages.generated.json +2 -1
- package/lib/ja/diagnosticMessages.generated.json +2 -1
- package/lib/ko/diagnosticMessages.generated.json +2 -1
- package/lib/lib.es2021.d.ts +1 -0
- package/lib/lib.es2021.intl.d.ts +9 -0
- package/lib/pl/diagnosticMessages.generated.json +2 -1
- package/lib/pt-br/diagnosticMessages.generated.json +2 -1
- package/lib/ru/diagnosticMessages.generated.json +2 -1
- package/lib/tr/diagnosticMessages.generated.json +2 -1
- package/lib/tsc.js +1278 -386
- package/lib/tsserver.js +1487 -477
- package/lib/tsserverlibrary.d.ts +66 -15
- package/lib/tsserverlibrary.js +1487 -477
- package/lib/typescript.d.ts +64 -13
- package/lib/typescript.js +1482 -471
- package/lib/typescriptServices.d.ts +64 -13
- package/lib/typescriptServices.js +1482 -471
- package/lib/typingsInstaller.js +1413 -428
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +2 -1
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20210927";
|
|
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 */
|
|
@@ -5100,6 +5101,12 @@ var ts;
|
|
|
5100
5101
|
(function (ModuleResolutionKind) {
|
|
5101
5102
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
5102
5103
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
|
|
5104
|
+
// Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
|
|
5105
|
+
// to better support ecmascript modules and their use within node - more features are still being added, so
|
|
5106
|
+
// we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
|
|
5107
|
+
// version-anchored resolution target
|
|
5108
|
+
ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
|
|
5109
|
+
ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
|
|
5103
5110
|
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
|
|
5104
5111
|
var WatchFileKind;
|
|
5105
5112
|
(function (WatchFileKind) {
|
|
@@ -5137,6 +5144,9 @@ var ts;
|
|
|
5137
5144
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5138
5145
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5139
5146
|
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
|
|
5147
|
+
// Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
|
|
5148
|
+
ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
|
|
5149
|
+
ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext";
|
|
5140
5150
|
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
|
|
5141
5151
|
var JsxEmit;
|
|
5142
5152
|
(function (JsxEmit) {
|
|
@@ -5336,6 +5346,12 @@ var ts;
|
|
|
5336
5346
|
Extension["Jsx"] = ".jsx";
|
|
5337
5347
|
Extension["Json"] = ".json";
|
|
5338
5348
|
Extension["TsBuildInfo"] = ".tsbuildinfo";
|
|
5349
|
+
Extension["Mjs"] = ".mjs";
|
|
5350
|
+
Extension["Mts"] = ".mts";
|
|
5351
|
+
Extension["Dmts"] = ".d.mts";
|
|
5352
|
+
Extension["Cjs"] = ".cjs";
|
|
5353
|
+
Extension["Cts"] = ".cts";
|
|
5354
|
+
Extension["Dcts"] = ".d.cts";
|
|
5339
5355
|
})(Extension = ts.Extension || (ts.Extension = {}));
|
|
5340
5356
|
/* @internal */
|
|
5341
5357
|
var TransformFlags;
|
|
@@ -5482,9 +5498,10 @@ var ts;
|
|
|
5482
5498
|
ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 262144] = "MakeTemplateObject";
|
|
5483
5499
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 524288] = "ClassPrivateFieldGet";
|
|
5484
5500
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 1048576] = "ClassPrivateFieldSet";
|
|
5485
|
-
ExternalEmitHelpers[ExternalEmitHelpers["
|
|
5501
|
+
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldIn"] = 2097152] = "ClassPrivateFieldIn";
|
|
5502
|
+
ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 4194304] = "CreateBinding";
|
|
5486
5503
|
ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper";
|
|
5487
|
-
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] =
|
|
5504
|
+
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 4194304] = "LastEmitHelper";
|
|
5488
5505
|
// Helpers included by ES2015 for..of
|
|
5489
5506
|
ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes";
|
|
5490
5507
|
// Helpers included by ES2017 for..await..of
|
|
@@ -8043,7 +8060,7 @@ var ts;
|
|
|
8043
8060
|
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."),
|
|
8044
8061
|
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."),
|
|
8045
8062
|
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."),
|
|
8046
|
-
|
|
8063
|
+
Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_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_esnext_commonjs_amd_system__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."),
|
|
8047
8064
|
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'."),
|
|
8048
8065
|
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."),
|
|
8049
8066
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
@@ -8061,7 +8078,7 @@ var ts;
|
|
|
8061
8078
|
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."),
|
|
8062
8079
|
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}')'?"),
|
|
8063
8080
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
8064
|
-
|
|
8081
|
+
The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'."),
|
|
8065
8082
|
A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
|
|
8066
8083
|
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."),
|
|
8067
8084
|
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."),
|
|
@@ -8092,7 +8109,7 @@ var ts;
|
|
|
8092
8109
|
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."),
|
|
8093
8110
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8094
8111
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8095
|
-
|
|
8112
|
+
Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_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_esnext_system_or_noden_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8096
8113
|
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'."),
|
|
8097
8114
|
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'."),
|
|
8098
8115
|
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 `}`?"),
|
|
@@ -8144,7 +8161,7 @@ var ts;
|
|
|
8144
8161
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8145
8162
|
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:"),
|
|
8146
8163
|
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."),
|
|
8147
|
-
|
|
8164
|
+
Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_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_esnext_system_or_nodenex_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."),
|
|
8148
8165
|
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."),
|
|
8149
8166
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8150
8167
|
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}'?"),
|
|
@@ -8161,6 +8178,9 @@ var ts;
|
|
|
8161
8178
|
_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."),
|
|
8162
8179
|
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."),
|
|
8163
8180
|
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"),
|
|
8181
|
+
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"),
|
|
8182
|
+
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."),
|
|
8183
|
+
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."),
|
|
8164
8184
|
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."),
|
|
8165
8185
|
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."),
|
|
8166
8186
|
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),
|
|
@@ -8225,7 +8245,7 @@ var ts;
|
|
|
8225
8245
|
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."),
|
|
8226
8246
|
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."),
|
|
8227
8247
|
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."),
|
|
8228
|
-
|
|
8248
|
+
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'."),
|
|
8229
8249
|
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."),
|
|
8230
8250
|
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."),
|
|
8231
8251
|
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."),
|
|
@@ -9030,6 +9050,13 @@ var ts;
|
|
|
9030
9050
|
Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"),
|
|
9031
9051
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9032
9052
|
_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"),
|
|
9053
|
+
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
9054
|
+
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
9055
|
+
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, ts.DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
9056
|
+
package_json_scope_0_has_no_imports_defined: diag(6273, ts.DiagnosticCategory.Message, "package_json_scope_0_has_no_imports_defined_6273", "package.json scope '{0}' has no imports defined."),
|
|
9057
|
+
package_json_scope_0_explicitly_maps_specifier_1_to_null: diag(6274, ts.DiagnosticCategory.Message, "package_json_scope_0_explicitly_maps_specifier_1_to_null_6274", "package.json scope '{0}' explicitly maps specifier '{1}' to null."),
|
|
9058
|
+
package_json_scope_0_has_invalid_type_for_target_of_specifier_1: diag(6275, ts.DiagnosticCategory.Message, "package_json_scope_0_has_invalid_type_for_target_of_specifier_1_6275", "package.json scope '{0}' has invalid type for target of specifier '{1}'"),
|
|
9059
|
+
Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6276, ts.DiagnosticCategory.Message, "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276", "Export specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
9033
9060
|
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
|
|
9034
9061
|
Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."),
|
|
9035
9062
|
Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."),
|
|
@@ -9289,6 +9316,8 @@ var ts;
|
|
|
9289
9316
|
The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, ts.DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."),
|
|
9290
9317
|
yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation: diag(7057, ts.DiagnosticCategory.Error, "yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057", "'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation."),
|
|
9291
9318
|
If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1: diag(7058, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058", "If the '{0}' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '{1}';`"),
|
|
9319
|
+
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
|
|
9320
|
+
This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
|
|
9292
9321
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9293
9322
|
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
|
|
9294
9323
|
import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
|
|
@@ -11895,7 +11924,7 @@ var ts;
|
|
|
11895
11924
|
}
|
|
11896
11925
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
|
|
11897
11926
|
function getDefaultLibFileName(options) {
|
|
11898
|
-
switch (options
|
|
11927
|
+
switch (ts.getEmitScriptTarget(options)) {
|
|
11899
11928
|
case 99 /* ESNext */:
|
|
11900
11929
|
return "lib.esnext.full.d.ts";
|
|
11901
11930
|
case 8 /* ES2021 */:
|
|
@@ -13316,6 +13345,7 @@ var ts;
|
|
|
13316
13345
|
case 225 /* ClassExpression */:
|
|
13317
13346
|
case 212 /* FunctionExpression */:
|
|
13318
13347
|
case 79 /* Identifier */:
|
|
13348
|
+
case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
|
|
13319
13349
|
case 13 /* RegularExpressionLiteral */:
|
|
13320
13350
|
case 8 /* NumericLiteral */:
|
|
13321
13351
|
case 9 /* BigIntLiteral */:
|
|
@@ -13958,22 +13988,22 @@ var ts;
|
|
|
13958
13988
|
return node.end - node.pos;
|
|
13959
13989
|
}
|
|
13960
13990
|
ts.getFullWidth = getFullWidth;
|
|
13961
|
-
function getResolvedModule(sourceFile, moduleNameText) {
|
|
13962
|
-
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
|
|
13991
|
+
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
13992
|
+
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
|
|
13963
13993
|
}
|
|
13964
13994
|
ts.getResolvedModule = getResolvedModule;
|
|
13965
|
-
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
|
|
13995
|
+
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
13966
13996
|
if (!sourceFile.resolvedModules) {
|
|
13967
|
-
sourceFile.resolvedModules =
|
|
13997
|
+
sourceFile.resolvedModules = ts.createModeAwareCache();
|
|
13968
13998
|
}
|
|
13969
|
-
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
|
13999
|
+
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
13970
14000
|
}
|
|
13971
14001
|
ts.setResolvedModule = setResolvedModule;
|
|
13972
14002
|
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
13973
14003
|
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
13974
|
-
sourceFile.resolvedTypeReferenceDirectiveNames =
|
|
14004
|
+
sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
|
|
13975
14005
|
}
|
|
13976
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
|
14006
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
|
|
13977
14007
|
}
|
|
13978
14008
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
13979
14009
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
@@ -14005,11 +14035,11 @@ var ts;
|
|
|
14005
14035
|
&& oldResolution.originalPath === newResolution.originalPath;
|
|
14006
14036
|
}
|
|
14007
14037
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
14008
|
-
function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
|
|
14038
|
+
function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
|
|
14009
14039
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14010
14040
|
for (var i = 0; i < names.length; i++) {
|
|
14011
14041
|
var newResolution = newResolutions[i];
|
|
14012
|
-
var oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
|
14042
|
+
var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
|
|
14013
14043
|
var changed = oldResolution
|
|
14014
14044
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14015
14045
|
: newResolution;
|
|
@@ -14544,8 +14574,11 @@ var ts;
|
|
|
14544
14574
|
return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
|
|
14545
14575
|
}
|
|
14546
14576
|
ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
|
|
14577
|
+
function isCommonJSContainingModuleKind(kind) {
|
|
14578
|
+
return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext;
|
|
14579
|
+
}
|
|
14547
14580
|
function isEffectiveExternalModule(node, compilerOptions) {
|
|
14548
|
-
return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions)
|
|
14581
|
+
return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
|
14549
14582
|
}
|
|
14550
14583
|
ts.isEffectiveExternalModule = isEffectiveExternalModule;
|
|
14551
14584
|
/**
|
|
@@ -15663,6 +15696,8 @@ var ts;
|
|
|
15663
15696
|
node = node.parent;
|
|
15664
15697
|
}
|
|
15665
15698
|
return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
|
|
15699
|
+
case 80 /* PrivateIdentifier */:
|
|
15700
|
+
return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */;
|
|
15666
15701
|
case 79 /* Identifier */:
|
|
15667
15702
|
if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
|
|
15668
15703
|
return true;
|
|
@@ -17329,6 +17364,7 @@ var ts;
|
|
|
17329
17364
|
case 108 /* ThisKeyword */:
|
|
17330
17365
|
case 106 /* SuperKeyword */:
|
|
17331
17366
|
case 79 /* Identifier */:
|
|
17367
|
+
case 80 /* PrivateIdentifier */:
|
|
17332
17368
|
case 104 /* NullKeyword */:
|
|
17333
17369
|
case 110 /* TrueKeyword */:
|
|
17334
17370
|
case 95 /* FalseKeyword */:
|
|
@@ -17835,9 +17871,17 @@ var ts;
|
|
|
17835
17871
|
var path = outputDir
|
|
17836
17872
|
? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
|
|
17837
17873
|
: fileName;
|
|
17838
|
-
|
|
17874
|
+
var declarationExtension = getDeclarationEmitExtensionForPath(path);
|
|
17875
|
+
return removeFileExtension(path) + declarationExtension;
|
|
17839
17876
|
}
|
|
17840
17877
|
ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
|
|
17878
|
+
function getDeclarationEmitExtensionForPath(path) {
|
|
17879
|
+
return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ :
|
|
17880
|
+
ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ :
|
|
17881
|
+
ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well
|
|
17882
|
+
".d.ts" /* Dts */;
|
|
17883
|
+
}
|
|
17884
|
+
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
17841
17885
|
function outFile(options) {
|
|
17842
17886
|
return options.outFile || options.out;
|
|
17843
17887
|
}
|
|
@@ -18577,7 +18621,7 @@ var ts;
|
|
|
18577
18621
|
}
|
|
18578
18622
|
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
|
18579
18623
|
function tryExtractTSExtension(fileName) {
|
|
18580
|
-
return ts.find(
|
|
18624
|
+
return ts.find(supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
18581
18625
|
}
|
|
18582
18626
|
ts.tryExtractTSExtension = tryExtractTSExtension;
|
|
18583
18627
|
/**
|
|
@@ -19529,7 +19573,10 @@ var ts;
|
|
|
19529
19573
|
}
|
|
19530
19574
|
ts.getLanguageVariant = getLanguageVariant;
|
|
19531
19575
|
function getEmitScriptTarget(compilerOptions) {
|
|
19532
|
-
return compilerOptions.target ||
|
|
19576
|
+
return compilerOptions.target ||
|
|
19577
|
+
(compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
|
|
19578
|
+
(compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) ||
|
|
19579
|
+
0 /* ES3 */;
|
|
19533
19580
|
}
|
|
19534
19581
|
ts.getEmitScriptTarget = getEmitScriptTarget;
|
|
19535
19582
|
function getEmitModuleKind(compilerOptions) {
|
|
@@ -19541,7 +19588,20 @@ var ts;
|
|
|
19541
19588
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
19542
19589
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
19543
19590
|
if (moduleResolution === undefined) {
|
|
19544
|
-
|
|
19591
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19592
|
+
case ts.ModuleKind.CommonJS:
|
|
19593
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
19594
|
+
break;
|
|
19595
|
+
case ts.ModuleKind.Node12:
|
|
19596
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
19597
|
+
break;
|
|
19598
|
+
case ts.ModuleKind.NodeNext:
|
|
19599
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
19600
|
+
break;
|
|
19601
|
+
default:
|
|
19602
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
19603
|
+
break;
|
|
19604
|
+
}
|
|
19545
19605
|
}
|
|
19546
19606
|
return moduleResolution;
|
|
19547
19607
|
}
|
|
@@ -19571,11 +19631,23 @@ var ts;
|
|
|
19571
19631
|
return !!(getEmitDeclarations(options) && options.declarationMap);
|
|
19572
19632
|
}
|
|
19573
19633
|
ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
|
|
19634
|
+
function getESModuleInterop(compilerOptions) {
|
|
19635
|
+
if (compilerOptions.esModuleInterop !== undefined) {
|
|
19636
|
+
return compilerOptions.esModuleInterop;
|
|
19637
|
+
}
|
|
19638
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19639
|
+
case ts.ModuleKind.Node12:
|
|
19640
|
+
case ts.ModuleKind.NodeNext:
|
|
19641
|
+
return true;
|
|
19642
|
+
}
|
|
19643
|
+
return undefined;
|
|
19644
|
+
}
|
|
19645
|
+
ts.getESModuleInterop = getESModuleInterop;
|
|
19574
19646
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
19575
19647
|
var moduleKind = getEmitModuleKind(compilerOptions);
|
|
19576
19648
|
return compilerOptions.allowSyntheticDefaultImports !== undefined
|
|
19577
19649
|
? compilerOptions.allowSyntheticDefaultImports
|
|
19578
|
-
: compilerOptions
|
|
19650
|
+
: getESModuleInterop(compilerOptions) ||
|
|
19579
19651
|
moduleKind === ts.ModuleKind.System;
|
|
19580
19652
|
}
|
|
19581
19653
|
ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
|
|
@@ -19600,7 +19672,7 @@ var ts;
|
|
|
19600
19672
|
}
|
|
19601
19673
|
ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
|
|
19602
19674
|
function getUseDefineForClassFields(compilerOptions) {
|
|
19603
|
-
return compilerOptions.useDefineForClassFields === undefined ? compilerOptions
|
|
19675
|
+
return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ : compilerOptions.useDefineForClassFields;
|
|
19604
19676
|
}
|
|
19605
19677
|
ts.getUseDefineForClassFields = getUseDefineForClassFields;
|
|
19606
19678
|
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
|
|
@@ -20040,51 +20112,54 @@ var ts;
|
|
|
20040
20112
|
}
|
|
20041
20113
|
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
20042
20114
|
/**
|
|
20043
|
-
*
|
|
20115
|
+
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
|
|
20044
20116
|
*/
|
|
20045
|
-
ts.supportedTSExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */];
|
|
20046
|
-
ts.
|
|
20117
|
+
ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
|
|
20118
|
+
ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions);
|
|
20119
|
+
var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false);
|
|
20047
20120
|
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
|
20048
|
-
|
|
20049
|
-
ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */];
|
|
20050
|
-
ts.
|
|
20051
|
-
var allSupportedExtensions =
|
|
20052
|
-
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(
|
|
20121
|
+
var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */];
|
|
20122
|
+
ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
|
|
20123
|
+
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20124
|
+
var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]];
|
|
20125
|
+
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20053
20126
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20054
20127
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20055
20128
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
20056
20129
|
return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20057
20130
|
}
|
|
20058
|
-
var
|
|
20059
|
-
|
|
20131
|
+
var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20132
|
+
var flatBuiltins = ts.flatten(builtins);
|
|
20133
|
+
var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true);
|
|
20134
|
+
return extensions;
|
|
20060
20135
|
}
|
|
20061
20136
|
ts.getSupportedExtensions = getSupportedExtensions;
|
|
20062
|
-
function
|
|
20137
|
+
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
|
|
20063
20138
|
if (!options || !options.resolveJsonModule)
|
|
20064
20139
|
return supportedExtensions;
|
|
20065
20140
|
if (supportedExtensions === allSupportedExtensions)
|
|
20066
20141
|
return allSupportedExtensionsWithJson;
|
|
20067
20142
|
if (supportedExtensions === ts.supportedTSExtensions)
|
|
20068
|
-
return
|
|
20069
|
-
return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false);
|
|
20143
|
+
return supportedTSExtensionsWithJson;
|
|
20144
|
+
return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false);
|
|
20070
20145
|
}
|
|
20071
|
-
ts.
|
|
20146
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule;
|
|
20072
20147
|
function isJSLike(scriptKind) {
|
|
20073
20148
|
return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
|
|
20074
20149
|
}
|
|
20075
20150
|
function hasJSFileExtension(fileName) {
|
|
20076
|
-
return ts.some(ts.
|
|
20151
|
+
return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20077
20152
|
}
|
|
20078
20153
|
ts.hasJSFileExtension = hasJSFileExtension;
|
|
20079
20154
|
function hasTSFileExtension(fileName) {
|
|
20080
|
-
return ts.some(ts.
|
|
20155
|
+
return ts.some(ts.supportedTSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20081
20156
|
}
|
|
20082
20157
|
ts.hasTSFileExtension = hasTSFileExtension;
|
|
20083
20158
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
20084
20159
|
if (!fileName)
|
|
20085
20160
|
return false;
|
|
20086
20161
|
var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
|
|
20087
|
-
for (var _i = 0, _a =
|
|
20162
|
+
for (var _i = 0, _a = ts.flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)); _i < _a.length; _i++) {
|
|
20088
20163
|
var extension = _a[_i];
|
|
20089
20164
|
if (ts.fileExtensionIs(fileName, extension)) {
|
|
20090
20165
|
return true;
|
|
@@ -20101,57 +20176,7 @@ var ts;
|
|
|
20101
20176
|
return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
|
|
20102
20177
|
}
|
|
20103
20178
|
ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
|
|
20104
|
-
|
|
20105
|
-
* Extension boundaries by priority. Lower numbers indicate higher priorities, and are
|
|
20106
|
-
* aligned to the offset of the highest priority extension in the
|
|
20107
|
-
* allSupportedExtensions array.
|
|
20108
|
-
*/
|
|
20109
|
-
var ExtensionPriority;
|
|
20110
|
-
(function (ExtensionPriority) {
|
|
20111
|
-
ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles";
|
|
20112
|
-
ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles";
|
|
20113
|
-
ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest";
|
|
20114
|
-
ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest";
|
|
20115
|
-
})(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {}));
|
|
20116
|
-
function getExtensionPriority(path, supportedExtensions) {
|
|
20117
|
-
for (var i = supportedExtensions.length - 1; i >= 0; i--) {
|
|
20118
|
-
if (ts.fileExtensionIs(path, supportedExtensions[i])) {
|
|
20119
|
-
return adjustExtensionPriority(i, supportedExtensions);
|
|
20120
|
-
}
|
|
20121
|
-
}
|
|
20122
|
-
// If its not in the list of supported extensions, this is likely a
|
|
20123
|
-
// TypeScript file with a non-ts extension
|
|
20124
|
-
return 0 /* Highest */;
|
|
20125
|
-
}
|
|
20126
|
-
ts.getExtensionPriority = getExtensionPriority;
|
|
20127
|
-
/**
|
|
20128
|
-
* Adjusts an extension priority to be the highest priority within the same range.
|
|
20129
|
-
*/
|
|
20130
|
-
function adjustExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20131
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20132
|
-
return 0 /* TypeScriptFiles */;
|
|
20133
|
-
}
|
|
20134
|
-
else if (extensionPriority < supportedExtensions.length) {
|
|
20135
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20136
|
-
}
|
|
20137
|
-
else {
|
|
20138
|
-
return supportedExtensions.length;
|
|
20139
|
-
}
|
|
20140
|
-
}
|
|
20141
|
-
ts.adjustExtensionPriority = adjustExtensionPriority;
|
|
20142
|
-
/**
|
|
20143
|
-
* Gets the next lowest extension priority for a given priority.
|
|
20144
|
-
*/
|
|
20145
|
-
function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20146
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20147
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20148
|
-
}
|
|
20149
|
-
else {
|
|
20150
|
-
return supportedExtensions.length;
|
|
20151
|
-
}
|
|
20152
|
-
}
|
|
20153
|
-
ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
|
|
20154
|
-
var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
20179
|
+
var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
20155
20180
|
function removeFileExtension(path) {
|
|
20156
20181
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
|
|
20157
20182
|
var ext = extensionsToRemove_1[_i];
|
|
@@ -20204,7 +20229,7 @@ var ts;
|
|
|
20204
20229
|
ts.positionIsSynthesized = positionIsSynthesized;
|
|
20205
20230
|
/** True if an extension is one of the supported TypeScript extensions. */
|
|
20206
20231
|
function extensionIsTS(ext) {
|
|
20207
|
-
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */;
|
|
20232
|
+
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */;
|
|
20208
20233
|
}
|
|
20209
20234
|
ts.extensionIsTS = extensionIsTS;
|
|
20210
20235
|
function resolutionExtensionIsTSOrJson(ext) {
|
|
@@ -25365,6 +25390,7 @@ var ts;
|
|
|
25365
25390
|
node.transformFlags =
|
|
25366
25391
|
propagateChildrenFlags(node.statements) |
|
|
25367
25392
|
propagateChildFlags(node.endOfFileToken);
|
|
25393
|
+
node.impliedNodeFormat = source.impliedNodeFormat;
|
|
25368
25394
|
return node;
|
|
25369
25395
|
}
|
|
25370
25396
|
// @api
|
|
@@ -26938,6 +26964,7 @@ var ts;
|
|
|
26938
26964
|
// Class Fields Helpers
|
|
26939
26965
|
createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
|
|
26940
26966
|
createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
|
|
26967
|
+
createClassPrivateFieldInHelper: createClassPrivateFieldInHelper
|
|
26941
26968
|
};
|
|
26942
26969
|
/**
|
|
26943
26970
|
* Gets an identifier for the name of an *unscoped* emit helper.
|
|
@@ -26978,7 +27005,7 @@ var ts;
|
|
|
26978
27005
|
}
|
|
26979
27006
|
// ES2018 Helpers
|
|
26980
27007
|
function createAssignHelper(attributesSegments) {
|
|
26981
|
-
if (context.getCompilerOptions()
|
|
27008
|
+
if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
|
|
26982
27009
|
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
|
|
26983
27010
|
/*typeArguments*/ undefined, attributesSegments);
|
|
26984
27011
|
}
|
|
@@ -27148,6 +27175,10 @@ var ts;
|
|
|
27148
27175
|
}
|
|
27149
27176
|
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args);
|
|
27150
27177
|
}
|
|
27178
|
+
function createClassPrivateFieldInHelper(state, receiver) {
|
|
27179
|
+
context.requestEmitHelper(ts.classPrivateFieldInHelper);
|
|
27180
|
+
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]);
|
|
27181
|
+
}
|
|
27151
27182
|
}
|
|
27152
27183
|
ts.createEmitHelperFactory = createEmitHelperFactory;
|
|
27153
27184
|
/* @internal */
|
|
@@ -27505,6 +27536,24 @@ var ts;
|
|
|
27505
27536
|
scoped: false,
|
|
27506
27537
|
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 };"
|
|
27507
27538
|
};
|
|
27539
|
+
/**
|
|
27540
|
+
* Parameters:
|
|
27541
|
+
* @param state — One of the following:
|
|
27542
|
+
* - A WeakMap when the member is a private instance field.
|
|
27543
|
+
* - A WeakSet when the member is a private instance method or accessor.
|
|
27544
|
+
* - A function value that should be the undecorated class constructor when the member is a private static field, method, or accessor.
|
|
27545
|
+
* @param receiver — The object being checked if it has the private member.
|
|
27546
|
+
*
|
|
27547
|
+
* Usage:
|
|
27548
|
+
* This helper is used to transform `#field in expression` to
|
|
27549
|
+
* `__classPrivateFieldIn(<weakMap/weakSet/constructor>, expression)`
|
|
27550
|
+
*/
|
|
27551
|
+
ts.classPrivateFieldInHelper = {
|
|
27552
|
+
name: "typescript:classPrivateFieldIn",
|
|
27553
|
+
importName: "__classPrivateFieldIn",
|
|
27554
|
+
scoped: false,
|
|
27555
|
+
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 };"
|
|
27556
|
+
};
|
|
27508
27557
|
var allUnscopedEmitHelpers;
|
|
27509
27558
|
function getAllUnscopedEmitHelpers() {
|
|
27510
27559
|
return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
|
|
@@ -27529,6 +27578,7 @@ var ts;
|
|
|
27529
27578
|
ts.exportStarHelper,
|
|
27530
27579
|
ts.classPrivateFieldGetHelper,
|
|
27531
27580
|
ts.classPrivateFieldSetHelper,
|
|
27581
|
+
ts.classPrivateFieldInHelper,
|
|
27532
27582
|
ts.createBindingHelper,
|
|
27533
27583
|
ts.setModuleDefaultHelper
|
|
27534
27584
|
], function (helper) { return helper.name; }));
|
|
@@ -28848,7 +28898,7 @@ var ts;
|
|
|
28848
28898
|
if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
28849
28899
|
var namedBindings = void 0;
|
|
28850
28900
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28851
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
|
|
28901
|
+
if ((moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
28852
28902
|
// use named imports
|
|
28853
28903
|
var helpers = ts.getEmitHelpers(sourceFile);
|
|
28854
28904
|
if (helpers) {
|
|
@@ -28900,9 +28950,9 @@ var ts;
|
|
|
28900
28950
|
return externalHelpersModuleName;
|
|
28901
28951
|
}
|
|
28902
28952
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28903
|
-
var create = (hasExportStarsToExportValues || (compilerOptions
|
|
28953
|
+
var create = (hasExportStarsToExportValues || (ts.getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
|
|
28904
28954
|
&& moduleKind !== ts.ModuleKind.System
|
|
28905
|
-
&& moduleKind < ts.ModuleKind.ES2015;
|
|
28955
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || node.impliedNodeFormat === ts.ModuleKind.CommonJS);
|
|
28906
28956
|
if (!create) {
|
|
28907
28957
|
var helpers = ts.getEmitHelpers(node);
|
|
28908
28958
|
if (helpers) {
|
|
@@ -34454,6 +34504,8 @@ var ts;
|
|
|
34454
34504
|
break;
|
|
34455
34505
|
case 15 /* TemplateHead */:
|
|
34456
34506
|
return parseTemplateExpression(/* isTaggedTemplate */ false);
|
|
34507
|
+
case 80 /* PrivateIdentifier */:
|
|
34508
|
+
return parsePrivateIdentifier();
|
|
34457
34509
|
}
|
|
34458
34510
|
return parseIdentifier(ts.Diagnostics.Expression_expected);
|
|
34459
34511
|
}
|
|
@@ -37155,6 +37207,7 @@ var ts;
|
|
|
37155
37207
|
// are already correct.
|
|
37156
37208
|
var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
|
|
37157
37209
|
result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
|
|
37210
|
+
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
|
|
37158
37211
|
return result;
|
|
37159
37212
|
}
|
|
37160
37213
|
IncrementalParser.updateSourceFile = updateSourceFile;
|
|
@@ -37604,7 +37657,7 @@ var ts;
|
|
|
37604
37657
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
37605
37658
|
/** @internal */
|
|
37606
37659
|
function isDeclarationFileName(fileName) {
|
|
37607
|
-
return ts.
|
|
37660
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37608
37661
|
}
|
|
37609
37662
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37610
37663
|
/*@internal*/
|
|
@@ -38217,7 +38270,9 @@ var ts;
|
|
|
38217
38270
|
es6: ts.ModuleKind.ES2015,
|
|
38218
38271
|
es2015: ts.ModuleKind.ES2015,
|
|
38219
38272
|
es2020: ts.ModuleKind.ES2020,
|
|
38220
|
-
esnext: ts.ModuleKind.ESNext
|
|
38273
|
+
esnext: ts.ModuleKind.ESNext,
|
|
38274
|
+
node12: ts.ModuleKind.Node12,
|
|
38275
|
+
nodenext: ts.ModuleKind.NodeNext,
|
|
38221
38276
|
})),
|
|
38222
38277
|
affectsModuleResolution: true,
|
|
38223
38278
|
affectsEmit: true,
|
|
@@ -39122,7 +39177,7 @@ var ts;
|
|
|
39122
39177
|
/* @internal */
|
|
39123
39178
|
ts.defaultInitCompilerOptions = {
|
|
39124
39179
|
module: ts.ModuleKind.CommonJS,
|
|
39125
|
-
target:
|
|
39180
|
+
target: 3 /* ES2016 */,
|
|
39126
39181
|
strict: true,
|
|
39127
39182
|
esModuleInterop: true,
|
|
39128
39183
|
forceConsistentCasingInFileNames: true,
|
|
@@ -40643,7 +40698,7 @@ var ts;
|
|
|
40643
40698
|
// Rather than re-query this for each file and filespec, we query the supported extensions
|
|
40644
40699
|
// once and store it on the expansion context.
|
|
40645
40700
|
var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
|
|
40646
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
40701
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
40647
40702
|
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
|
40648
40703
|
// remove a literal file.
|
|
40649
40704
|
if (validatedFilesSpec) {
|
|
@@ -40691,7 +40746,7 @@ var ts;
|
|
|
40691
40746
|
wildcardFileMap.set(key, file);
|
|
40692
40747
|
}
|
|
40693
40748
|
};
|
|
40694
|
-
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40749
|
+
for (var _a = 0, _b = host.readDirectory(basePath, ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40695
40750
|
var file = _b[_a];
|
|
40696
40751
|
_loop_6(file);
|
|
40697
40752
|
}
|
|
@@ -40854,16 +40909,25 @@ var ts;
|
|
|
40854
40909
|
* extension priority.
|
|
40855
40910
|
*
|
|
40856
40911
|
* @param file The path to the file.
|
|
40857
|
-
* @param extensionPriority The priority of the extension.
|
|
40858
|
-
* @param context The expansion context.
|
|
40859
40912
|
*/
|
|
40860
40913
|
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
|
|
40861
|
-
var
|
|
40862
|
-
|
|
40863
|
-
|
|
40864
|
-
|
|
40865
|
-
|
|
40914
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40915
|
+
if (!extensionGroup) {
|
|
40916
|
+
return false;
|
|
40917
|
+
}
|
|
40918
|
+
for (var _i = 0, extensionGroup_1 = extensionGroup; _i < extensionGroup_1.length; _i++) {
|
|
40919
|
+
var ext = extensionGroup_1[_i];
|
|
40920
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
40921
|
+
return false;
|
|
40922
|
+
}
|
|
40923
|
+
var higherPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40866
40924
|
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
|
|
40925
|
+
if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) {
|
|
40926
|
+
// LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
|
|
40927
|
+
// files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
|
|
40928
|
+
// prevent breakage.
|
|
40929
|
+
continue;
|
|
40930
|
+
}
|
|
40867
40931
|
return true;
|
|
40868
40932
|
}
|
|
40869
40933
|
}
|
|
@@ -40874,15 +40938,18 @@ var ts;
|
|
|
40874
40938
|
* already been included.
|
|
40875
40939
|
*
|
|
40876
40940
|
* @param file The path to the file.
|
|
40877
|
-
* @param extensionPriority The priority of the extension.
|
|
40878
|
-
* @param context The expansion context.
|
|
40879
40941
|
*/
|
|
40880
40942
|
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
|
|
40881
|
-
var
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40943
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40944
|
+
if (!extensionGroup) {
|
|
40945
|
+
return;
|
|
40946
|
+
}
|
|
40947
|
+
for (var i = extensionGroup.length - 1; i >= 0; i--) {
|
|
40948
|
+
var ext = extensionGroup[i];
|
|
40949
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
40950
|
+
return;
|
|
40951
|
+
}
|
|
40952
|
+
var lowerPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40886
40953
|
wildcardFiles.delete(lowerPriorityPath);
|
|
40887
40954
|
}
|
|
40888
40955
|
}
|
|
@@ -41142,7 +41209,7 @@ var ts;
|
|
|
41142
41209
|
}
|
|
41143
41210
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41144
41211
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41145
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName);
|
|
41212
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
|
|
41146
41213
|
if (result) {
|
|
41147
41214
|
if (traceEnabled) {
|
|
41148
41215
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41176,7 +41243,7 @@ var ts;
|
|
|
41176
41243
|
}
|
|
41177
41244
|
}
|
|
41178
41245
|
var failedLookupLocations = [];
|
|
41179
|
-
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
41246
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
|
|
41180
41247
|
var resolved = primaryLookup();
|
|
41181
41248
|
var primary = true;
|
|
41182
41249
|
if (!resolved) {
|
|
@@ -41196,7 +41263,7 @@ var ts;
|
|
|
41196
41263
|
};
|
|
41197
41264
|
}
|
|
41198
41265
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41199
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result);
|
|
41266
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
|
|
41200
41267
|
if (traceEnabled)
|
|
41201
41268
|
traceResult(result);
|
|
41202
41269
|
return result;
|
|
@@ -41409,9 +41476,56 @@ var ts;
|
|
|
41409
41476
|
}
|
|
41410
41477
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
41411
41478
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
41412
|
-
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return
|
|
41479
|
+
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
|
|
41413
41480
|
}
|
|
41414
41481
|
}
|
|
41482
|
+
/* @internal */
|
|
41483
|
+
function createModeAwareCache() {
|
|
41484
|
+
var underlying = new ts.Map();
|
|
41485
|
+
var memoizedReverseKeys = new ts.Map();
|
|
41486
|
+
var cache = {
|
|
41487
|
+
get: function (specifier, mode) {
|
|
41488
|
+
return underlying.get(getUnderlyingCacheKey(specifier, mode));
|
|
41489
|
+
},
|
|
41490
|
+
set: function (specifier, mode, value) {
|
|
41491
|
+
underlying.set(getUnderlyingCacheKey(specifier, mode), value);
|
|
41492
|
+
return cache;
|
|
41493
|
+
},
|
|
41494
|
+
delete: function (specifier, mode) {
|
|
41495
|
+
underlying.delete(getUnderlyingCacheKey(specifier, mode));
|
|
41496
|
+
return cache;
|
|
41497
|
+
},
|
|
41498
|
+
has: function (specifier, mode) {
|
|
41499
|
+
return underlying.has(getUnderlyingCacheKey(specifier, mode));
|
|
41500
|
+
},
|
|
41501
|
+
forEach: function (cb) {
|
|
41502
|
+
return underlying.forEach(function (elem, key) {
|
|
41503
|
+
var _a = memoizedReverseKeys.get(key), specifier = _a[0], mode = _a[1];
|
|
41504
|
+
return cb(elem, specifier, mode);
|
|
41505
|
+
});
|
|
41506
|
+
},
|
|
41507
|
+
size: function () {
|
|
41508
|
+
return underlying.size;
|
|
41509
|
+
}
|
|
41510
|
+
};
|
|
41511
|
+
return cache;
|
|
41512
|
+
function getUnderlyingCacheKey(specifier, mode) {
|
|
41513
|
+
var result = mode === undefined ? specifier : mode + "|" + specifier;
|
|
41514
|
+
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
41515
|
+
return result;
|
|
41516
|
+
}
|
|
41517
|
+
}
|
|
41518
|
+
ts.createModeAwareCache = createModeAwareCache;
|
|
41519
|
+
/* @internal */
|
|
41520
|
+
function zipToModeAwareCache(file, keys, values) {
|
|
41521
|
+
ts.Debug.assert(keys.length === values.length);
|
|
41522
|
+
var map = createModeAwareCache();
|
|
41523
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
41524
|
+
map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
|
|
41525
|
+
}
|
|
41526
|
+
return map;
|
|
41527
|
+
}
|
|
41528
|
+
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
41415
41529
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
41416
41530
|
var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
41417
41531
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
@@ -41425,9 +41539,9 @@ var ts;
|
|
|
41425
41539
|
function update(options) {
|
|
41426
41540
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
41427
41541
|
}
|
|
41428
|
-
function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
|
|
41542
|
+
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
41429
41543
|
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
41430
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
|
|
41544
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
|
|
41431
41545
|
}
|
|
41432
41546
|
function createPerModuleNameCache() {
|
|
41433
41547
|
var directoryPathMap = new ts.Map();
|
|
@@ -41506,13 +41620,15 @@ var ts;
|
|
|
41506
41620
|
}
|
|
41507
41621
|
}
|
|
41508
41622
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
41509
|
-
function resolveModuleNameFromCache(moduleName, containingFile, cache) {
|
|
41623
|
+
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
41510
41624
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41511
41625
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
41512
|
-
|
|
41626
|
+
if (!perFolderCache)
|
|
41627
|
+
return undefined;
|
|
41628
|
+
return perFolderCache.get(moduleName, mode);
|
|
41513
41629
|
}
|
|
41514
41630
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
41515
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
41631
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41516
41632
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41517
41633
|
if (redirectedReference) {
|
|
41518
41634
|
compilerOptions = redirectedReference.commandLine.options;
|
|
@@ -41525,7 +41641,7 @@ var ts;
|
|
|
41525
41641
|
}
|
|
41526
41642
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41527
41643
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
|
|
41528
|
-
var result = perFolderCache && perFolderCache.get(moduleName);
|
|
41644
|
+
var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
41529
41645
|
if (result) {
|
|
41530
41646
|
if (traceEnabled) {
|
|
41531
41647
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -41534,7 +41650,20 @@ var ts;
|
|
|
41534
41650
|
else {
|
|
41535
41651
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
41536
41652
|
if (moduleResolution === undefined) {
|
|
41537
|
-
|
|
41653
|
+
switch (ts.getEmitModuleKind(compilerOptions)) {
|
|
41654
|
+
case ts.ModuleKind.CommonJS:
|
|
41655
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
41656
|
+
break;
|
|
41657
|
+
case ts.ModuleKind.Node12:
|
|
41658
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
41659
|
+
break;
|
|
41660
|
+
case ts.ModuleKind.NodeNext:
|
|
41661
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
41662
|
+
break;
|
|
41663
|
+
default:
|
|
41664
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
41665
|
+
break;
|
|
41666
|
+
}
|
|
41538
41667
|
if (traceEnabled) {
|
|
41539
41668
|
trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
41540
41669
|
}
|
|
@@ -41546,6 +41675,12 @@ var ts;
|
|
|
41546
41675
|
}
|
|
41547
41676
|
ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
|
|
41548
41677
|
switch (moduleResolution) {
|
|
41678
|
+
case ts.ModuleResolutionKind.Node12:
|
|
41679
|
+
result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41680
|
+
break;
|
|
41681
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
41682
|
+
result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41683
|
+
break;
|
|
41549
41684
|
case ts.ModuleResolutionKind.NodeJs:
|
|
41550
41685
|
result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
41551
41686
|
break;
|
|
@@ -41559,10 +41694,10 @@ var ts;
|
|
|
41559
41694
|
ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
|
|
41560
41695
|
ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
41561
41696
|
if (perFolderCache) {
|
|
41562
|
-
perFolderCache.set(moduleName, result);
|
|
41697
|
+
perFolderCache.set(moduleName, resolutionMode, result);
|
|
41563
41698
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41564
41699
|
// put result in per-module name cache
|
|
41565
|
-
cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
|
|
41700
|
+
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
41566
41701
|
}
|
|
41567
41702
|
}
|
|
41568
41703
|
}
|
|
@@ -41769,22 +41904,60 @@ var ts;
|
|
|
41769
41904
|
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
41770
41905
|
}
|
|
41771
41906
|
ts.tryResolveJSModule = tryResolveJSModule;
|
|
41907
|
+
/* @internal */
|
|
41908
|
+
var NodeResolutionFeatures;
|
|
41909
|
+
(function (NodeResolutionFeatures) {
|
|
41910
|
+
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
41911
|
+
// resolving `#local` names in your own package.json
|
|
41912
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Imports"] = 2] = "Imports";
|
|
41913
|
+
// resolving `your-own-name` from your own package.json
|
|
41914
|
+
NodeResolutionFeatures[NodeResolutionFeatures["SelfName"] = 4] = "SelfName";
|
|
41915
|
+
// respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
|
|
41916
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
|
|
41917
|
+
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
|
|
41918
|
+
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
41919
|
+
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
41920
|
+
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
41921
|
+
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
41922
|
+
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
41923
|
+
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41924
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41925
|
+
}
|
|
41926
|
+
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41927
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41928
|
+
}
|
|
41929
|
+
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41930
|
+
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41931
|
+
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
41932
|
+
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
41933
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
|
|
41934
|
+
}
|
|
41772
41935
|
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
41773
41936
|
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
41774
41937
|
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
41775
41938
|
var tsconfigExtensions = [Extensions.TSConfig];
|
|
41776
41939
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
41777
|
-
return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41940
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41778
41941
|
}
|
|
41779
41942
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
41780
|
-
return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41943
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41781
41944
|
}
|
|
41782
41945
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
41783
|
-
function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41946
|
+
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41784
41947
|
var _a, _b;
|
|
41785
41948
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41786
41949
|
var failedLookupLocations = [];
|
|
41787
|
-
|
|
41950
|
+
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
41951
|
+
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
41952
|
+
var state = {
|
|
41953
|
+
compilerOptions: compilerOptions,
|
|
41954
|
+
host: host,
|
|
41955
|
+
traceEnabled: traceEnabled,
|
|
41956
|
+
failedLookupLocations: failedLookupLocations,
|
|
41957
|
+
packageJsonInfoCache: cache,
|
|
41958
|
+
features: features,
|
|
41959
|
+
conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
|
|
41960
|
+
};
|
|
41788
41961
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
41789
41962
|
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);
|
|
41790
41963
|
function tryResolve(extensions) {
|
|
@@ -41794,10 +41967,19 @@ var ts;
|
|
|
41794
41967
|
return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
41795
41968
|
}
|
|
41796
41969
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41797
|
-
|
|
41798
|
-
|
|
41970
|
+
var resolved_1;
|
|
41971
|
+
if (features & NodeResolutionFeatures.Imports && ts.startsWith(moduleName, "#")) {
|
|
41972
|
+
resolved_1 = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41973
|
+
}
|
|
41974
|
+
if (!resolved_1 && features & NodeResolutionFeatures.SelfName) {
|
|
41975
|
+
resolved_1 = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41976
|
+
}
|
|
41977
|
+
if (!resolved_1) {
|
|
41978
|
+
if (traceEnabled) {
|
|
41979
|
+
trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
|
|
41980
|
+
}
|
|
41981
|
+
resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41799
41982
|
}
|
|
41800
|
-
var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41801
41983
|
if (!resolved_1)
|
|
41802
41984
|
return undefined;
|
|
41803
41985
|
var resolvedValue = resolved_1.value;
|
|
@@ -41906,26 +42088,40 @@ var ts;
|
|
|
41906
42088
|
function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
|
|
41907
42089
|
if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
|
|
41908
42090
|
var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
|
|
41909
|
-
|
|
42091
|
+
var extension = extensionLess ? candidate.substring(extensionLess.length) : "";
|
|
42092
|
+
return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
|
|
41910
42093
|
}
|
|
41911
|
-
//
|
|
41912
|
-
|
|
41913
|
-
|
|
41914
|
-
|
|
42094
|
+
// esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
|
|
42095
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42096
|
+
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
|
|
42097
|
+
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
|
|
42098
|
+
if (resolvedByAddingExtension) {
|
|
42099
|
+
return resolvedByAddingExtension;
|
|
42100
|
+
}
|
|
41915
42101
|
}
|
|
42102
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
42103
|
+
}
|
|
42104
|
+
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
41916
42105
|
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
|
|
41917
42106
|
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
|
|
41918
|
-
if (ts.hasJSFileExtension(candidate)) {
|
|
42107
|
+
if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) {
|
|
41919
42108
|
var extensionless = ts.removeFileExtension(candidate);
|
|
42109
|
+
var extension = candidate.substring(extensionless.length);
|
|
41920
42110
|
if (state.traceEnabled) {
|
|
41921
|
-
var extension = candidate.substring(extensionless.length);
|
|
41922
42111
|
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
41923
42112
|
}
|
|
41924
|
-
return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
|
|
42113
|
+
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
41925
42114
|
}
|
|
41926
42115
|
}
|
|
42116
|
+
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
42117
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
|
|
42118
|
+
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
42119
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
42120
|
+
}
|
|
42121
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
42122
|
+
}
|
|
41927
42123
|
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
|
|
41928
|
-
function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
|
|
42124
|
+
function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecordFailures, state) {
|
|
41929
42125
|
if (!onlyRecordFailures) {
|
|
41930
42126
|
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
|
41931
42127
|
var directory = ts.getDirectoryPath(candidate);
|
|
@@ -41935,11 +42131,51 @@ var ts;
|
|
|
41935
42131
|
}
|
|
41936
42132
|
switch (extensions) {
|
|
41937
42133
|
case Extensions.DtsOnly:
|
|
41938
|
-
|
|
42134
|
+
switch (originalExtension) {
|
|
42135
|
+
case ".mjs" /* Mjs */:
|
|
42136
|
+
case ".mts" /* Mts */:
|
|
42137
|
+
case ".d.mts" /* Dmts */:
|
|
42138
|
+
return tryExtension(".d.mts" /* Dmts */);
|
|
42139
|
+
case ".cjs" /* Cjs */:
|
|
42140
|
+
case ".cts" /* Cts */:
|
|
42141
|
+
case ".d.cts" /* Dcts */:
|
|
42142
|
+
return tryExtension(".d.cts" /* Dcts */);
|
|
42143
|
+
case ".json" /* Json */:
|
|
42144
|
+
candidate += ".json" /* Json */;
|
|
42145
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42146
|
+
default: return tryExtension(".d.ts" /* Dts */);
|
|
42147
|
+
}
|
|
41939
42148
|
case Extensions.TypeScript:
|
|
41940
|
-
|
|
42149
|
+
switch (originalExtension) {
|
|
42150
|
+
case ".mjs" /* Mjs */:
|
|
42151
|
+
case ".mts" /* Mts */:
|
|
42152
|
+
case ".d.mts" /* Dmts */:
|
|
42153
|
+
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
42154
|
+
case ".cjs" /* Cjs */:
|
|
42155
|
+
case ".cts" /* Cts */:
|
|
42156
|
+
case ".d.cts" /* Dcts */:
|
|
42157
|
+
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
42158
|
+
case ".json" /* Json */:
|
|
42159
|
+
candidate += ".json" /* Json */;
|
|
42160
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42161
|
+
default:
|
|
42162
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
42163
|
+
}
|
|
41941
42164
|
case Extensions.JavaScript:
|
|
41942
|
-
|
|
42165
|
+
switch (originalExtension) {
|
|
42166
|
+
case ".mjs" /* Mjs */:
|
|
42167
|
+
case ".mts" /* Mts */:
|
|
42168
|
+
case ".d.mts" /* Dmts */:
|
|
42169
|
+
return tryExtension(".mjs" /* Mjs */);
|
|
42170
|
+
case ".cjs" /* Cjs */:
|
|
42171
|
+
case ".cts" /* Cts */:
|
|
42172
|
+
case ".d.cts" /* Dcts */:
|
|
42173
|
+
return tryExtension(".cjs" /* Cjs */);
|
|
42174
|
+
case ".json" /* Json */:
|
|
42175
|
+
return tryExtension(".json" /* Json */);
|
|
42176
|
+
default:
|
|
42177
|
+
return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
|
|
42178
|
+
}
|
|
41943
42179
|
case Extensions.TSConfig:
|
|
41944
42180
|
case Extensions.Json:
|
|
41945
42181
|
return tryExtension(".json" /* Json */);
|
|
@@ -41974,6 +42210,33 @@ var ts;
|
|
|
41974
42210
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
41975
42211
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
41976
42212
|
}
|
|
42213
|
+
/**
|
|
42214
|
+
* A function for locating the package.json scope for a given path
|
|
42215
|
+
*/
|
|
42216
|
+
/*@internal*/
|
|
42217
|
+
function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
|
|
42218
|
+
var state = {
|
|
42219
|
+
host: host,
|
|
42220
|
+
compilerOptions: options,
|
|
42221
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42222
|
+
failedLookupLocations: [],
|
|
42223
|
+
packageJsonInfoCache: packageJsonInfoCache,
|
|
42224
|
+
features: 0,
|
|
42225
|
+
conditions: [],
|
|
42226
|
+
};
|
|
42227
|
+
var parts = ts.getPathComponents(fileName);
|
|
42228
|
+
parts.pop();
|
|
42229
|
+
while (parts.length > 0) {
|
|
42230
|
+
var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
|
42231
|
+
if (pkg) {
|
|
42232
|
+
return pkg;
|
|
42233
|
+
}
|
|
42234
|
+
parts.pop();
|
|
42235
|
+
}
|
|
42236
|
+
return undefined;
|
|
42237
|
+
}
|
|
42238
|
+
ts.getPackageScopeForPath = getPackageScopeForPath;
|
|
42239
|
+
/*@internal*/
|
|
41977
42240
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
41978
42241
|
var _a, _b, _c;
|
|
41979
42242
|
var host = state.host, traceEnabled = state.traceEnabled;
|
|
@@ -42016,6 +42279,7 @@ var ts;
|
|
|
42016
42279
|
state.failedLookupLocations.push(packageJsonPath);
|
|
42017
42280
|
}
|
|
42018
42281
|
}
|
|
42282
|
+
ts.getPackageJsonInfo = getPackageJsonInfo;
|
|
42019
42283
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
42020
42284
|
var packageFile;
|
|
42021
42285
|
if (jsonContent) {
|
|
@@ -42071,7 +42335,10 @@ var ts;
|
|
|
42071
42335
|
var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
|
|
42072
42336
|
if (packageFileResult)
|
|
42073
42337
|
return packageFileResult;
|
|
42074
|
-
|
|
42338
|
+
// esm mode resolutions don't do package `index` lookups
|
|
42339
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42340
|
+
return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
|
|
42341
|
+
}
|
|
42075
42342
|
}
|
|
42076
42343
|
/** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
|
|
42077
42344
|
function resolvedIfExtensionMatches(extensions, path) {
|
|
@@ -42101,6 +42368,226 @@ var ts;
|
|
|
42101
42368
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42102
42369
|
}
|
|
42103
42370
|
ts.parsePackageName = parsePackageName;
|
|
42371
|
+
function allKeysStartWithDot(obj) {
|
|
42372
|
+
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42373
|
+
}
|
|
42374
|
+
function noKeyStartsWithDot(obj) {
|
|
42375
|
+
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42376
|
+
}
|
|
42377
|
+
function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42378
|
+
var _a, _b;
|
|
42379
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42380
|
+
var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
|
42381
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42382
|
+
if (!scope || !scope.packageJsonContent.exports) {
|
|
42383
|
+
return undefined;
|
|
42384
|
+
}
|
|
42385
|
+
var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
|
|
42386
|
+
if (scope.packageJsonContent.name !== parts[1]) {
|
|
42387
|
+
return undefined;
|
|
42388
|
+
}
|
|
42389
|
+
var trailingParts = parts.slice(2);
|
|
42390
|
+
return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference);
|
|
42391
|
+
}
|
|
42392
|
+
function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
|
|
42393
|
+
if (!scope.packageJsonContent.exports) {
|
|
42394
|
+
return undefined;
|
|
42395
|
+
}
|
|
42396
|
+
if (subpath === ".") {
|
|
42397
|
+
var mainExport = void 0;
|
|
42398
|
+
if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports))) {
|
|
42399
|
+
mainExport = scope.packageJsonContent.exports;
|
|
42400
|
+
}
|
|
42401
|
+
else if (ts.hasProperty(scope.packageJsonContent.exports, ".")) {
|
|
42402
|
+
mainExport = scope.packageJsonContent.exports["."];
|
|
42403
|
+
}
|
|
42404
|
+
if (mainExport) {
|
|
42405
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
42406
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
42407
|
+
}
|
|
42408
|
+
}
|
|
42409
|
+
else if (allKeysStartWithDot(scope.packageJsonContent.exports)) {
|
|
42410
|
+
if (typeof scope.packageJsonContent.exports !== "object") {
|
|
42411
|
+
if (state.traceEnabled) {
|
|
42412
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42413
|
+
}
|
|
42414
|
+
return toSearchResult(/*value*/ undefined);
|
|
42415
|
+
}
|
|
42416
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false);
|
|
42417
|
+
if (result) {
|
|
42418
|
+
return result;
|
|
42419
|
+
}
|
|
42420
|
+
}
|
|
42421
|
+
if (state.traceEnabled) {
|
|
42422
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42423
|
+
}
|
|
42424
|
+
return toSearchResult(/*value*/ undefined);
|
|
42425
|
+
}
|
|
42426
|
+
function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42427
|
+
var _a, _b;
|
|
42428
|
+
if (moduleName === "#" || ts.startsWith(moduleName, "#/")) {
|
|
42429
|
+
if (state.traceEnabled) {
|
|
42430
|
+
trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
|
|
42431
|
+
}
|
|
42432
|
+
return toSearchResult(/*value*/ undefined);
|
|
42433
|
+
}
|
|
42434
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42435
|
+
var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
|
|
42436
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42437
|
+
if (!scope) {
|
|
42438
|
+
if (state.traceEnabled) {
|
|
42439
|
+
trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
|
|
42440
|
+
}
|
|
42441
|
+
return toSearchResult(/*value*/ undefined);
|
|
42442
|
+
}
|
|
42443
|
+
if (!scope.packageJsonContent.imports) {
|
|
42444
|
+
if (state.traceEnabled) {
|
|
42445
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
|
|
42446
|
+
}
|
|
42447
|
+
return toSearchResult(/*value*/ undefined);
|
|
42448
|
+
}
|
|
42449
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
|
|
42450
|
+
if (result) {
|
|
42451
|
+
return result;
|
|
42452
|
+
}
|
|
42453
|
+
if (state.traceEnabled) {
|
|
42454
|
+
trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
|
|
42455
|
+
}
|
|
42456
|
+
return toSearchResult(/*value*/ undefined);
|
|
42457
|
+
}
|
|
42458
|
+
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
42459
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
42460
|
+
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
42461
|
+
var target = lookupTable[moduleName];
|
|
42462
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
42463
|
+
}
|
|
42464
|
+
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), function (a, b) { return a.length - b.length; });
|
|
42465
|
+
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
42466
|
+
var potentialTarget = expandingKeys_1[_i];
|
|
42467
|
+
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
42468
|
+
var target = lookupTable[potentialTarget];
|
|
42469
|
+
var starPos = potentialTarget.indexOf("*");
|
|
42470
|
+
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
42471
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42472
|
+
}
|
|
42473
|
+
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
42474
|
+
var target = lookupTable[potentialTarget];
|
|
42475
|
+
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
42476
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42477
|
+
}
|
|
42478
|
+
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
42479
|
+
var target = lookupTable[potentialTarget];
|
|
42480
|
+
var subpath = moduleName.substring(potentialTarget.length);
|
|
42481
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
42482
|
+
}
|
|
42483
|
+
}
|
|
42484
|
+
function matchesPatternWithTrailer(target, name) {
|
|
42485
|
+
if (ts.endsWith(target, "*"))
|
|
42486
|
+
return false; // handled by next case in loop
|
|
42487
|
+
var starPos = target.indexOf("*");
|
|
42488
|
+
if (starPos === -1)
|
|
42489
|
+
return false; // handled by last case in loop
|
|
42490
|
+
return ts.startsWith(name, target.substring(0, starPos)) && ts.endsWith(name, target.substring(starPos + 1));
|
|
42491
|
+
}
|
|
42492
|
+
}
|
|
42493
|
+
/**
|
|
42494
|
+
* Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
|
|
42495
|
+
*/
|
|
42496
|
+
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
42497
|
+
return loadModuleFromTargetImportOrExport;
|
|
42498
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
42499
|
+
var _a, _b;
|
|
42500
|
+
if (typeof target === "string") {
|
|
42501
|
+
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
42502
|
+
if (state.traceEnabled) {
|
|
42503
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42504
|
+
}
|
|
42505
|
+
return toSearchResult(/*value*/ undefined);
|
|
42506
|
+
}
|
|
42507
|
+
if (!ts.startsWith(target, "./")) {
|
|
42508
|
+
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
42509
|
+
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
42510
|
+
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
42511
|
+
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
42512
|
+
}
|
|
42513
|
+
if (state.traceEnabled) {
|
|
42514
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42515
|
+
}
|
|
42516
|
+
return toSearchResult(/*value*/ undefined);
|
|
42517
|
+
}
|
|
42518
|
+
var parts = ts.pathIsRelative(target) ? ts.getPathComponents(target).slice(1) : ts.getPathComponents(target);
|
|
42519
|
+
var partsAfterFirst = parts.slice(1);
|
|
42520
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42521
|
+
if (state.traceEnabled) {
|
|
42522
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42523
|
+
}
|
|
42524
|
+
return toSearchResult(/*value*/ undefined);
|
|
42525
|
+
}
|
|
42526
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42527
|
+
// TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
|
|
42528
|
+
// to be in the business of validating everyone's import and export map correctness.
|
|
42529
|
+
var subpathParts = ts.getPathComponents(subpath);
|
|
42530
|
+
if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) {
|
|
42531
|
+
if (state.traceEnabled) {
|
|
42532
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42533
|
+
}
|
|
42534
|
+
return toSearchResult(/*value*/ undefined);
|
|
42535
|
+
}
|
|
42536
|
+
var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
42537
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
42538
|
+
}
|
|
42539
|
+
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
42540
|
+
if (!Array.isArray(target)) {
|
|
42541
|
+
for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
|
|
42542
|
+
var key = _c[_i];
|
|
42543
|
+
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
42544
|
+
var subTarget = target[key];
|
|
42545
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
42546
|
+
if (result) {
|
|
42547
|
+
return result;
|
|
42548
|
+
}
|
|
42549
|
+
}
|
|
42550
|
+
}
|
|
42551
|
+
return undefined;
|
|
42552
|
+
}
|
|
42553
|
+
else {
|
|
42554
|
+
if (!ts.length(target)) {
|
|
42555
|
+
if (state.traceEnabled) {
|
|
42556
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42557
|
+
}
|
|
42558
|
+
return toSearchResult(/*value*/ undefined);
|
|
42559
|
+
}
|
|
42560
|
+
for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
|
|
42561
|
+
var elem = target_1[_d];
|
|
42562
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
42563
|
+
if (result) {
|
|
42564
|
+
return result;
|
|
42565
|
+
}
|
|
42566
|
+
}
|
|
42567
|
+
}
|
|
42568
|
+
}
|
|
42569
|
+
else if (target === null) { // eslint-disable-line no-null/no-null
|
|
42570
|
+
if (state.traceEnabled) {
|
|
42571
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName);
|
|
42572
|
+
}
|
|
42573
|
+
return toSearchResult(/*value*/ undefined);
|
|
42574
|
+
}
|
|
42575
|
+
if (state.traceEnabled) {
|
|
42576
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42577
|
+
}
|
|
42578
|
+
return toSearchResult(/*value*/ undefined);
|
|
42579
|
+
}
|
|
42580
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42581
|
+
if (conditions.indexOf("types") === -1)
|
|
42582
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42583
|
+
if (!ts.startsWith(key, "types@"))
|
|
42584
|
+
return false;
|
|
42585
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42586
|
+
if (!range)
|
|
42587
|
+
return false;
|
|
42588
|
+
return range.test(ts.version);
|
|
42589
|
+
}
|
|
42590
|
+
}
|
|
42104
42591
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42105
42592
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42106
42593
|
}
|
|
@@ -42109,24 +42596,24 @@ var ts;
|
|
|
42109
42596
|
return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42110
42597
|
}
|
|
42111
42598
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42112
|
-
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42599
|
+
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
|
|
42113
42600
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
42114
42601
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
42115
42602
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
|
|
42116
42603
|
if (resolutionFromCache) {
|
|
42117
42604
|
return resolutionFromCache;
|
|
42118
42605
|
}
|
|
42119
|
-
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
|
|
42606
|
+
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
|
|
42120
42607
|
}
|
|
42121
42608
|
});
|
|
42122
42609
|
}
|
|
42123
|
-
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
|
|
42610
|
+
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42124
42611
|
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
|
|
42125
42612
|
var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
|
|
42126
42613
|
if (!nodeModulesFolderExists && state.traceEnabled) {
|
|
42127
42614
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
|
|
42128
42615
|
}
|
|
42129
|
-
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
|
|
42616
|
+
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
|
|
42130
42617
|
if (packageResult) {
|
|
42131
42618
|
return packageResult;
|
|
42132
42619
|
}
|
|
@@ -42139,27 +42626,35 @@ var ts;
|
|
|
42139
42626
|
}
|
|
42140
42627
|
nodeModulesAtTypesExists = false;
|
|
42141
42628
|
}
|
|
42142
|
-
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
|
|
42629
|
+
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state, cache, redirectedReference);
|
|
42143
42630
|
}
|
|
42144
42631
|
}
|
|
42145
|
-
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
|
|
42632
|
+
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
|
|
42146
42633
|
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
|
|
42147
42634
|
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
|
|
42148
42635
|
var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
|
|
42149
|
-
if (
|
|
42150
|
-
|
|
42151
|
-
if (
|
|
42152
|
-
|
|
42636
|
+
// But only if we're not respecting export maps (if we are, we might redirect around this location)
|
|
42637
|
+
if (!(state.features & NodeResolutionFeatures.Exports)) {
|
|
42638
|
+
if (packageInfo) {
|
|
42639
|
+
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
|
|
42640
|
+
if (fromFile) {
|
|
42641
|
+
return noPackageId(fromFile);
|
|
42642
|
+
}
|
|
42643
|
+
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42644
|
+
return withPackageId(packageInfo, fromDirectory);
|
|
42153
42645
|
}
|
|
42154
|
-
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42155
|
-
return withPackageId(packageInfo, fromDirectory);
|
|
42156
42646
|
}
|
|
42647
|
+
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42157
42648
|
var loader = function (extensions, candidate, onlyRecordFailures, state) {
|
|
42649
|
+
var _a;
|
|
42650
|
+
// package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
|
|
42651
|
+
if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
|
|
42652
|
+
return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
|
|
42653
|
+
}
|
|
42158
42654
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
42159
42655
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
42160
42656
|
return withPackageId(packageInfo, pathAndExtension);
|
|
42161
42657
|
};
|
|
42162
|
-
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42163
42658
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
42164
42659
|
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
|
|
42165
42660
|
// Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings.
|
|
@@ -42261,7 +42756,7 @@ var ts;
|
|
|
42261
42756
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
42262
42757
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
42263
42758
|
var failedLookupLocations = [];
|
|
42264
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
42759
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42265
42760
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
42266
42761
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
42267
42762
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
@@ -42272,7 +42767,7 @@ var ts;
|
|
|
42272
42767
|
return { value: resolvedUsingSettings };
|
|
42273
42768
|
}
|
|
42274
42769
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
42275
|
-
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42770
|
+
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
|
|
42276
42771
|
// Climb up parent directories looking for a module.
|
|
42277
42772
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
42278
42773
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
|
|
@@ -42308,8 +42803,8 @@ var ts;
|
|
|
42308
42803
|
trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
|
|
42309
42804
|
}
|
|
42310
42805
|
var failedLookupLocations = [];
|
|
42311
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache };
|
|
42312
|
-
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false);
|
|
42806
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42807
|
+
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42313
42808
|
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
42314
42809
|
}
|
|
42315
42810
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
@@ -44490,7 +44985,7 @@ var ts;
|
|
|
44490
44985
|
}
|
|
44491
44986
|
function checkStrictModeLabeledStatement(node) {
|
|
44492
44987
|
// Grammar checking for labeledStatement
|
|
44493
|
-
if (inStrictMode && options
|
|
44988
|
+
if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) {
|
|
44494
44989
|
if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
|
|
44495
44990
|
errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
|
|
44496
44991
|
}
|
|
@@ -46006,7 +46501,7 @@ var ts;
|
|
|
46006
46501
|
host.getSourceFiles().forEach(function (sf) {
|
|
46007
46502
|
if (!sf.resolvedModules)
|
|
46008
46503
|
return;
|
|
46009
|
-
|
|
46504
|
+
sf.resolvedModules.forEach(function (r) {
|
|
46010
46505
|
if (r && r.packageId)
|
|
46011
46506
|
map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
|
|
46012
46507
|
});
|
|
@@ -46424,10 +46919,13 @@ var ts;
|
|
|
46424
46919
|
var undefinedProperties = new ts.Map();
|
|
46425
46920
|
var unknownSymbol = createSymbol(4 /* Property */, "unknown");
|
|
46426
46921
|
var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
|
|
46922
|
+
var unresolvedSymbols = new ts.Map();
|
|
46923
|
+
var errorTypes = new ts.Map();
|
|
46427
46924
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
46428
46925
|
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
46429
46926
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
46430
46927
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
46928
|
+
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
46431
46929
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
|
|
46432
46930
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46433
46931
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -47149,7 +47647,7 @@ var ts;
|
|
|
47149
47647
|
}
|
|
47150
47648
|
else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
47151
47649
|
// foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
|
|
47152
|
-
return !(compilerOptions
|
|
47650
|
+
return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47153
47651
|
&& ts.getContainingClass(declaration) === ts.getContainingClass(usage)
|
|
47154
47652
|
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
47155
47653
|
}
|
|
@@ -47177,7 +47675,7 @@ var ts;
|
|
|
47177
47675
|
return true;
|
|
47178
47676
|
}
|
|
47179
47677
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
47180
|
-
if (compilerOptions
|
|
47678
|
+
if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47181
47679
|
&& ts.getContainingClass(declaration)
|
|
47182
47680
|
&& (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
47183
47681
|
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
|
@@ -47355,7 +47853,7 @@ var ts;
|
|
|
47355
47853
|
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, issueSuggestions);
|
|
47356
47854
|
}
|
|
47357
47855
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, issueSuggestions) {
|
|
47358
|
-
var _a;
|
|
47856
|
+
var _a, _b, _c;
|
|
47359
47857
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
47360
47858
|
var result;
|
|
47361
47859
|
var lastLocation;
|
|
@@ -47425,7 +47923,7 @@ var ts;
|
|
|
47425
47923
|
isInExternalModule = true;
|
|
47426
47924
|
// falls through
|
|
47427
47925
|
case 260 /* ModuleDeclaration */:
|
|
47428
|
-
var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
|
|
47926
|
+
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
47429
47927
|
if (location.kind === 303 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
47430
47928
|
// It's an external module. First see if the module has an export default and if the local
|
|
47431
47929
|
// name of that export default matches.
|
|
@@ -47456,7 +47954,7 @@ var ts;
|
|
|
47456
47954
|
}
|
|
47457
47955
|
// ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs)
|
|
47458
47956
|
if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) {
|
|
47459
|
-
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((
|
|
47957
|
+
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) {
|
|
47460
47958
|
result = undefined;
|
|
47461
47959
|
}
|
|
47462
47960
|
else {
|
|
@@ -47465,7 +47963,7 @@ var ts;
|
|
|
47465
47963
|
}
|
|
47466
47964
|
break;
|
|
47467
47965
|
case 259 /* EnumDeclaration */:
|
|
47468
|
-
if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
|
|
47966
|
+
if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
|
|
47469
47967
|
break loop;
|
|
47470
47968
|
}
|
|
47471
47969
|
break;
|
|
@@ -47548,7 +48046,7 @@ var ts;
|
|
|
47548
48046
|
case 213 /* ArrowFunction */:
|
|
47549
48047
|
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
|
47550
48048
|
// for lower compile targets the resolved symbol is used to emit an error
|
|
47551
|
-
if (compilerOptions
|
|
48049
|
+
if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
|
|
47552
48050
|
break;
|
|
47553
48051
|
}
|
|
47554
48052
|
// falls through
|
|
@@ -47716,7 +48214,7 @@ var ts;
|
|
|
47716
48214
|
}
|
|
47717
48215
|
// Perform extra checks only if error reporting was requested
|
|
47718
48216
|
if (nameNotFoundMessage) {
|
|
47719
|
-
if (propertyWithInvalidInitializer && !(compilerOptions
|
|
48217
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
47720
48218
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
47721
48219
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
47722
48220
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -48294,7 +48792,7 @@ var ts;
|
|
|
48294
48792
|
if (!ts.isIdentifier(name)) {
|
|
48295
48793
|
return undefined;
|
|
48296
48794
|
}
|
|
48297
|
-
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions
|
|
48795
|
+
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
|
|
48298
48796
|
var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
|
|
48299
48797
|
if (targetSymbol) {
|
|
48300
48798
|
if (name.escapedText) {
|
|
@@ -48372,18 +48870,18 @@ var ts;
|
|
|
48372
48870
|
}
|
|
48373
48871
|
function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
|
|
48374
48872
|
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
48375
|
-
var message = compilerOptions
|
|
48873
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
|
|
48376
48874
|
ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48377
48875
|
error(name, message, declarationName);
|
|
48378
48876
|
}
|
|
48379
48877
|
else {
|
|
48380
48878
|
if (ts.isInJSFile(node)) {
|
|
48381
|
-
var message = compilerOptions
|
|
48879
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
|
|
48382
48880
|
ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48383
48881
|
error(name, message, declarationName);
|
|
48384
48882
|
}
|
|
48385
48883
|
else {
|
|
48386
|
-
var message = compilerOptions
|
|
48884
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
|
|
48387
48885
|
ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48388
48886
|
error(name, message, declarationName, declarationName, moduleName);
|
|
48389
48887
|
}
|
|
@@ -48824,6 +49322,7 @@ var ts;
|
|
|
48824
49322
|
: undefined;
|
|
48825
49323
|
}
|
|
48826
49324
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
49325
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48827
49326
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
48828
49327
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
48829
49328
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -48835,7 +49334,15 @@ var ts;
|
|
|
48835
49334
|
return ambientModule;
|
|
48836
49335
|
}
|
|
48837
49336
|
var currentSourceFile = ts.getSourceFileOfNode(location);
|
|
48838
|
-
var
|
|
49337
|
+
var contextSpecifier = ts.isStringLiteralLike(location)
|
|
49338
|
+
? location
|
|
49339
|
+
: ((_a = ts.findAncestor(location, ts.isImportCall)) === null || _a === void 0 ? void 0 : _a.arguments[0]) ||
|
|
49340
|
+
((_b = ts.findAncestor(location, ts.isImportDeclaration)) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) ||
|
|
49341
|
+
((_c = ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) ||
|
|
49342
|
+
((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
|
|
49343
|
+
((_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) ||
|
|
49344
|
+
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49345
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
|
|
48839
49346
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
48840
49347
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
48841
49348
|
if (sourceFile) {
|
|
@@ -48843,6 +49350,12 @@ var ts;
|
|
|
48843
49350
|
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
48844
49351
|
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
|
48845
49352
|
}
|
|
49353
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
|
|
49354
|
+
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
|
|
49355
|
+
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49356
|
+
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);
|
|
49357
|
+
}
|
|
49358
|
+
}
|
|
48846
49359
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
48847
49360
|
return getMergedSymbol(sourceFile.symbol);
|
|
48848
49361
|
}
|
|
@@ -48900,15 +49413,14 @@ var ts;
|
|
|
48900
49413
|
* Direct users to import source with .js extension if outputting an ES module.
|
|
48901
49414
|
* @see https://github.com/microsoft/TypeScript/issues/42151
|
|
48902
49415
|
*/
|
|
48903
|
-
|
|
48904
|
-
|
|
48905
|
-
replacedImportSource += ".js";
|
|
49416
|
+
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
49417
|
+
replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js";
|
|
48906
49418
|
}
|
|
48907
49419
|
error(errorNode, diag, tsExtension, replacedImportSource);
|
|
48908
49420
|
}
|
|
48909
49421
|
else if (!compilerOptions.resolveJsonModule &&
|
|
48910
49422
|
ts.fileExtensionIs(moduleReference, ".json" /* Json */) &&
|
|
48911
|
-
ts.getEmitModuleResolutionKind(compilerOptions)
|
|
49423
|
+
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic &&
|
|
48912
49424
|
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
48913
49425
|
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
48914
49426
|
}
|
|
@@ -48981,7 +49493,7 @@ var ts;
|
|
|
48981
49493
|
error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
|
|
48982
49494
|
return symbol;
|
|
48983
49495
|
}
|
|
48984
|
-
if (compilerOptions
|
|
49496
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
48985
49497
|
var referenceParent = referencingLocation.parent;
|
|
48986
49498
|
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
48987
49499
|
ts.isImportCall(referenceParent)) {
|
|
@@ -49866,7 +50378,9 @@ var ts;
|
|
|
49866
50378
|
var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
|
|
49867
50379
|
if (typeNode === undefined)
|
|
49868
50380
|
return ts.Debug.fail("should always get typenode");
|
|
49869
|
-
|
|
50381
|
+
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
|
|
50382
|
+
// Otherwise, we always strip comments out.
|
|
50383
|
+
var options = { removeComments: type !== unresolvedType };
|
|
49870
50384
|
var printer = ts.createPrinter(options);
|
|
49871
50385
|
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
|
|
49872
50386
|
printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
|
|
@@ -49946,6 +50460,7 @@ var ts;
|
|
|
49946
50460
|
isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
|
|
49947
50461
|
fileExists: function (fileName) { return host.fileExists(fileName); },
|
|
49948
50462
|
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
|
|
50463
|
+
readFile: host.readFile ? (function (fileName) { return host.readFile(fileName); }) : undefined,
|
|
49949
50464
|
} : undefined },
|
|
49950
50465
|
encounteredError: false,
|
|
49951
50466
|
reportedDiagnostic: false,
|
|
@@ -50011,6 +50526,12 @@ var ts;
|
|
|
50011
50526
|
type = getReducedType(type);
|
|
50012
50527
|
}
|
|
50013
50528
|
if (type.flags & 1 /* Any */) {
|
|
50529
|
+
if (type.aliasSymbol) {
|
|
50530
|
+
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
|
|
50531
|
+
}
|
|
50532
|
+
if (type === unresolvedType) {
|
|
50533
|
+
return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
|
|
50534
|
+
}
|
|
50014
50535
|
context.approximateLength += 3;
|
|
50015
50536
|
return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
|
|
50016
50537
|
}
|
|
@@ -51099,6 +51620,10 @@ var ts;
|
|
|
51099
51620
|
}
|
|
51100
51621
|
return specifier;
|
|
51101
51622
|
}
|
|
51623
|
+
function symbolToEntityNameNode(symbol) {
|
|
51624
|
+
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
|
|
51625
|
+
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
51626
|
+
}
|
|
51102
51627
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
51103
51628
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
51104
51629
|
var isTypeOf = meaning === 111551 /* Value */;
|
|
@@ -51107,7 +51632,7 @@ var ts;
|
|
|
51107
51632
|
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
|
|
51108
51633
|
var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
|
|
51109
51634
|
var specifier = getSpecifierForModuleSymbol(chain[0], context);
|
|
51110
|
-
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions)
|
|
51635
|
+
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
|
|
51111
51636
|
// If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
|
|
51112
51637
|
// since declaration files with these kinds of references are liable to fail when published :(
|
|
51113
51638
|
context.encounteredError = true;
|
|
@@ -51330,7 +51855,7 @@ var ts;
|
|
|
51330
51855
|
if (nameType) {
|
|
51331
51856
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
51332
51857
|
var name = "" + nameType.value;
|
|
51333
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
51858
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
51334
51859
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51335
51860
|
}
|
|
51336
51861
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -51344,7 +51869,7 @@ var ts;
|
|
|
51344
51869
|
}
|
|
51345
51870
|
}
|
|
51346
51871
|
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
51347
|
-
return ts.isIdentifierText(name, compilerOptions
|
|
51872
|
+
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
51348
51873
|
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
51349
51874
|
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51350
51875
|
}
|
|
@@ -51385,7 +51910,7 @@ var ts;
|
|
|
51385
51910
|
* so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
|
|
51386
51911
|
*/
|
|
51387
51912
|
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
51388
|
-
if (type
|
|
51913
|
+
if (!isErrorType(type) && enclosingDeclaration) {
|
|
51389
51914
|
var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
|
|
51390
51915
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
51391
51916
|
// try to reuse the existing annotation
|
|
@@ -51408,7 +51933,7 @@ var ts;
|
|
|
51408
51933
|
return result;
|
|
51409
51934
|
}
|
|
51410
51935
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
51411
|
-
if (type
|
|
51936
|
+
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
51412
51937
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
51413
51938
|
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
|
|
51414
51939
|
var annotated = getTypeFromTypeNode(annotation);
|
|
@@ -51515,7 +52040,7 @@ var ts;
|
|
|
51515
52040
|
/*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
51516
52041
|
}
|
|
51517
52042
|
}
|
|
51518
|
-
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
|
|
52043
|
+
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
|
|
51519
52044
|
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51520
52045
|
}
|
|
51521
52046
|
if (ts.isLiteralImportTypeNode(node)) {
|
|
@@ -52278,6 +52803,27 @@ var ts;
|
|
|
52278
52803
|
/*decorators*/ undefined,
|
|
52279
52804
|
/*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), staticMembers, true), constructors, true), publicProperties, true), privateProperties, true)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags);
|
|
52280
52805
|
}
|
|
52806
|
+
function getSomeTargetNameFromDeclarations(declarations) {
|
|
52807
|
+
return ts.firstDefined(declarations, function (d) {
|
|
52808
|
+
if (ts.isImportSpecifier(d) || ts.isExportSpecifier(d)) {
|
|
52809
|
+
return ts.idText(d.propertyName || d.name);
|
|
52810
|
+
}
|
|
52811
|
+
if (ts.isBinaryExpression(d) || ts.isExportAssignment(d)) {
|
|
52812
|
+
var expression = ts.isExportAssignment(d) ? d.expression : d.right;
|
|
52813
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
52814
|
+
return ts.idText(expression.name);
|
|
52815
|
+
}
|
|
52816
|
+
}
|
|
52817
|
+
if (isAliasSymbolDeclaration(d)) {
|
|
52818
|
+
// This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module.
|
|
52819
|
+
var name = ts.getNameOfDeclaration(d);
|
|
52820
|
+
if (name && ts.isIdentifier(name)) {
|
|
52821
|
+
return ts.idText(name);
|
|
52822
|
+
}
|
|
52823
|
+
}
|
|
52824
|
+
return undefined;
|
|
52825
|
+
});
|
|
52826
|
+
}
|
|
52281
52827
|
function serializeAsAlias(symbol, localName, modifierFlags) {
|
|
52282
52828
|
var _a, _b, _c, _d, _e;
|
|
52283
52829
|
// synthesize an alias, eg `export { symbolName as Name }`
|
|
@@ -52290,8 +52836,10 @@ var ts;
|
|
|
52290
52836
|
if (!target) {
|
|
52291
52837
|
return;
|
|
52292
52838
|
}
|
|
52293
|
-
|
|
52294
|
-
|
|
52839
|
+
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
|
|
52840
|
+
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
|
|
52841
|
+
var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName);
|
|
52842
|
+
if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
|
|
52295
52843
|
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
|
|
52296
52844
|
verbatimTargetName = "default" /* Default */;
|
|
52297
52845
|
}
|
|
@@ -52838,7 +53386,7 @@ var ts;
|
|
|
52838
53386
|
if (nameType) {
|
|
52839
53387
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52840
53388
|
var name = "" + nameType.value;
|
|
52841
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
53389
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52842
53390
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
52843
53391
|
}
|
|
52844
53392
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -53143,6 +53691,11 @@ var ts;
|
|
|
53143
53691
|
function isTypeAny(type) {
|
|
53144
53692
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
53145
53693
|
}
|
|
53694
|
+
function isErrorType(type) {
|
|
53695
|
+
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
|
|
53696
|
+
// a reference to an unresolved symbol. We want those to behave like the errorType.
|
|
53697
|
+
return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
|
|
53698
|
+
}
|
|
53146
53699
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
53147
53700
|
// assigned by contextual typing.
|
|
53148
53701
|
function getTypeForBindingElementParent(node) {
|
|
@@ -53660,7 +54213,7 @@ var ts;
|
|
|
53660
54213
|
if (!declaredType) {
|
|
53661
54214
|
return type;
|
|
53662
54215
|
}
|
|
53663
|
-
else if (declaredType
|
|
54216
|
+
else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
|
|
53664
54217
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
|
|
53665
54218
|
}
|
|
53666
54219
|
}
|
|
@@ -54554,7 +55107,7 @@ var ts;
|
|
|
54554
55107
|
for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
|
|
54555
55108
|
var node = implementsTypeNodes_1[_b];
|
|
54556
55109
|
var implementsType = getTypeFromTypeNode(node);
|
|
54557
|
-
if (implementsType
|
|
55110
|
+
if (!isErrorType(implementsType)) {
|
|
54558
55111
|
if (resolvedImplementsTypes === ts.emptyArray) {
|
|
54559
55112
|
resolvedImplementsTypes = [implementsType];
|
|
54560
55113
|
}
|
|
@@ -54634,7 +55187,7 @@ var ts;
|
|
|
54634
55187
|
}
|
|
54635
55188
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
54636
55189
|
}
|
|
54637
|
-
if (baseType
|
|
55190
|
+
if (isErrorType(baseType)) {
|
|
54638
55191
|
return type.resolvedBaseTypes = ts.emptyArray;
|
|
54639
55192
|
}
|
|
54640
55193
|
var reducedBaseType = getReducedType(baseType);
|
|
@@ -54690,7 +55243,7 @@ var ts;
|
|
|
54690
55243
|
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
|
|
54691
55244
|
var node = _c[_b];
|
|
54692
55245
|
var baseType = getReducedType(getTypeFromTypeNode(node));
|
|
54693
|
-
if (baseType
|
|
55246
|
+
if (!isErrorType(baseType)) {
|
|
54694
55247
|
if (isValidBaseType(baseType)) {
|
|
54695
55248
|
if (type !== baseType && !hasBaseType(baseType, type)) {
|
|
54696
55249
|
if (type.resolvedBaseTypes === ts.emptyArray) {
|
|
@@ -56532,7 +57085,7 @@ var ts;
|
|
|
56532
57085
|
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
|
|
56533
57086
|
var current = _c[_i];
|
|
56534
57087
|
var type = getApparentType(current);
|
|
56535
|
-
if (!(type
|
|
57088
|
+
if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
|
|
56536
57089
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
56537
57090
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
56538
57091
|
if (prop) {
|
|
@@ -57482,7 +58035,7 @@ var ts;
|
|
|
57482
58035
|
}
|
|
57483
58036
|
else {
|
|
57484
58037
|
var type = getTypeFromTypeNode(constraintDeclaration);
|
|
57485
|
-
if (type.flags & 1 /* Any */ && type
|
|
58038
|
+
if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
|
|
57486
58039
|
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
|
|
57487
58040
|
// use unknown otherwise
|
|
57488
58041
|
type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
|
|
@@ -57654,6 +58207,18 @@ var ts;
|
|
|
57654
58207
|
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
|
57655
58208
|
*/
|
|
57656
58209
|
function getTypeFromTypeAliasReference(node, symbol) {
|
|
58210
|
+
if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
|
|
58211
|
+
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
58212
|
+
var id = getAliasId(symbol, typeArguments);
|
|
58213
|
+
var errorType_1 = errorTypes.get(id);
|
|
58214
|
+
if (!errorType_1) {
|
|
58215
|
+
errorType_1 = createIntrinsicType(1 /* Any */, "error");
|
|
58216
|
+
errorType_1.aliasSymbol = symbol;
|
|
58217
|
+
errorType_1.aliasTypeArguments = typeArguments;
|
|
58218
|
+
errorTypes.set(id, errorType_1);
|
|
58219
|
+
}
|
|
58220
|
+
return errorType_1;
|
|
58221
|
+
}
|
|
57657
58222
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
57658
58223
|
var typeParameters = getSymbolLinks(symbol).typeParameters;
|
|
57659
58224
|
if (typeParameters) {
|
|
@@ -57695,11 +58260,37 @@ var ts;
|
|
|
57695
58260
|
}
|
|
57696
58261
|
return undefined;
|
|
57697
58262
|
}
|
|
57698
|
-
function
|
|
57699
|
-
|
|
58263
|
+
function getSymbolPath(symbol) {
|
|
58264
|
+
return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
|
|
58265
|
+
}
|
|
58266
|
+
function getUnresolvedSymbolForEntityName(name) {
|
|
58267
|
+
var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
|
|
58268
|
+
name.kind === 205 /* PropertyAccessExpression */ ? name.name :
|
|
58269
|
+
name;
|
|
58270
|
+
var text = identifier.escapedText;
|
|
58271
|
+
if (text) {
|
|
58272
|
+
var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
|
|
58273
|
+
name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
|
|
58274
|
+
undefined;
|
|
58275
|
+
var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
|
|
58276
|
+
var result = unresolvedSymbols.get(path);
|
|
58277
|
+
if (!result) {
|
|
58278
|
+
unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
|
|
58279
|
+
result.parent = parentSymbol;
|
|
58280
|
+
result.declaredType = unresolvedType;
|
|
58281
|
+
}
|
|
58282
|
+
return result;
|
|
58283
|
+
}
|
|
58284
|
+
return unknownSymbol;
|
|
58285
|
+
}
|
|
58286
|
+
function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
|
|
58287
|
+
var name = getTypeReferenceName(typeReference);
|
|
58288
|
+
if (!name) {
|
|
57700
58289
|
return unknownSymbol;
|
|
57701
58290
|
}
|
|
57702
|
-
|
|
58291
|
+
var symbol = resolveEntityName(name, meaning, ignoreErrors);
|
|
58292
|
+
return symbol && symbol !== unknownSymbol ? symbol :
|
|
58293
|
+
ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
|
|
57703
58294
|
}
|
|
57704
58295
|
function getTypeReferenceType(node, symbol) {
|
|
57705
58296
|
if (symbol === unknownSymbol) {
|
|
@@ -57724,7 +58315,7 @@ var ts;
|
|
|
57724
58315
|
}
|
|
57725
58316
|
else {
|
|
57726
58317
|
// Resolve the type reference as a Type for the purpose of reporting errors.
|
|
57727
|
-
resolveTypeReferenceName(
|
|
58318
|
+
resolveTypeReferenceName(node, 788968 /* Type */);
|
|
57728
58319
|
return getTypeOfSymbol(symbol);
|
|
57729
58320
|
}
|
|
57730
58321
|
}
|
|
@@ -57868,18 +58459,18 @@ var ts;
|
|
|
57868
58459
|
if (isJSDocTypeReference(node)) {
|
|
57869
58460
|
type = getIntendedTypeFromJSDocTypeReference(node);
|
|
57870
58461
|
if (!type) {
|
|
57871
|
-
symbol = resolveTypeReferenceName(
|
|
58462
|
+
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
|
|
57872
58463
|
if (symbol === unknownSymbol) {
|
|
57873
|
-
symbol = resolveTypeReferenceName(
|
|
58464
|
+
symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
|
|
57874
58465
|
}
|
|
57875
58466
|
else {
|
|
57876
|
-
resolveTypeReferenceName(
|
|
58467
|
+
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
|
|
57877
58468
|
}
|
|
57878
58469
|
type = getTypeReferenceType(node, symbol);
|
|
57879
58470
|
}
|
|
57880
58471
|
}
|
|
57881
58472
|
if (!type) {
|
|
57882
|
-
symbol = resolveTypeReferenceName(
|
|
58473
|
+
symbol = resolveTypeReferenceName(node, meaning);
|
|
57883
58474
|
type = getTypeReferenceType(node, symbol);
|
|
57884
58475
|
}
|
|
57885
58476
|
// Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
|
|
@@ -58140,7 +58731,7 @@ var ts;
|
|
|
58140
58731
|
function mayResolveTypeAlias(node) {
|
|
58141
58732
|
switch (node.kind) {
|
|
58142
58733
|
case 177 /* TypeReference */:
|
|
58143
|
-
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node
|
|
58734
|
+
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
|
|
58144
58735
|
case 180 /* TypeQuery */:
|
|
58145
58736
|
return true;
|
|
58146
58737
|
case 192 /* TypeOperator */:
|
|
@@ -58415,8 +59006,6 @@ var ts;
|
|
|
58415
59006
|
// We ignore 'never' types in unions
|
|
58416
59007
|
if (!(flags & 131072 /* Never */)) {
|
|
58417
59008
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58418
|
-
if (flags & 469499904 /* StructuredOrInstantiable */)
|
|
58419
|
-
includes |= 262144 /* IncludesStructuredOrInstantiable */;
|
|
58420
59009
|
if (type === wildcardType)
|
|
58421
59010
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58422
59011
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -58722,13 +59311,19 @@ var ts;
|
|
|
58722
59311
|
if (type === wildcardType)
|
|
58723
59312
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58724
59313
|
}
|
|
58725
|
-
else if (
|
|
58726
|
-
if (
|
|
58727
|
-
|
|
58728
|
-
|
|
58729
|
-
|
|
59314
|
+
else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
59315
|
+
if (exactOptionalPropertyTypes && type === missingType) {
|
|
59316
|
+
includes |= 262144 /* IncludesMissingType */;
|
|
59317
|
+
type = undefinedType;
|
|
59318
|
+
}
|
|
59319
|
+
if (!typeSet.has(type.id.toString())) {
|
|
59320
|
+
if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) {
|
|
59321
|
+
// We have seen two distinct unit types which means we should reduce to an
|
|
59322
|
+
// empty intersection. Adding TypeFlags.NonPrimitive causes that to happen.
|
|
59323
|
+
includes |= 67108864 /* NonPrimitive */;
|
|
59324
|
+
}
|
|
59325
|
+
typeSet.set(type.id.toString(), type);
|
|
58730
59326
|
}
|
|
58731
|
-
typeSet.set(type.id.toString(), type);
|
|
58732
59327
|
}
|
|
58733
59328
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58734
59329
|
}
|
|
@@ -58801,14 +59396,13 @@ var ts;
|
|
|
58801
59396
|
}
|
|
58802
59397
|
return false;
|
|
58803
59398
|
}
|
|
58804
|
-
function
|
|
58805
|
-
|
|
58806
|
-
|
|
58807
|
-
|
|
58808
|
-
|
|
58809
|
-
return
|
|
59399
|
+
function eachIsUnionContaining(types, flag) {
|
|
59400
|
+
return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
|
|
59401
|
+
}
|
|
59402
|
+
function removeFromEach(types, flag) {
|
|
59403
|
+
for (var i = 0; i < types.length; i++) {
|
|
59404
|
+
types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
|
|
58810
59405
|
}
|
|
58811
|
-
return false;
|
|
58812
59406
|
}
|
|
58813
59407
|
// If the given list of types contains more than one union of primitive types, replace the
|
|
58814
59408
|
// first with a union containing an intersection of those primitive types, then remove the
|
|
@@ -58917,6 +59511,9 @@ var ts;
|
|
|
58917
59511
|
if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
|
|
58918
59512
|
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
|
|
58919
59513
|
}
|
|
59514
|
+
if (includes & 262144 /* IncludesMissingType */) {
|
|
59515
|
+
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
59516
|
+
}
|
|
58920
59517
|
if (typeSet.length === 0) {
|
|
58921
59518
|
return unknownType;
|
|
58922
59519
|
}
|
|
@@ -58933,10 +59530,13 @@ var ts;
|
|
|
58933
59530
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
58934
59531
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
58935
59532
|
}
|
|
58936
|
-
else if (
|
|
58937
|
-
|
|
59533
|
+
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
59534
|
+
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
59535
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
59536
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58938
59537
|
}
|
|
58939
|
-
else if (
|
|
59538
|
+
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
59539
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
58940
59540
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58941
59541
|
}
|
|
58942
59542
|
else {
|
|
@@ -60669,7 +61269,7 @@ var ts;
|
|
|
60669
61269
|
var mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
60670
61270
|
if (typeVariable !== mappedTypeVariable) {
|
|
60671
61271
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
60672
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t
|
|
61272
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
60673
61273
|
if (!type.declaration.nameType) {
|
|
60674
61274
|
if (isArrayType(t)) {
|
|
60675
61275
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -60711,7 +61311,7 @@ var ts;
|
|
|
60711
61311
|
}
|
|
60712
61312
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
60713
61313
|
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
|
|
60714
|
-
return elementType
|
|
61314
|
+
return isErrorType(elementType) ? errorType :
|
|
60715
61315
|
createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
60716
61316
|
}
|
|
60717
61317
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
@@ -61929,7 +62529,7 @@ var ts;
|
|
|
61929
62529
|
path = "" + str;
|
|
61930
62530
|
}
|
|
61931
62531
|
// Otherwise write a dotted name if possible
|
|
61932
|
-
else if (ts.isIdentifierText(str, compilerOptions
|
|
62532
|
+
else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) {
|
|
61933
62533
|
path = path + "." + str;
|
|
61934
62534
|
}
|
|
61935
62535
|
// Failing that, check if the name is already a computed name
|
|
@@ -62293,7 +62893,7 @@ var ts;
|
|
|
62293
62893
|
var targetTypes = target.types;
|
|
62294
62894
|
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
62295
62895
|
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
62296
|
-
if (intrinsicAttributes
|
|
62896
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
62297
62897
|
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
62298
62898
|
// do not report top error
|
|
62299
62899
|
return result;
|
|
@@ -67808,6 +68408,9 @@ var ts;
|
|
|
67808
68408
|
case 102 /* InstanceOfKeyword */:
|
|
67809
68409
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
67810
68410
|
case 101 /* InKeyword */:
|
|
68411
|
+
if (ts.isPrivateIdentifier(expr.left)) {
|
|
68412
|
+
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
68413
|
+
}
|
|
67811
68414
|
var target = getReferenceCandidate(expr.right);
|
|
67812
68415
|
var leftType = getTypeOfNode(expr.left);
|
|
67813
68416
|
if (leftType.flags & 128 /* StringLiteral */) {
|
|
@@ -67837,6 +68440,22 @@ var ts;
|
|
|
67837
68440
|
}
|
|
67838
68441
|
return type;
|
|
67839
68442
|
}
|
|
68443
|
+
function narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue) {
|
|
68444
|
+
var target = getReferenceCandidate(expr.right);
|
|
68445
|
+
if (!isMatchingReference(reference, target)) {
|
|
68446
|
+
return type;
|
|
68447
|
+
}
|
|
68448
|
+
ts.Debug.assertNode(expr.left, ts.isPrivateIdentifier);
|
|
68449
|
+
var symbol = getSymbolForPrivateIdentifierExpression(expr.left);
|
|
68450
|
+
if (symbol === undefined) {
|
|
68451
|
+
return type;
|
|
68452
|
+
}
|
|
68453
|
+
var classSymbol = symbol.parent;
|
|
68454
|
+
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
68455
|
+
? getTypeOfSymbol(classSymbol)
|
|
68456
|
+
: getDeclaredTypeOfSymbol(classSymbol);
|
|
68457
|
+
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
|
68458
|
+
}
|
|
67840
68459
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
67841
68460
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
67842
68461
|
// When operator is === and type of value excludes undefined, null and undefined is removed from type of obj in true branch.
|
|
@@ -69270,8 +69889,7 @@ var ts;
|
|
|
69270
69889
|
if (result) {
|
|
69271
69890
|
return result;
|
|
69272
69891
|
}
|
|
69273
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
|
|
69274
|
-
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69892
|
+
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
|
|
69275
69893
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
69276
69894
|
}
|
|
69277
69895
|
}
|
|
@@ -69852,7 +70470,7 @@ var ts;
|
|
|
69852
70470
|
var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
|
|
69853
70471
|
propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
|
|
69854
70472
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
69855
|
-
if (intrinsicAttribs
|
|
70473
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
69856
70474
|
propsType = intersectTypes(intrinsicAttribs, propsType);
|
|
69857
70475
|
}
|
|
69858
70476
|
return propsType;
|
|
@@ -69945,7 +70563,7 @@ var ts;
|
|
|
69945
70563
|
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
|
69946
70564
|
var apparentAttributesType = attributesType;
|
|
69947
70565
|
var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
|
|
69948
|
-
if (intrinsicClassAttribs
|
|
70566
|
+
if (!isErrorType(intrinsicClassAttribs)) {
|
|
69949
70567
|
var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
|
69950
70568
|
var hostClassType = getReturnTypeOfSignature(sig);
|
|
69951
70569
|
apparentAttributesType = intersectTypes(typeParams
|
|
@@ -69953,7 +70571,7 @@ var ts;
|
|
|
69953
70571
|
: intrinsicClassAttribs, apparentAttributesType);
|
|
69954
70572
|
}
|
|
69955
70573
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
69956
|
-
if (intrinsicAttribs
|
|
70574
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
69957
70575
|
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
|
69958
70576
|
}
|
|
69959
70577
|
return apparentAttributesType;
|
|
@@ -70421,7 +71039,7 @@ var ts;
|
|
|
70421
71039
|
checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
|
|
70422
71040
|
}
|
|
70423
71041
|
offset = propertiesArray.length;
|
|
70424
|
-
if (spread
|
|
71042
|
+
if (isErrorType(spread)) {
|
|
70425
71043
|
continue;
|
|
70426
71044
|
}
|
|
70427
71045
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
@@ -70478,7 +71096,7 @@ var ts;
|
|
|
70478
71096
|
}
|
|
70479
71097
|
}
|
|
70480
71098
|
}
|
|
70481
|
-
if (spread
|
|
71099
|
+
if (isErrorType(spread)) {
|
|
70482
71100
|
return errorType;
|
|
70483
71101
|
}
|
|
70484
71102
|
if (spread !== emptyObjectType) {
|
|
@@ -70745,7 +71363,7 @@ var ts;
|
|
|
70745
71363
|
var links = getNodeLinks(node);
|
|
70746
71364
|
if (!links.resolvedSymbol) {
|
|
70747
71365
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
|
|
70748
|
-
if (intrinsicElementsType
|
|
71366
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70749
71367
|
// Property case
|
|
70750
71368
|
if (!ts.isIdentifier(node.tagName))
|
|
70751
71369
|
return ts.Debug.fail();
|
|
@@ -70908,7 +71526,7 @@ var ts;
|
|
|
70908
71526
|
// var CustomTag: "h1" = "h1";
|
|
70909
71527
|
// <CustomTag> Hello World </CustomTag>
|
|
70910
71528
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
|
|
70911
|
-
if (intrinsicElementsType
|
|
71529
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70912
71530
|
var stringLiteralTypeName = type.value;
|
|
70913
71531
|
var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
|
|
70914
71532
|
if (intrinsicProp) {
|
|
@@ -70976,7 +71594,7 @@ var ts;
|
|
|
70976
71594
|
}
|
|
70977
71595
|
function getJsxElementClassTypeAt(location) {
|
|
70978
71596
|
var type = getJsxType(JsxNames.ElementClass, location);
|
|
70979
|
-
if (type
|
|
71597
|
+
if (isErrorType(type))
|
|
70980
71598
|
return undefined;
|
|
70981
71599
|
return type;
|
|
70982
71600
|
}
|
|
@@ -71282,7 +71900,7 @@ var ts;
|
|
|
71282
71900
|
}
|
|
71283
71901
|
function checkNonNullNonVoidType(type, node) {
|
|
71284
71902
|
var nonNullType = checkNonNullType(type, node);
|
|
71285
|
-
if (nonNullType
|
|
71903
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
71286
71904
|
error(node, ts.Diagnostics.Object_is_possibly_undefined);
|
|
71287
71905
|
}
|
|
71288
71906
|
return nonNullType;
|
|
@@ -71317,6 +71935,36 @@ var ts;
|
|
|
71317
71935
|
}
|
|
71318
71936
|
}
|
|
71319
71937
|
}
|
|
71938
|
+
function checkGrammarPrivateIdentifierExpression(privId) {
|
|
71939
|
+
if (!ts.getContainingClass(privId)) {
|
|
71940
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
71941
|
+
}
|
|
71942
|
+
if (!ts.isExpressionNode(privId)) {
|
|
71943
|
+
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);
|
|
71944
|
+
}
|
|
71945
|
+
if (!getSymbolForPrivateIdentifierExpression(privId)) {
|
|
71946
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId));
|
|
71947
|
+
}
|
|
71948
|
+
return false;
|
|
71949
|
+
}
|
|
71950
|
+
function checkPrivateIdentifierExpression(privId) {
|
|
71951
|
+
checkGrammarPrivateIdentifierExpression(privId);
|
|
71952
|
+
var symbol = getSymbolForPrivateIdentifierExpression(privId);
|
|
71953
|
+
if (symbol) {
|
|
71954
|
+
markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false);
|
|
71955
|
+
}
|
|
71956
|
+
return anyType;
|
|
71957
|
+
}
|
|
71958
|
+
function getSymbolForPrivateIdentifierExpression(privId) {
|
|
71959
|
+
if (!ts.isExpressionNode(privId)) {
|
|
71960
|
+
return undefined;
|
|
71961
|
+
}
|
|
71962
|
+
var links = getNodeLinks(privId);
|
|
71963
|
+
if (links.resolvedSymbol === undefined) {
|
|
71964
|
+
links.resolvedSymbol = lookupSymbolForPrivateIdentifierDeclaration(privId.escapedText, privId);
|
|
71965
|
+
}
|
|
71966
|
+
return links.resolvedSymbol;
|
|
71967
|
+
}
|
|
71320
71968
|
function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
|
|
71321
71969
|
return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
|
|
71322
71970
|
}
|
|
@@ -71380,7 +72028,7 @@ var ts;
|
|
|
71380
72028
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
71381
72029
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
71382
72030
|
}
|
|
71383
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions
|
|
72031
|
+
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
71384
72032
|
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
71385
72033
|
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
71386
72034
|
if (n === lexicalClass_1)
|
|
@@ -71399,7 +72047,7 @@ var ts;
|
|
|
71399
72047
|
}
|
|
71400
72048
|
if (isAnyLike) {
|
|
71401
72049
|
if (lexicallyScopedSymbol) {
|
|
71402
|
-
return apparentType;
|
|
72050
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71403
72051
|
}
|
|
71404
72052
|
if (!ts.getContainingClass(right)) {
|
|
71405
72053
|
grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -71423,7 +72071,8 @@ var ts;
|
|
|
71423
72071
|
if (ts.isIdentifier(left) && parentSymbol) {
|
|
71424
72072
|
markAliasReferenced(parentSymbol, node);
|
|
71425
72073
|
}
|
|
71426
|
-
return apparentType;
|
|
72074
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
72075
|
+
;
|
|
71427
72076
|
}
|
|
71428
72077
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
71429
72078
|
}
|
|
@@ -71882,7 +72531,7 @@ var ts;
|
|
|
71882
72531
|
}
|
|
71883
72532
|
function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
|
|
71884
72533
|
// Short-circuiting for improved performance.
|
|
71885
|
-
if (
|
|
72534
|
+
if (isTypeAny(type)) {
|
|
71886
72535
|
return true;
|
|
71887
72536
|
}
|
|
71888
72537
|
var prop = getPropertyOfType(type, propertyName);
|
|
@@ -71900,7 +72549,7 @@ var ts;
|
|
|
71900
72549
|
*/
|
|
71901
72550
|
function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
|
|
71902
72551
|
// Short-circuiting for improved performance.
|
|
71903
|
-
if (
|
|
72552
|
+
if (isTypeAny(containingType)) {
|
|
71904
72553
|
return true;
|
|
71905
72554
|
}
|
|
71906
72555
|
// A #private property access in an optional chain is an error dealt with by the parser.
|
|
@@ -71971,7 +72620,7 @@ var ts;
|
|
|
71971
72620
|
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
|
|
71972
72621
|
var indexExpression = node.argumentExpression;
|
|
71973
72622
|
var indexType = checkExpression(indexExpression);
|
|
71974
|
-
if (objectType
|
|
72623
|
+
if (isErrorType(objectType) || objectType === silentNeverType) {
|
|
71975
72624
|
return objectType;
|
|
71976
72625
|
}
|
|
71977
72626
|
if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
|
|
@@ -72216,7 +72865,7 @@ var ts;
|
|
|
72216
72865
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
72217
72866
|
// return type of 'wrap'.
|
|
72218
72867
|
if (node.kind !== 164 /* Decorator */) {
|
|
72219
|
-
var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
72868
|
+
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
72220
72869
|
if (contextualType) {
|
|
72221
72870
|
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
72222
72871
|
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
@@ -73165,7 +73814,7 @@ var ts;
|
|
|
73165
73814
|
}
|
|
73166
73815
|
return anySignature;
|
|
73167
73816
|
}
|
|
73168
|
-
if (superType
|
|
73817
|
+
if (!isErrorType(superType)) {
|
|
73169
73818
|
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
|
|
73170
73819
|
// with the type arguments specified in the extends clause.
|
|
73171
73820
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
|
|
@@ -73193,7 +73842,7 @@ var ts;
|
|
|
73193
73842
|
return silentNeverSignature;
|
|
73194
73843
|
}
|
|
73195
73844
|
var apparentType = getApparentType(funcType);
|
|
73196
|
-
if (apparentType
|
|
73845
|
+
if (isErrorType(apparentType)) {
|
|
73197
73846
|
// Another error has already been reported
|
|
73198
73847
|
return resolveErrorCall(node);
|
|
73199
73848
|
}
|
|
@@ -73209,7 +73858,7 @@ var ts;
|
|
|
73209
73858
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
73210
73859
|
// The unknownType indicates that an error already occurred (and was reported). No
|
|
73211
73860
|
// need to report another error in this case.
|
|
73212
|
-
if (funcType
|
|
73861
|
+
if (!isErrorType(funcType) && node.typeArguments) {
|
|
73213
73862
|
error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
73214
73863
|
}
|
|
73215
73864
|
return resolveUntypedCall(node);
|
|
@@ -73286,7 +73935,7 @@ var ts;
|
|
|
73286
73935
|
// signatures for overload resolution. The result type of the function call becomes
|
|
73287
73936
|
// the result type of the operation.
|
|
73288
73937
|
expressionType = getApparentType(expressionType);
|
|
73289
|
-
if (expressionType
|
|
73938
|
+
if (isErrorType(expressionType)) {
|
|
73290
73939
|
// Another error has already been reported
|
|
73291
73940
|
return resolveErrorCall(node);
|
|
73292
73941
|
}
|
|
@@ -73501,7 +74150,7 @@ var ts;
|
|
|
73501
74150
|
function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
|
|
73502
74151
|
var tagType = checkExpression(node.tag);
|
|
73503
74152
|
var apparentType = getApparentType(tagType);
|
|
73504
|
-
if (apparentType
|
|
74153
|
+
if (isErrorType(apparentType)) {
|
|
73505
74154
|
// Another error has already been reported
|
|
73506
74155
|
return resolveErrorCall(node);
|
|
73507
74156
|
}
|
|
@@ -73547,7 +74196,7 @@ var ts;
|
|
|
73547
74196
|
function resolveDecorator(node, candidatesOutArray, checkMode) {
|
|
73548
74197
|
var funcType = checkExpression(node.expression);
|
|
73549
74198
|
var apparentType = getApparentType(funcType);
|
|
73550
|
-
if (apparentType
|
|
74199
|
+
if (isErrorType(apparentType)) {
|
|
73551
74200
|
return resolveErrorCall(node);
|
|
73552
74201
|
}
|
|
73553
74202
|
var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
|
@@ -73602,7 +74251,7 @@ var ts;
|
|
|
73602
74251
|
}
|
|
73603
74252
|
var exprTypes = checkExpression(node.tagName);
|
|
73604
74253
|
var apparentType = getApparentType(exprTypes);
|
|
73605
|
-
if (apparentType
|
|
74254
|
+
if (isErrorType(apparentType)) {
|
|
73606
74255
|
return resolveErrorCall(node);
|
|
73607
74256
|
}
|
|
73608
74257
|
var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
|
|
@@ -73925,7 +74574,7 @@ var ts;
|
|
|
73925
74574
|
}
|
|
73926
74575
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
73927
74576
|
var _a;
|
|
73928
|
-
if (allowSyntheticDefaultImports && type && type
|
|
74577
|
+
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
73929
74578
|
var synthType = type;
|
|
73930
74579
|
if (!synthType.syntheticType) {
|
|
73931
74580
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
@@ -73988,6 +74637,12 @@ var ts;
|
|
|
73988
74637
|
return getReturnTypeOfSignature(signature);
|
|
73989
74638
|
}
|
|
73990
74639
|
function checkAssertion(node) {
|
|
74640
|
+
if (node.kind === 210 /* TypeAssertionExpression */) {
|
|
74641
|
+
var file = ts.getSourceFileOfNode(node);
|
|
74642
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
74643
|
+
grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
74644
|
+
}
|
|
74645
|
+
}
|
|
73991
74646
|
return checkAssertionWorker(node, node.type, node.expression);
|
|
73992
74647
|
}
|
|
73993
74648
|
function isValidConstAssertionArgument(node) {
|
|
@@ -74031,7 +74686,7 @@ var ts;
|
|
|
74031
74686
|
checkSourceElement(type);
|
|
74032
74687
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
74033
74688
|
var targetType = getTypeFromTypeNode(type);
|
|
74034
|
-
if (produceDiagnostics && targetType
|
|
74689
|
+
if (produceDiagnostics && !isErrorType(targetType)) {
|
|
74035
74690
|
var widenedType = getWidenedType(exprType);
|
|
74036
74691
|
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
74037
74692
|
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);
|
|
@@ -74064,7 +74719,7 @@ var ts;
|
|
|
74064
74719
|
return getGlobalImportMetaExpressionType();
|
|
74065
74720
|
case 103 /* NewKeyword */:
|
|
74066
74721
|
var type = checkNewTargetMetaProperty(node);
|
|
74067
|
-
return type
|
|
74722
|
+
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
|
|
74068
74723
|
default:
|
|
74069
74724
|
ts.Debug.assertNever(node.keywordToken);
|
|
74070
74725
|
}
|
|
@@ -74086,7 +74741,14 @@ var ts;
|
|
|
74086
74741
|
}
|
|
74087
74742
|
function checkImportMetaProperty(node) {
|
|
74088
74743
|
if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
|
|
74089
|
-
|
|
74744
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74745
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74746
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74747
|
+
}
|
|
74748
|
+
}
|
|
74749
|
+
else {
|
|
74750
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74751
|
+
}
|
|
74090
74752
|
}
|
|
74091
74753
|
var file = ts.getSourceFileOfNode(node);
|
|
74092
74754
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
@@ -75030,9 +75692,9 @@ var ts;
|
|
|
75030
75692
|
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);
|
|
75031
75693
|
diagnostics.add(diagnostic);
|
|
75032
75694
|
}
|
|
75033
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
75695
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75034
75696
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
75035
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75697
|
+
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_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher);
|
|
75036
75698
|
diagnostics.add(diagnostic);
|
|
75037
75699
|
}
|
|
75038
75700
|
}
|
|
@@ -75057,7 +75719,7 @@ var ts;
|
|
|
75057
75719
|
}
|
|
75058
75720
|
var operandType = checkExpression(node.expression);
|
|
75059
75721
|
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);
|
|
75060
|
-
if (awaitedType === operandType && awaitedType
|
|
75722
|
+
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
75061
75723
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
|
|
75062
75724
|
}
|
|
75063
75725
|
return awaitedType;
|
|
@@ -75206,11 +75868,29 @@ var ts;
|
|
|
75206
75868
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75207
75869
|
return silentNeverType;
|
|
75208
75870
|
}
|
|
75209
|
-
|
|
75871
|
+
if (ts.isPrivateIdentifier(left)) {
|
|
75872
|
+
if (languageVersion < 99 /* ESNext */) {
|
|
75873
|
+
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
75874
|
+
}
|
|
75875
|
+
// Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type
|
|
75876
|
+
// which provides us with the opportunity to emit more detailed errors
|
|
75877
|
+
if (!getNodeLinks(left).resolvedSymbol && ts.getContainingClass(left)) {
|
|
75878
|
+
var isUncheckedJS = isUncheckedJSSuggestion(left, rightType.symbol, /*excludeClasses*/ true);
|
|
75879
|
+
reportNonexistentProperty(left, rightType, isUncheckedJS);
|
|
75880
|
+
}
|
|
75881
|
+
}
|
|
75882
|
+
else {
|
|
75883
|
+
leftType = checkNonNullType(leftType, left);
|
|
75884
|
+
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
75885
|
+
// Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
|
|
75886
|
+
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
75887
|
+
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
75888
|
+
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);
|
|
75889
|
+
}
|
|
75890
|
+
}
|
|
75210
75891
|
rightType = checkNonNullType(rightType, right);
|
|
75211
75892
|
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
75212
|
-
// The in operator requires the
|
|
75213
|
-
// and the right operand to be
|
|
75893
|
+
// The in operator requires the right operand to be
|
|
75214
75894
|
//
|
|
75215
75895
|
// 1. assignable to the non-primitive type,
|
|
75216
75896
|
// 2. an unconstrained type parameter,
|
|
@@ -75228,10 +75908,6 @@ var ts;
|
|
|
75228
75908
|
// unless *all* instantiations would result in an error.
|
|
75229
75909
|
//
|
|
75230
75910
|
// The result is always of the Boolean primitive type.
|
|
75231
|
-
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
75232
|
-
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
75233
|
-
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
|
75234
|
-
}
|
|
75235
75911
|
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
75236
75912
|
if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
75237
75913
|
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
@@ -75698,7 +76374,7 @@ var ts;
|
|
|
75698
76374
|
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
|
|
75699
76375
|
// Otherwise, the result is of type Any.
|
|
75700
76376
|
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
|
75701
|
-
resultType = leftType
|
|
76377
|
+
resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
|
|
75702
76378
|
}
|
|
75703
76379
|
// Symbols are not allowed at all in arithmetic expressions
|
|
75704
76380
|
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
|
|
@@ -76477,6 +77153,8 @@ var ts;
|
|
|
76477
77153
|
switch (kind) {
|
|
76478
77154
|
case 79 /* Identifier */:
|
|
76479
77155
|
return checkIdentifier(node, checkMode);
|
|
77156
|
+
case 80 /* PrivateIdentifier */:
|
|
77157
|
+
return checkPrivateIdentifierExpression(node);
|
|
76480
77158
|
case 108 /* ThisKeyword */:
|
|
76481
77159
|
return checkThisExpression(node);
|
|
76482
77160
|
case 106 /* SuperKeyword */:
|
|
@@ -77070,7 +77748,7 @@ var ts;
|
|
|
77070
77748
|
// - The containing class is a derived class.
|
|
77071
77749
|
// - The constructor declares parameter properties
|
|
77072
77750
|
// or the containing class declares instance member variables with initializers.
|
|
77073
|
-
var superCallShouldBeFirst = (compilerOptions
|
|
77751
|
+
var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
77074
77752
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
77075
77753
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
77076
77754
|
// Skip past any prologue directives to find the first statement
|
|
@@ -77176,7 +77854,7 @@ var ts;
|
|
|
77176
77854
|
}
|
|
77177
77855
|
function getTypeParametersForTypeReference(node) {
|
|
77178
77856
|
var type = getTypeFromTypeReference(node);
|
|
77179
|
-
if (type
|
|
77857
|
+
if (!isErrorType(type)) {
|
|
77180
77858
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
77181
77859
|
if (symbol) {
|
|
77182
77860
|
return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
|
|
@@ -77192,7 +77870,7 @@ var ts;
|
|
|
77192
77870
|
}
|
|
77193
77871
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
77194
77872
|
var type = getTypeFromTypeReference(node);
|
|
77195
|
-
if (type
|
|
77873
|
+
if (!isErrorType(type)) {
|
|
77196
77874
|
if (node.typeArguments && produceDiagnostics) {
|
|
77197
77875
|
var typeParameters = getTypeParametersForTypeReference(node);
|
|
77198
77876
|
if (typeParameters) {
|
|
@@ -78018,7 +78696,7 @@ var ts;
|
|
|
78018
78696
|
//
|
|
78019
78697
|
var returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78020
78698
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78021
|
-
if (returnType
|
|
78699
|
+
if (isErrorType(returnType)) {
|
|
78022
78700
|
return;
|
|
78023
78701
|
}
|
|
78024
78702
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
@@ -78032,7 +78710,7 @@ var ts;
|
|
|
78032
78710
|
else {
|
|
78033
78711
|
// Always mark the type node as referenced if it points to a value
|
|
78034
78712
|
markTypeNodeAsReferenced(returnTypeNode);
|
|
78035
|
-
if (returnType
|
|
78713
|
+
if (isErrorType(returnType)) {
|
|
78036
78714
|
return;
|
|
78037
78715
|
}
|
|
78038
78716
|
var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
|
|
@@ -78042,7 +78720,7 @@ var ts;
|
|
|
78042
78720
|
}
|
|
78043
78721
|
var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
|
|
78044
78722
|
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
|
|
78045
|
-
if (promiseConstructorType
|
|
78723
|
+
if (isErrorType(promiseConstructorType)) {
|
|
78046
78724
|
if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
|
|
78047
78725
|
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);
|
|
78048
78726
|
}
|
|
@@ -78814,7 +79492,7 @@ var ts;
|
|
|
78814
79492
|
}
|
|
78815
79493
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
78816
79494
|
// No need to check for require or exports for ES6 modules and later
|
|
78817
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
79495
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
78818
79496
|
return;
|
|
78819
79497
|
}
|
|
78820
79498
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -79094,7 +79772,7 @@ var ts;
|
|
|
79094
79772
|
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
|
79095
79773
|
// initializer is consistent with type associated with the node
|
|
79096
79774
|
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
|
79097
|
-
if (type
|
|
79775
|
+
if (!isErrorType(type) && !isErrorType(declarationType) &&
|
|
79098
79776
|
!isTypeIdenticalTo(type, declarationType) &&
|
|
79099
79777
|
!(symbol.flags & 67108864 /* Assignment */)) {
|
|
79100
79778
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
|
|
@@ -80375,8 +81053,8 @@ var ts;
|
|
|
80375
81053
|
* The name cannot be used as 'Object' of user defined types with special target.
|
|
80376
81054
|
*/
|
|
80377
81055
|
function checkClassNameCollisionWithObject(name) {
|
|
80378
|
-
if (languageVersion
|
|
80379
|
-
&& moduleKind < ts.ModuleKind.ES2015) {
|
|
81056
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object"
|
|
81057
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
80380
81058
|
error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494
|
|
80381
81059
|
}
|
|
80382
81060
|
}
|
|
@@ -80592,7 +81270,7 @@ var ts;
|
|
|
80592
81270
|
checkTypeReferenceNode(typeRefNode);
|
|
80593
81271
|
if (produceDiagnostics) {
|
|
80594
81272
|
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
80595
|
-
if (t
|
|
81273
|
+
if (!isErrorType(t)) {
|
|
80596
81274
|
if (isValidBaseType(t)) {
|
|
80597
81275
|
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
80598
81276
|
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
@@ -81546,8 +82224,8 @@ var ts;
|
|
|
81546
82224
|
checkAliasSymbol(node);
|
|
81547
82225
|
if (node.kind === 269 /* ImportSpecifier */ &&
|
|
81548
82226
|
ts.idText(node.propertyName || node.name) === "default" &&
|
|
81549
|
-
compilerOptions
|
|
81550
|
-
moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82227
|
+
ts.getESModuleInterop(compilerOptions) &&
|
|
82228
|
+
moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81551
82229
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81552
82230
|
}
|
|
81553
82231
|
}
|
|
@@ -81579,7 +82257,7 @@ var ts;
|
|
|
81579
82257
|
if (importClause.namedBindings) {
|
|
81580
82258
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
81581
82259
|
checkImportBinding(importClause.namedBindings);
|
|
81582
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions
|
|
82260
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
|
|
81583
82261
|
// import * as ns from "foo";
|
|
81584
82262
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81585
82263
|
}
|
|
@@ -81625,7 +82303,7 @@ var ts;
|
|
|
81625
82303
|
}
|
|
81626
82304
|
}
|
|
81627
82305
|
else {
|
|
81628
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
82306
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
81629
82307
|
// Import equals declaration is deprecated in es6 or above
|
|
81630
82308
|
grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
|
81631
82309
|
}
|
|
@@ -81641,7 +82319,7 @@ var ts;
|
|
|
81641
82319
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
81642
82320
|
}
|
|
81643
82321
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
81644
|
-
checkExternalEmitHelpers(node,
|
|
82322
|
+
checkExternalEmitHelpers(node, 4194304 /* CreateBinding */);
|
|
81645
82323
|
}
|
|
81646
82324
|
checkGrammarExportDeclaration(node);
|
|
81647
82325
|
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
|
|
@@ -81666,12 +82344,12 @@ var ts;
|
|
|
81666
82344
|
else if (node.exportClause) {
|
|
81667
82345
|
checkAliasSymbol(node.exportClause);
|
|
81668
82346
|
}
|
|
81669
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82347
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81670
82348
|
if (node.exportClause) {
|
|
81671
82349
|
// export * as ns from "foo";
|
|
81672
82350
|
// For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper.
|
|
81673
82351
|
// We only use the helper here when in esModuleInterop
|
|
81674
|
-
if (compilerOptions
|
|
82352
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
81675
82353
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81676
82354
|
}
|
|
81677
82355
|
}
|
|
@@ -81755,9 +82433,9 @@ var ts;
|
|
|
81755
82433
|
}
|
|
81756
82434
|
}
|
|
81757
82435
|
else {
|
|
81758
|
-
if (compilerOptions
|
|
82436
|
+
if (ts.getESModuleInterop(compilerOptions) &&
|
|
81759
82437
|
moduleKind !== ts.ModuleKind.System &&
|
|
81760
|
-
moduleKind < ts.ModuleKind.ES2015 &&
|
|
82438
|
+
(moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) &&
|
|
81761
82439
|
ts.idText(node.propertyName || node.name) === "default") {
|
|
81762
82440
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81763
82441
|
}
|
|
@@ -81816,7 +82494,7 @@ var ts;
|
|
|
81816
82494
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
81817
82495
|
}
|
|
81818
82496
|
if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
|
|
81819
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
82497
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
81820
82498
|
// export assignment is not supported in es6 modules
|
|
81821
82499
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
81822
82500
|
}
|
|
@@ -82610,6 +83288,9 @@ var ts;
|
|
|
82610
83288
|
}
|
|
82611
83289
|
return result;
|
|
82612
83290
|
}
|
|
83291
|
+
else if (ts.isPrivateIdentifier(name)) {
|
|
83292
|
+
return getSymbolForPrivateIdentifierExpression(name);
|
|
83293
|
+
}
|
|
82613
83294
|
else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) {
|
|
82614
83295
|
var links = getNodeLinks(name);
|
|
82615
83296
|
if (links.resolvedSymbol) {
|
|
@@ -82632,7 +83313,8 @@ var ts;
|
|
|
82632
83313
|
}
|
|
82633
83314
|
else if (isTypeReferenceIdentifier(name)) {
|
|
82634
83315
|
var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
|
|
82635
|
-
|
|
83316
|
+
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
|
|
83317
|
+
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
|
|
82636
83318
|
}
|
|
82637
83319
|
if (name.parent.kind === 176 /* TypePredicate */) {
|
|
82638
83320
|
return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
|
|
@@ -82859,7 +83541,7 @@ var ts;
|
|
|
82859
83541
|
var symbol = getSymbolAtLocation(node);
|
|
82860
83542
|
if (symbol) {
|
|
82861
83543
|
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
|
82862
|
-
return declaredType
|
|
83544
|
+
return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
|
|
82863
83545
|
}
|
|
82864
83546
|
}
|
|
82865
83547
|
if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
@@ -83357,7 +84039,7 @@ var ts;
|
|
|
83357
84039
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83358
84040
|
}
|
|
83359
84041
|
var type = getDeclaredTypeOfSymbol(typeSymbol);
|
|
83360
|
-
if (type
|
|
84042
|
+
if (isErrorType(type)) {
|
|
83361
84043
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83362
84044
|
}
|
|
83363
84045
|
else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
@@ -83869,7 +84551,7 @@ var ts;
|
|
|
83869
84551
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
83870
84552
|
if (helpersModule !== unknownSymbol) {
|
|
83871
84553
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
83872
|
-
for (var helper = 1 /* FirstEmitHelper */; helper <=
|
|
84554
|
+
for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) {
|
|
83873
84555
|
if (uncheckedHelpers & helper) {
|
|
83874
84556
|
var name = getHelperName(helper);
|
|
83875
84557
|
var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */);
|
|
@@ -83921,7 +84603,8 @@ var ts;
|
|
|
83921
84603
|
case 262144 /* MakeTemplateObject */: return "__makeTemplateObject";
|
|
83922
84604
|
case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet";
|
|
83923
84605
|
case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet";
|
|
83924
|
-
case 2097152 /*
|
|
84606
|
+
case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn";
|
|
84607
|
+
case 4194304 /* CreateBinding */: return "__createBinding";
|
|
83925
84608
|
default: return ts.Debug.fail("Unrecognized helper");
|
|
83926
84609
|
}
|
|
83927
84610
|
}
|
|
@@ -84353,6 +85036,11 @@ var ts;
|
|
|
84353
85036
|
if (!ts.isArrowFunction(node)) {
|
|
84354
85037
|
return false;
|
|
84355
85038
|
}
|
|
85039
|
+
if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
|
|
85040
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) {
|
|
85041
|
+
grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint);
|
|
85042
|
+
}
|
|
85043
|
+
}
|
|
84356
85044
|
var equalsGreaterThanToken = node.equalsGreaterThanToken;
|
|
84357
85045
|
var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
|
|
84358
85046
|
var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
|
|
@@ -84685,8 +85373,8 @@ var ts;
|
|
|
84685
85373
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
84686
85374
|
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));
|
|
84687
85375
|
}
|
|
84688
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
84689
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85376
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85377
|
+
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher));
|
|
84690
85378
|
}
|
|
84691
85379
|
}
|
|
84692
85380
|
}
|
|
@@ -85027,8 +85715,7 @@ var ts;
|
|
|
85027
85715
|
: ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
|
85028
85716
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
85029
85717
|
}
|
|
85030
|
-
|
|
85031
|
-
if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
|
|
85718
|
+
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
85032
85719
|
!(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
85033
85720
|
checkESModuleMarker(node.name);
|
|
85034
85721
|
}
|
|
@@ -85363,7 +86050,7 @@ var ts;
|
|
|
85363
86050
|
}
|
|
85364
86051
|
function checkGrammarImportCallExpression(node) {
|
|
85365
86052
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
85366
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
86053
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext);
|
|
85367
86054
|
}
|
|
85368
86055
|
if (node.typeArguments) {
|
|
85369
86056
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -90523,7 +91210,7 @@ var ts;
|
|
|
90523
91210
|
function transformSourceFile(node) {
|
|
90524
91211
|
var options = context.getCompilerOptions();
|
|
90525
91212
|
if (node.isDeclarationFile
|
|
90526
|
-
|| useDefineForClassFields && options
|
|
91213
|
+
|| useDefineForClassFields && ts.getEmitScriptTarget(options) === 99 /* ESNext */) {
|
|
90527
91214
|
return node;
|
|
90528
91215
|
}
|
|
90529
91216
|
var visited = ts.visitEachChild(node, visitor, context);
|
|
@@ -90611,14 +91298,37 @@ var ts;
|
|
|
90611
91298
|
}
|
|
90612
91299
|
/**
|
|
90613
91300
|
* If we visit a private name, this means it is an undeclared private name.
|
|
90614
|
-
* Replace it with an empty identifier to indicate a problem with the code
|
|
91301
|
+
* Replace it with an empty identifier to indicate a problem with the code,
|
|
91302
|
+
* unless we are in a statement position - otherwise this will not trigger
|
|
91303
|
+
* a SyntaxError.
|
|
90615
91304
|
*/
|
|
90616
91305
|
function visitPrivateIdentifier(node) {
|
|
90617
91306
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
90618
91307
|
return node;
|
|
90619
91308
|
}
|
|
91309
|
+
if (ts.isStatement(node.parent)) {
|
|
91310
|
+
return node;
|
|
91311
|
+
}
|
|
90620
91312
|
return ts.setOriginalNode(factory.createIdentifier(""), node);
|
|
90621
91313
|
}
|
|
91314
|
+
/**
|
|
91315
|
+
* Visits `#id in expr`
|
|
91316
|
+
*/
|
|
91317
|
+
function visitPrivateIdentifierInInExpression(node) {
|
|
91318
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
91319
|
+
return node;
|
|
91320
|
+
}
|
|
91321
|
+
var privId = node.left;
|
|
91322
|
+
ts.Debug.assertNode(privId, ts.isPrivateIdentifier);
|
|
91323
|
+
ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */);
|
|
91324
|
+
var info = accessPrivateIdentifier(privId);
|
|
91325
|
+
if (info) {
|
|
91326
|
+
var receiver = ts.visitNode(node.right, visitor, ts.isExpression);
|
|
91327
|
+
return ts.setOriginalNode(context.getEmitHelperFactory().createClassPrivateFieldInHelper(info.brandCheckIdentifier, receiver), node);
|
|
91328
|
+
}
|
|
91329
|
+
// Private name has not been declared. Subsequent transformers will handle this error
|
|
91330
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91331
|
+
}
|
|
90622
91332
|
/**
|
|
90623
91333
|
* Visits the members of a class that has fields.
|
|
90624
91334
|
*
|
|
@@ -91005,6 +91715,9 @@ var ts;
|
|
|
91005
91715
|
}
|
|
91006
91716
|
}
|
|
91007
91717
|
}
|
|
91718
|
+
if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
|
|
91719
|
+
return visitPrivateIdentifierInInExpression(node);
|
|
91720
|
+
}
|
|
91008
91721
|
return ts.visitEachChild(node, visitor, context);
|
|
91009
91722
|
}
|
|
91010
91723
|
function createPrivateIdentifierAssignment(info, receiver, right, operator) {
|
|
@@ -93899,7 +94612,7 @@ var ts;
|
|
|
93899
94612
|
// When there are no attributes, React wants "null"
|
|
93900
94613
|
}
|
|
93901
94614
|
else {
|
|
93902
|
-
var target = compilerOptions
|
|
94615
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
93903
94616
|
if (target && target >= 5 /* ES2018 */) {
|
|
93904
94617
|
objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
93905
94618
|
return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
|
|
@@ -94098,7 +94811,8 @@ var ts;
|
|
|
94098
94811
|
}
|
|
94099
94812
|
}
|
|
94100
94813
|
function visitJsxExpression(node) {
|
|
94101
|
-
|
|
94814
|
+
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
94815
|
+
return node.dotDotDotToken ? factory.createSpreadElement(expression) : expression;
|
|
94102
94816
|
}
|
|
94103
94817
|
}
|
|
94104
94818
|
ts.transformJsx = transformJsx;
|
|
@@ -100734,7 +101448,7 @@ var ts;
|
|
|
100734
101448
|
case 348 /* PartiallyEmittedExpression */:
|
|
100735
101449
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
100736
101450
|
case 207 /* CallExpression */:
|
|
100737
|
-
if (ts.isImportCall(node)) {
|
|
101451
|
+
if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
|
|
100738
101452
|
return visitImportCallExpression(node);
|
|
100739
101453
|
}
|
|
100740
101454
|
break;
|
|
@@ -100957,7 +101671,7 @@ var ts;
|
|
|
100957
101671
|
}
|
|
100958
101672
|
}
|
|
100959
101673
|
var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
|
100960
|
-
if (compilerOptions
|
|
101674
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
100961
101675
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
|
|
100962
101676
|
}
|
|
100963
101677
|
return promise;
|
|
@@ -100970,7 +101684,7 @@ var ts;
|
|
|
100970
101684
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
100971
101685
|
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
|
100972
101686
|
var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
|
100973
|
-
if (compilerOptions
|
|
101687
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
100974
101688
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
100975
101689
|
}
|
|
100976
101690
|
var func;
|
|
@@ -101000,7 +101714,7 @@ var ts;
|
|
|
101000
101714
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
101001
101715
|
}
|
|
101002
101716
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
101003
|
-
if (!compilerOptions
|
|
101717
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101004
101718
|
return innerExpr;
|
|
101005
101719
|
}
|
|
101006
101720
|
if (ts.getExportNeedsImportStarHelper(node)) {
|
|
@@ -101009,7 +101723,7 @@ var ts;
|
|
|
101009
101723
|
return innerExpr;
|
|
101010
101724
|
}
|
|
101011
101725
|
function getHelperExpressionForImport(node, innerExpr) {
|
|
101012
|
-
if (!compilerOptions
|
|
101726
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101013
101727
|
return innerExpr;
|
|
101014
101728
|
}
|
|
101015
101729
|
if (ts.getImportNeedsImportStarHelper(node)) {
|
|
@@ -101163,7 +101877,7 @@ var ts;
|
|
|
101163
101877
|
statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier));
|
|
101164
101878
|
}
|
|
101165
101879
|
else {
|
|
101166
|
-
var exportNeedsImportDefault = !!compilerOptions
|
|
101880
|
+
var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) &&
|
|
101167
101881
|
!(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) &&
|
|
101168
101882
|
ts.idText(specifier.propertyName || specifier.name) === "default";
|
|
101169
101883
|
var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
|
|
@@ -103332,7 +104046,10 @@ var ts;
|
|
|
103332
104046
|
(function (ts) {
|
|
103333
104047
|
function transformECMAScriptModule(context) {
|
|
103334
104048
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
|
|
104049
|
+
var host = context.getEmitHost();
|
|
104050
|
+
var resolver = context.getEmitResolver();
|
|
103335
104051
|
var compilerOptions = context.getCompilerOptions();
|
|
104052
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
103336
104053
|
var previousOnEmitNode = context.onEmitNode;
|
|
103337
104054
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
103338
104055
|
context.onEmitNode = onEmitNode;
|
|
@@ -103340,13 +104057,21 @@ var ts;
|
|
|
103340
104057
|
context.enableEmitNotification(303 /* SourceFile */);
|
|
103341
104058
|
context.enableSubstitution(79 /* Identifier */);
|
|
103342
104059
|
var helperNameSubstitutions;
|
|
104060
|
+
var currentSourceFile;
|
|
104061
|
+
var importRequireStatements;
|
|
103343
104062
|
return ts.chainBundle(context, transformSourceFile);
|
|
103344
104063
|
function transformSourceFile(node) {
|
|
103345
104064
|
if (node.isDeclarationFile) {
|
|
103346
104065
|
return node;
|
|
103347
104066
|
}
|
|
103348
104067
|
if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
|
|
104068
|
+
currentSourceFile = node;
|
|
104069
|
+
importRequireStatements = undefined;
|
|
103349
104070
|
var result = updateExternalModule(node);
|
|
104071
|
+
currentSourceFile = undefined;
|
|
104072
|
+
if (importRequireStatements) {
|
|
104073
|
+
result = factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(ts.insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements));
|
|
104074
|
+
}
|
|
103350
104075
|
if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
|
|
103351
104076
|
return result;
|
|
103352
104077
|
}
|
|
@@ -103370,8 +104095,10 @@ var ts;
|
|
|
103370
104095
|
function visitor(node) {
|
|
103371
104096
|
switch (node.kind) {
|
|
103372
104097
|
case 264 /* ImportEqualsDeclaration */:
|
|
103373
|
-
//
|
|
103374
|
-
|
|
104098
|
+
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
104099
|
+
// To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url`
|
|
104100
|
+
// is available, just because the output is reasonable for a node-like runtime.
|
|
104101
|
+
return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
|
|
103375
104102
|
case 270 /* ExportAssignment */:
|
|
103376
104103
|
return visitExportAssignment(node);
|
|
103377
104104
|
case 271 /* ExportDeclaration */:
|
|
@@ -103380,6 +104107,68 @@ var ts;
|
|
|
103380
104107
|
}
|
|
103381
104108
|
return node;
|
|
103382
104109
|
}
|
|
104110
|
+
/**
|
|
104111
|
+
* Creates a `require()` call to import an external module.
|
|
104112
|
+
*
|
|
104113
|
+
* @param importNode The declaration to import.
|
|
104114
|
+
*/
|
|
104115
|
+
function createRequireCall(importNode) {
|
|
104116
|
+
var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, ts.Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
|
|
104117
|
+
var args = [];
|
|
104118
|
+
if (moduleName) {
|
|
104119
|
+
args.push(moduleName);
|
|
104120
|
+
}
|
|
104121
|
+
if (!importRequireStatements) {
|
|
104122
|
+
var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104123
|
+
var importStatement = factory.createImportDeclaration(
|
|
104124
|
+
/*decorators*/ undefined,
|
|
104125
|
+
/*modifiers*/ undefined, factory.createImportClause(
|
|
104126
|
+
/*isTypeOnly*/ false,
|
|
104127
|
+
/*name*/ undefined, factory.createNamedImports([
|
|
104128
|
+
factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
|
|
104129
|
+
])), factory.createStringLiteral("module"));
|
|
104130
|
+
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104131
|
+
var requireStatement = factory.createVariableStatement(
|
|
104132
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104133
|
+
factory.createVariableDeclaration(requireHelperName,
|
|
104134
|
+
/*exclamationToken*/ undefined,
|
|
104135
|
+
/*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
|
|
104136
|
+
factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
|
|
104137
|
+
]))
|
|
104138
|
+
],
|
|
104139
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */));
|
|
104140
|
+
importRequireStatements = [importStatement, requireStatement];
|
|
104141
|
+
}
|
|
104142
|
+
var name = importRequireStatements[1].declarationList.declarations[0].name;
|
|
104143
|
+
ts.Debug.assertNode(name, ts.isIdentifier);
|
|
104144
|
+
return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args);
|
|
104145
|
+
}
|
|
104146
|
+
/**
|
|
104147
|
+
* Visits an ImportEqualsDeclaration node.
|
|
104148
|
+
*
|
|
104149
|
+
* @param node The node to visit.
|
|
104150
|
+
*/
|
|
104151
|
+
function visitImportEqualsDeclaration(node) {
|
|
104152
|
+
ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
|
|
104153
|
+
var statements;
|
|
104154
|
+
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(
|
|
104155
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104156
|
+
factory.createVariableDeclaration(factory.cloneNode(node.name),
|
|
104157
|
+
/*exclamationToken*/ undefined,
|
|
104158
|
+
/*type*/ undefined, createRequireCall(node))
|
|
104159
|
+
],
|
|
104160
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
|
|
104161
|
+
statements = appendExportsOfImportEqualsDeclaration(statements, node);
|
|
104162
|
+
return ts.singleOrMany(statements);
|
|
104163
|
+
}
|
|
104164
|
+
function appendExportsOfImportEqualsDeclaration(statements, node) {
|
|
104165
|
+
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
104166
|
+
statements = ts.append(statements, factory.createExportDeclaration(
|
|
104167
|
+
/*decorators*/ undefined,
|
|
104168
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104169
|
+
}
|
|
104170
|
+
return statements;
|
|
104171
|
+
}
|
|
103383
104172
|
function visitExportAssignment(node) {
|
|
103384
104173
|
// Elide `export=` as it is not legal with --module ES6
|
|
103385
104174
|
return node.isExportEquals ? undefined : node;
|
|
@@ -103457,6 +104246,78 @@ var ts;
|
|
|
103457
104246
|
}
|
|
103458
104247
|
ts.transformECMAScriptModule = transformECMAScriptModule;
|
|
103459
104248
|
})(ts || (ts = {}));
|
|
104249
|
+
/*@internal*/
|
|
104250
|
+
var ts;
|
|
104251
|
+
(function (ts) {
|
|
104252
|
+
function transformNodeModule(context) {
|
|
104253
|
+
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
104254
|
+
var previousOnEmitNode = context.onEmitNode;
|
|
104255
|
+
var esmTransform = ts.transformECMAScriptModule(context);
|
|
104256
|
+
var esmOnSubstituteNode = context.onSubstituteNode;
|
|
104257
|
+
var esmOnEmitNode = context.onEmitNode;
|
|
104258
|
+
context.onSubstituteNode = previousOnSubstituteNode;
|
|
104259
|
+
context.onEmitNode = previousOnEmitNode;
|
|
104260
|
+
var cjsTransform = ts.transformModule(context);
|
|
104261
|
+
var cjsOnSubstituteNode = context.onSubstituteNode;
|
|
104262
|
+
var cjsOnEmitNode = context.onEmitNode;
|
|
104263
|
+
context.onSubstituteNode = onSubstituteNode;
|
|
104264
|
+
context.onEmitNode = onEmitNode;
|
|
104265
|
+
context.enableSubstitution(303 /* SourceFile */);
|
|
104266
|
+
context.enableEmitNotification(303 /* SourceFile */);
|
|
104267
|
+
var currentSourceFile;
|
|
104268
|
+
return transformSourceFileOrBundle;
|
|
104269
|
+
function onSubstituteNode(hint, node) {
|
|
104270
|
+
if (ts.isSourceFile(node)) {
|
|
104271
|
+
currentSourceFile = node;
|
|
104272
|
+
// Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on
|
|
104273
|
+
// the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute
|
|
104274
|
+
// functions on source files safely, as that context only gets setup in a later pipeline phase!)
|
|
104275
|
+
return previousOnSubstituteNode(hint, node);
|
|
104276
|
+
}
|
|
104277
|
+
else {
|
|
104278
|
+
if (!currentSourceFile) {
|
|
104279
|
+
return previousOnSubstituteNode(hint, node);
|
|
104280
|
+
}
|
|
104281
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104282
|
+
return esmOnSubstituteNode(hint, node);
|
|
104283
|
+
}
|
|
104284
|
+
return cjsOnSubstituteNode(hint, node);
|
|
104285
|
+
}
|
|
104286
|
+
}
|
|
104287
|
+
function onEmitNode(hint, node, emitCallback) {
|
|
104288
|
+
if (ts.isSourceFile(node)) {
|
|
104289
|
+
currentSourceFile = node;
|
|
104290
|
+
}
|
|
104291
|
+
if (!currentSourceFile) {
|
|
104292
|
+
return previousOnEmitNode(hint, node, emitCallback);
|
|
104293
|
+
}
|
|
104294
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104295
|
+
return esmOnEmitNode(hint, node, emitCallback);
|
|
104296
|
+
}
|
|
104297
|
+
return cjsOnEmitNode(hint, node, emitCallback);
|
|
104298
|
+
}
|
|
104299
|
+
function getModuleTransformForFile(file) {
|
|
104300
|
+
return file.impliedNodeFormat === ts.ModuleKind.ESNext ? esmTransform : cjsTransform;
|
|
104301
|
+
}
|
|
104302
|
+
function transformSourceFile(node) {
|
|
104303
|
+
if (node.isDeclarationFile) {
|
|
104304
|
+
return node;
|
|
104305
|
+
}
|
|
104306
|
+
currentSourceFile = node;
|
|
104307
|
+
var result = getModuleTransformForFile(node)(node);
|
|
104308
|
+
currentSourceFile = undefined;
|
|
104309
|
+
ts.Debug.assert(ts.isSourceFile(result));
|
|
104310
|
+
return result;
|
|
104311
|
+
}
|
|
104312
|
+
function transformSourceFileOrBundle(node) {
|
|
104313
|
+
return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
|
|
104314
|
+
}
|
|
104315
|
+
function transformBundle(node) {
|
|
104316
|
+
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
|
|
104317
|
+
}
|
|
104318
|
+
}
|
|
104319
|
+
ts.transformNodeModule = transformNodeModule;
|
|
104320
|
+
})(ts || (ts = {}));
|
|
103460
104321
|
/* @internal */
|
|
103461
104322
|
var ts;
|
|
103462
104323
|
(function (ts) {
|
|
@@ -105278,6 +106139,9 @@ var ts;
|
|
|
105278
106139
|
return ts.transformECMAScriptModule;
|
|
105279
106140
|
case ts.ModuleKind.System:
|
|
105280
106141
|
return ts.transformSystemModule;
|
|
106142
|
+
case ts.ModuleKind.Node12:
|
|
106143
|
+
case ts.ModuleKind.NodeNext:
|
|
106144
|
+
return ts.transformNodeModule;
|
|
105281
106145
|
default:
|
|
105282
106146
|
return ts.transformModule;
|
|
105283
106147
|
}
|
|
@@ -105888,7 +106752,7 @@ var ts;
|
|
|
105888
106752
|
return getOutputPathsForBundle(options, forceDtsPaths);
|
|
105889
106753
|
}
|
|
105890
106754
|
else {
|
|
105891
|
-
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
|
|
106755
|
+
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options));
|
|
105892
106756
|
var isJsonFile = ts.isJsonSourceFile(sourceFile);
|
|
105893
106757
|
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
|
|
105894
106758
|
var isJsonEmittedToSameLocation = isJsonFile &&
|
|
@@ -105904,26 +106768,13 @@ var ts;
|
|
|
105904
106768
|
function getSourceMapFilePath(jsFilePath, options) {
|
|
105905
106769
|
return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
|
|
105906
106770
|
}
|
|
105907
|
-
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
|
|
105908
|
-
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
|
|
105909
|
-
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
|
|
105910
106771
|
/* @internal */
|
|
105911
|
-
function getOutputExtension(
|
|
105912
|
-
|
|
105913
|
-
|
|
105914
|
-
|
|
105915
|
-
|
|
105916
|
-
|
|
105917
|
-
if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) {
|
|
105918
|
-
return ".jsx" /* Jsx */;
|
|
105919
|
-
}
|
|
105920
|
-
}
|
|
105921
|
-
else if (sourceFile.languageVariant === 1 /* JSX */) {
|
|
105922
|
-
// TypeScript source file preserving JSX syntax
|
|
105923
|
-
return ".jsx" /* Jsx */;
|
|
105924
|
-
}
|
|
105925
|
-
}
|
|
105926
|
-
return ".js" /* Js */;
|
|
106772
|
+
function getOutputExtension(fileName, options) {
|
|
106773
|
+
return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ :
|
|
106774
|
+
options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ :
|
|
106775
|
+
ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ :
|
|
106776
|
+
ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ :
|
|
106777
|
+
".js" /* Js */;
|
|
105927
106778
|
}
|
|
105928
106779
|
ts.getOutputExtension = getOutputExtension;
|
|
105929
106780
|
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
|
|
@@ -105933,19 +106784,14 @@ var ts;
|
|
|
105933
106784
|
}
|
|
105934
106785
|
/* @internal */
|
|
105935
106786
|
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
105936
|
-
ts.
|
|
105937
|
-
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts" /* Dts */);
|
|
106787
|
+
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ts.getDeclarationEmitExtensionForPath(inputFileName));
|
|
105938
106788
|
}
|
|
105939
106789
|
ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
|
|
105940
106790
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
105941
106791
|
if (configFile.options.emitDeclarationOnly)
|
|
105942
106792
|
return undefined;
|
|
105943
106793
|
var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
105944
|
-
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory),
|
|
105945
|
-
".json" /* Json */ :
|
|
105946
|
-
configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ?
|
|
105947
|
-
".jsx" /* Jsx */ :
|
|
105948
|
-
".js" /* Js */);
|
|
106794
|
+
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options));
|
|
105949
106795
|
return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
|
|
105950
106796
|
outputFileName :
|
|
105951
106797
|
undefined;
|
|
@@ -106016,7 +106862,7 @@ var ts;
|
|
|
106016
106862
|
/*@internal*/
|
|
106017
106863
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
106018
106864
|
var options = _a.options, fileNames = _a.fileNames;
|
|
106019
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.
|
|
106865
|
+
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
|
|
106020
106866
|
}
|
|
106021
106867
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
106022
106868
|
/*@internal*/
|
|
@@ -107293,6 +108139,8 @@ var ts;
|
|
|
107293
108139
|
// Identifiers
|
|
107294
108140
|
case 79 /* Identifier */:
|
|
107295
108141
|
return emitIdentifier(node);
|
|
108142
|
+
case 80 /* PrivateIdentifier */:
|
|
108143
|
+
return emitPrivateIdentifier(node);
|
|
107296
108144
|
// Expressions
|
|
107297
108145
|
case 203 /* ArrayLiteralExpression */:
|
|
107298
108146
|
return emitArrayLiteralExpression(node);
|
|
@@ -111279,7 +112127,7 @@ var ts;
|
|
|
111279
112127
|
if (options.declarationDir)
|
|
111280
112128
|
return false;
|
|
111281
112129
|
}
|
|
111282
|
-
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.
|
|
112130
|
+
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensionsFlat)) {
|
|
111283
112131
|
return false;
|
|
111284
112132
|
}
|
|
111285
112133
|
// just check if sourceFile with the name exists
|
|
@@ -111891,6 +112739,56 @@ var ts;
|
|
|
111891
112739
|
return resolutions;
|
|
111892
112740
|
}
|
|
111893
112741
|
ts.loadWithLocalCache = loadWithLocalCache;
|
|
112742
|
+
;
|
|
112743
|
+
/* @internal */
|
|
112744
|
+
function getModeForResolutionAtIndex(file, index) {
|
|
112745
|
+
if (file.impliedNodeFormat === undefined)
|
|
112746
|
+
return undefined;
|
|
112747
|
+
// we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
|
|
112748
|
+
// so it's safe to use them even pre-bind
|
|
112749
|
+
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
|
112750
|
+
}
|
|
112751
|
+
ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex;
|
|
112752
|
+
/* @internal */
|
|
112753
|
+
function getModeForUsageLocation(file, usage) {
|
|
112754
|
+
var _a;
|
|
112755
|
+
if (file.impliedNodeFormat === undefined)
|
|
112756
|
+
return undefined;
|
|
112757
|
+
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
112758
|
+
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
|
112759
|
+
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112760
|
+
}
|
|
112761
|
+
// in esm files, import=require statements are cjs format, otherwise everything is esm
|
|
112762
|
+
// imports are only parent'd up to their containing declaration/expression, so access farther parents with care
|
|
112763
|
+
var exprParentParent = (_a = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _a === void 0 ? void 0 : _a.parent;
|
|
112764
|
+
return exprParentParent && ts.isImportEqualsDeclaration(exprParentParent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
|
|
112765
|
+
}
|
|
112766
|
+
ts.getModeForUsageLocation = getModeForUsageLocation;
|
|
112767
|
+
/* @internal */
|
|
112768
|
+
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
|
|
112769
|
+
if (names.length === 0) {
|
|
112770
|
+
return [];
|
|
112771
|
+
}
|
|
112772
|
+
var resolutions = [];
|
|
112773
|
+
var cache = new ts.Map();
|
|
112774
|
+
var i = 0;
|
|
112775
|
+
for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
|
|
112776
|
+
var name = names_3[_i];
|
|
112777
|
+
var result = void 0;
|
|
112778
|
+
var mode = getModeForResolutionAtIndex(containingFile, i);
|
|
112779
|
+
i++;
|
|
112780
|
+
var cacheKey = mode !== undefined ? mode + "|" + name : name;
|
|
112781
|
+
if (cache.has(cacheKey)) {
|
|
112782
|
+
result = cache.get(cacheKey);
|
|
112783
|
+
}
|
|
112784
|
+
else {
|
|
112785
|
+
cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
|
|
112786
|
+
}
|
|
112787
|
+
resolutions.push(result);
|
|
112788
|
+
}
|
|
112789
|
+
return resolutions;
|
|
112790
|
+
}
|
|
112791
|
+
ts.loadWithModeAwareCache = loadWithModeAwareCache;
|
|
111894
112792
|
/* @internal */
|
|
111895
112793
|
function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
|
|
111896
112794
|
return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
|
|
@@ -111949,7 +112847,7 @@ var ts;
|
|
|
111949
112847
|
switch (kind) {
|
|
111950
112848
|
case ts.FileIncludeKind.Import:
|
|
111951
112849
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
111952
|
-
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
112850
|
+
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
111953
112851
|
if (importLiteral.pos === -1)
|
|
111954
112852
|
return { file: file, packageId: packageId, text: importLiteral.text };
|
|
111955
112853
|
pos = ts.skipTrivia(file.text, importLiteral.pos);
|
|
@@ -111960,7 +112858,7 @@ var ts;
|
|
|
111960
112858
|
break;
|
|
111961
112859
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
111962
112860
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
111963
|
-
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName))) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
112861
|
+
packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), getModeForResolutionAtIndex(file, index))) === null || _g === void 0 ? void 0 : _g.packageId;
|
|
111964
112862
|
break;
|
|
111965
112863
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
111966
112864
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -112047,6 +112945,33 @@ var ts;
|
|
|
112047
112945
|
configFileParseResult.errors;
|
|
112048
112946
|
}
|
|
112049
112947
|
ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
|
|
112948
|
+
/**
|
|
112949
|
+
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
|
112950
|
+
* `options` parameter.
|
|
112951
|
+
*
|
|
112952
|
+
* @param fileName The normalized absolute path to check the format of (it need not exist on disk)
|
|
112953
|
+
* @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
|
|
112954
|
+
* @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
|
|
112955
|
+
* @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
|
|
112956
|
+
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
112957
|
+
*/
|
|
112958
|
+
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
112959
|
+
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
112960
|
+
case ts.ModuleResolutionKind.Node12:
|
|
112961
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
112962
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext :
|
|
112963
|
+
ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS :
|
|
112964
|
+
ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() :
|
|
112965
|
+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
|
112966
|
+
default:
|
|
112967
|
+
return undefined;
|
|
112968
|
+
}
|
|
112969
|
+
function lookupFromPackageJson() {
|
|
112970
|
+
var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
|
|
112971
|
+
return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112972
|
+
}
|
|
112973
|
+
}
|
|
112974
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
112050
112975
|
/**
|
|
112051
112976
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
112052
112977
|
*/
|
|
@@ -112067,7 +112992,7 @@ var ts;
|
|
|
112067
112992
|
};
|
|
112068
112993
|
}
|
|
112069
112994
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
112070
|
-
var _a, _b, _c;
|
|
112995
|
+
var _a, _b, _c, _d;
|
|
112071
112996
|
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
|
112072
112997
|
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
|
|
112073
112998
|
var oldProgram = createProgramOptions.oldProgram;
|
|
@@ -112109,7 +113034,7 @@ var ts;
|
|
|
112109
113034
|
var programDiagnostics = ts.createDiagnosticCollection();
|
|
112110
113035
|
var currentDirectory = host.getCurrentDirectory();
|
|
112111
113036
|
var supportedExtensions = ts.getSupportedExtensions(options);
|
|
112112
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
113037
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
112113
113038
|
// Map storing if there is emit blocking diagnostics for given input
|
|
112114
113039
|
var hasEmitBlockingDiagnostics = new ts.Map();
|
|
112115
113040
|
var _compilerOptionsObjectLiteralSyntax;
|
|
@@ -112118,7 +113043,7 @@ var ts;
|
|
|
112118
113043
|
var actualResolveModuleNamesWorker;
|
|
112119
113044
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
112120
113045
|
if (host.resolveModuleNames) {
|
|
112121
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames),
|
|
113046
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
|
|
112122
113047
|
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
|
112123
113048
|
if (!resolved || resolved.extension !== undefined) {
|
|
112124
113049
|
return resolved;
|
|
@@ -112127,11 +113052,12 @@ var ts;
|
|
|
112127
113052
|
withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
|
|
112128
113053
|
return withExtension;
|
|
112129
113054
|
}); };
|
|
113055
|
+
moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
112130
113056
|
}
|
|
112131
113057
|
else {
|
|
112132
113058
|
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
112133
|
-
var loader_1 = function (moduleName,
|
|
112134
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return
|
|
113059
|
+
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
|
|
113060
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
|
|
112135
113061
|
}
|
|
112136
113062
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
112137
113063
|
if (host.resolveTypeReferenceDirectives) {
|
|
@@ -112167,9 +113093,9 @@ var ts;
|
|
|
112167
113093
|
var projectReferenceRedirects;
|
|
112168
113094
|
var mapFromFileToProjectReferenceRedirects;
|
|
112169
113095
|
var mapFromToProjectReferenceRedirectSource;
|
|
112170
|
-
var useSourceOfProjectReferenceRedirect = !!((
|
|
113096
|
+
var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
|
|
112171
113097
|
!options.disableSourceOfProjectReferenceRedirect;
|
|
112172
|
-
var
|
|
113098
|
+
var _e = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
112173
113099
|
compilerHost: host,
|
|
112174
113100
|
getSymlinkCache: getSymlinkCache,
|
|
112175
113101
|
useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
|
|
@@ -112177,7 +113103,8 @@ var ts;
|
|
|
112177
113103
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
112178
113104
|
getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
|
|
112179
113105
|
forEachResolvedProjectReference: forEachResolvedProjectReference
|
|
112180
|
-
}), onProgramCreateComplete =
|
|
113106
|
+
}), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
|
|
113107
|
+
var readFile = host.readFile.bind(host);
|
|
112181
113108
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
112182
113109
|
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
112183
113110
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112236,7 +113163,7 @@ var ts;
|
|
|
112236
113163
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
112237
113164
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
112238
113165
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
112239
|
-
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (
|
|
113166
|
+
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
112240
113167
|
}
|
|
112241
113168
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
112242
113169
|
}
|
|
@@ -112352,9 +113279,10 @@ var ts;
|
|
|
112352
113279
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
112353
113280
|
emitBuildInfo: emitBuildInfo,
|
|
112354
113281
|
fileExists: fileExists,
|
|
113282
|
+
readFile: readFile,
|
|
112355
113283
|
directoryExists: directoryExists,
|
|
112356
113284
|
getSymlinkCache: getSymlinkCache,
|
|
112357
|
-
realpath: (
|
|
113285
|
+
realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
|
|
112358
113286
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
112359
113287
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
112360
113288
|
structureIsReused: structureIsReused,
|
|
@@ -112384,7 +113312,7 @@ var ts;
|
|
|
112384
113312
|
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
112385
113313
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
|
|
112386
113314
|
ts.performance.mark("beforeResolveModule");
|
|
112387
|
-
var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
|
|
113315
|
+
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
|
|
112388
113316
|
ts.performance.mark("afterResolveModule");
|
|
112389
113317
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
112390
113318
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112405,7 +113333,7 @@ var ts;
|
|
|
112405
113333
|
}
|
|
112406
113334
|
function getRedirectReferenceForResolution(file) {
|
|
112407
113335
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
112408
|
-
if (redirect || !ts.
|
|
113336
|
+
if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
|
|
112409
113337
|
return redirect;
|
|
112410
113338
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
112411
113339
|
// So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
|
|
@@ -112450,8 +113378,8 @@ var ts;
|
|
|
112450
113378
|
}
|
|
112451
113379
|
return ts.libs.length + 2;
|
|
112452
113380
|
}
|
|
112453
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
112454
|
-
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
|
|
113381
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
113382
|
+
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
112455
113383
|
}
|
|
112456
113384
|
function toPath(fileName) {
|
|
112457
113385
|
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
@@ -112493,9 +113421,11 @@ var ts;
|
|
|
112493
113421
|
// Since we assume the filesystem does not change during program creation,
|
|
112494
113422
|
// it is safe to reuse resolutions from the earlier call.
|
|
112495
113423
|
var result_14 = [];
|
|
113424
|
+
var i = 0;
|
|
112496
113425
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
112497
113426
|
var moduleName = moduleNames_1[_i];
|
|
112498
|
-
var resolvedModule = file.resolvedModules.get(moduleName);
|
|
113427
|
+
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113428
|
+
i++;
|
|
112499
113429
|
result_14.push(resolvedModule);
|
|
112500
113430
|
}
|
|
112501
113431
|
return result_14;
|
|
@@ -112523,7 +113453,7 @@ var ts;
|
|
|
112523
113453
|
var moduleName = moduleNames[i];
|
|
112524
113454
|
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
112525
113455
|
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
112526
|
-
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
|
|
113456
|
+
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
|
|
112527
113457
|
if (oldResolvedModule) {
|
|
112528
113458
|
if (ts.isTraceEnabled(options, host)) {
|
|
112529
113459
|
ts.trace(host, oldResolvedModule.packageId ?
|
|
@@ -112547,7 +113477,7 @@ var ts;
|
|
|
112547
113477
|
}
|
|
112548
113478
|
}
|
|
112549
113479
|
else {
|
|
112550
|
-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
|
|
113480
|
+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
|
|
112551
113481
|
}
|
|
112552
113482
|
if (resolvesToAmbientModuleInNonModifiedFile) {
|
|
112553
113483
|
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
|
@@ -112584,8 +113514,10 @@ var ts;
|
|
|
112584
113514
|
return result;
|
|
112585
113515
|
// If we change our policy of rechecking failed lookups on each program create,
|
|
112586
113516
|
// we should adjust the value returned here.
|
|
112587
|
-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
112588
|
-
|
|
113517
|
+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, index) {
|
|
113518
|
+
if (index >= ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.imports) + ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.moduleAugmentations))
|
|
113519
|
+
return false; // mode index out of bounds, don't reuse resolution
|
|
113520
|
+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index));
|
|
112589
113521
|
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
112590
113522
|
if (resolutionToFile && resolvedFile) {
|
|
112591
113523
|
// In the old program, we resolved to an ambient module that was in the same
|
|
@@ -112668,8 +113600,8 @@ var ts;
|
|
|
112668
113600
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
112669
113601
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
112670
113602
|
var newSourceFile = host.getSourceFileByPath
|
|
112671
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options
|
|
112672
|
-
: host.getSourceFile(oldSourceFile.fileName, options
|
|
113603
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
|
|
113604
|
+
: host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
|
|
112673
113605
|
if (!newSourceFile) {
|
|
112674
113606
|
return 0 /* Not */;
|
|
112675
113607
|
}
|
|
@@ -112776,10 +113708,10 @@ var ts;
|
|
|
112776
113708
|
var moduleNames = getModuleNames(newSourceFile);
|
|
112777
113709
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
112778
113710
|
// ensure that module resolution results are still correct
|
|
112779
|
-
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
|
|
113711
|
+
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
|
|
112780
113712
|
if (resolutionsChanged) {
|
|
112781
113713
|
structureIsReused = 1 /* SafeModules */;
|
|
112782
|
-
newSourceFile.resolvedModules = ts.
|
|
113714
|
+
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
112783
113715
|
}
|
|
112784
113716
|
else {
|
|
112785
113717
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
@@ -112788,10 +113720,10 @@ var ts;
|
|
|
112788
113720
|
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
112789
113721
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
112790
113722
|
// ensure that types resolutions are still correct
|
|
112791
|
-
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
|
|
113723
|
+
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
112792
113724
|
if (typeReferenceEesolutionsChanged) {
|
|
112793
113725
|
structureIsReused = 1 /* SafeModules */;
|
|
112794
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.
|
|
113726
|
+
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
112795
113727
|
}
|
|
112796
113728
|
else {
|
|
112797
113729
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
@@ -113422,6 +114354,7 @@ var ts;
|
|
|
113422
114354
|
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
|
|
113423
114355
|
// only through top - level external module names. Relative external module names are not permitted.
|
|
113424
114356
|
if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
|
|
114357
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113425
114358
|
imports = ts.append(imports, moduleNameExpr);
|
|
113426
114359
|
if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) {
|
|
113427
114360
|
usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:");
|
|
@@ -113430,6 +114363,7 @@ var ts;
|
|
|
113430
114363
|
}
|
|
113431
114364
|
else if (ts.isModuleDeclaration(node)) {
|
|
113432
114365
|
if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) {
|
|
114366
|
+
node.name.parent = node;
|
|
113433
114367
|
var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
|
|
113434
114368
|
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
|
113435
114369
|
// This will happen in two cases:
|
|
@@ -113465,13 +114399,16 @@ var ts;
|
|
|
113465
114399
|
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
|
113466
114400
|
var node = getNodeAtPosition(file, r.lastIndex);
|
|
113467
114401
|
if (isJavaScriptFile && ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
|
114402
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113468
114403
|
imports = ts.append(imports, node.arguments[0]);
|
|
113469
114404
|
}
|
|
113470
114405
|
// we have to check the argument list has length of at least 1. We will still have to process these even though we have parsing error.
|
|
113471
114406
|
else if (ts.isImportCall(node) && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) {
|
|
114407
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113472
114408
|
imports = ts.append(imports, node.arguments[0]);
|
|
113473
114409
|
}
|
|
113474
114410
|
else if (ts.isLiteralImportTypeNode(node)) {
|
|
114411
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113475
114412
|
imports = ts.append(imports, node.argument.literal);
|
|
113476
114413
|
}
|
|
113477
114414
|
}
|
|
@@ -113507,13 +114444,13 @@ var ts;
|
|
|
113507
114444
|
function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) {
|
|
113508
114445
|
if (ts.hasExtension(fileName)) {
|
|
113509
114446
|
var canonicalFileName_1 = host.getCanonicalFileName(fileName);
|
|
113510
|
-
if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
114447
|
+
if (!options.allowNonTsExtensions && !ts.forEach(ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
113511
114448
|
if (fail) {
|
|
113512
114449
|
if (ts.hasJSFileExtension(canonicalFileName_1)) {
|
|
113513
114450
|
fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
|
|
113514
114451
|
}
|
|
113515
114452
|
else {
|
|
113516
|
-
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114453
|
+
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113517
114454
|
}
|
|
113518
114455
|
}
|
|
113519
114456
|
return undefined;
|
|
@@ -113543,9 +114480,10 @@ var ts;
|
|
|
113543
114480
|
fail(ts.Diagnostics.File_0_not_found, fileName);
|
|
113544
114481
|
return undefined;
|
|
113545
114482
|
}
|
|
113546
|
-
|
|
114483
|
+
// Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts)
|
|
114484
|
+
var sourceFileWithAddedExtension = ts.forEach(supportedExtensions[0], function (extension) { return getSourceFile(fileName + extension); });
|
|
113547
114485
|
if (fail && !sourceFileWithAddedExtension)
|
|
113548
|
-
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114486
|
+
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113549
114487
|
return sourceFileWithAddedExtension;
|
|
113550
114488
|
}
|
|
113551
114489
|
}
|
|
@@ -113690,7 +114628,7 @@ var ts;
|
|
|
113690
114628
|
}
|
|
113691
114629
|
}
|
|
113692
114630
|
// We haven't looked for this file, do so now and cache result
|
|
113693
|
-
var file = host.getSourceFile(fileName, options
|
|
114631
|
+
var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
|
|
113694
114632
|
if (packageId) {
|
|
113695
114633
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
113696
114634
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
@@ -113718,6 +114656,10 @@ var ts;
|
|
|
113718
114656
|
file.path = path;
|
|
113719
114657
|
file.resolvedPath = toPath(fileName);
|
|
113720
114658
|
file.originalFileName = originalFileName;
|
|
114659
|
+
// It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
|
|
114660
|
+
// and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
|
|
114661
|
+
// to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
|
|
114662
|
+
file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
113721
114663
|
addFileIncludeReason(file, reason);
|
|
113722
114664
|
if (host.useCaseSensitiveFileNames()) {
|
|
113723
114665
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -113909,9 +114851,9 @@ var ts;
|
|
|
113909
114851
|
}
|
|
113910
114852
|
}
|
|
113911
114853
|
function pathForLibFile(libFileName) {
|
|
113912
|
-
// Support resolving to lib.dom.d.ts -> @typescript/dom, and
|
|
113913
|
-
// lib.dom.iterable.d.ts -> @typescript/dom/iterable
|
|
113914
|
-
// lib.es2015.symbol.wellknown.d.ts -> @typescript/es2015/symbol-wellknown
|
|
114854
|
+
// Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
|
|
114855
|
+
// lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
|
|
114856
|
+
// lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
|
|
113915
114857
|
var components = libFileName.split(".");
|
|
113916
114858
|
var path = components[1];
|
|
113917
114859
|
var i = 2;
|
|
@@ -113920,7 +114862,7 @@ var ts;
|
|
|
113920
114862
|
i++;
|
|
113921
114863
|
}
|
|
113922
114864
|
var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts");
|
|
113923
|
-
var localOverrideModuleResult = ts.resolveModuleName("@typescript/" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
114865
|
+
var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
113924
114866
|
if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) {
|
|
113925
114867
|
return localOverrideModuleResult.resolvedModule.resolvedFileName;
|
|
113926
114868
|
}
|
|
@@ -113961,7 +114903,7 @@ var ts;
|
|
|
113961
114903
|
var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options;
|
|
113962
114904
|
for (var index = 0; index < moduleNames.length; index++) {
|
|
113963
114905
|
var resolution = resolutions[index];
|
|
113964
|
-
ts.setResolvedModule(file, moduleNames[index], resolution);
|
|
114906
|
+
ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
|
|
113965
114907
|
if (!resolution) {
|
|
113966
114908
|
continue;
|
|
113967
114909
|
}
|
|
@@ -114184,7 +115126,7 @@ var ts;
|
|
|
114184
115126
|
if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
|
|
114185
115127
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
|
|
114186
115128
|
}
|
|
114187
|
-
var languageVersion = options
|
|
115129
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
114188
115130
|
var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
|
|
114189
115131
|
if (options.isolatedModules) {
|
|
114190
115132
|
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
|
|
@@ -114445,7 +115387,7 @@ var ts;
|
|
|
114445
115387
|
message = ts.Diagnostics.File_is_library_specified_here;
|
|
114446
115388
|
break;
|
|
114447
115389
|
}
|
|
114448
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
115390
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
114449
115391
|
configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
|
|
114450
115392
|
message = ts.Diagnostics.File_is_default_library_for_target_specified_here;
|
|
114451
115393
|
break;
|
|
@@ -114613,7 +115555,7 @@ var ts;
|
|
|
114613
115555
|
if (options.outDir) {
|
|
114614
115556
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
114615
115557
|
}
|
|
114616
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.
|
|
115558
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
|
|
114617
115559
|
// Otherwise just check if sourceFile with the name exists
|
|
114618
115560
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
114619
115561
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -115145,7 +116087,7 @@ var ts;
|
|
|
115145
116087
|
}
|
|
115146
116088
|
}
|
|
115147
116089
|
}
|
|
115148
|
-
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
|
|
116090
|
+
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
|
|
115149
116091
|
}
|
|
115150
116092
|
return {
|
|
115151
116093
|
fileInfos: fileInfos,
|
|
@@ -115239,7 +116181,7 @@ var ts;
|
|
|
115239
116181
|
/*forceDtsEmit*/ true);
|
|
115240
116182
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
115241
116183
|
if (firstDts_1) {
|
|
115242
|
-
ts.Debug.assert(ts.
|
|
116184
|
+
ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
|
|
115243
116185
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
115244
116186
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
115245
116187
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -115563,6 +116505,14 @@ var ts;
|
|
|
115563
116505
|
ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
|
|
115564
116506
|
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
|
|
115565
116507
|
}
|
|
116508
|
+
if (useOldState) {
|
|
116509
|
+
// Any time the interpretation of a source file changes, mark it as changed
|
|
116510
|
+
ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
|
|
116511
|
+
if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
|
|
116512
|
+
state.changedFilesSet.add(sourceFilePath);
|
|
116513
|
+
}
|
|
116514
|
+
});
|
|
116515
|
+
}
|
|
115566
116516
|
state.buildInfoEmitPending = !!state.changedFilesSet.size;
|
|
115567
116517
|
return state;
|
|
115568
116518
|
}
|
|
@@ -115959,13 +116909,13 @@ var ts;
|
|
|
115959
116909
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
115960
116910
|
return value.version === actualSignature ?
|
|
115961
116911
|
value.affectsGlobalScope ?
|
|
115962
|
-
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
|
|
116912
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
|
|
115963
116913
|
value.version :
|
|
115964
116914
|
actualSignature !== undefined ?
|
|
115965
116915
|
signature === undefined ?
|
|
115966
116916
|
value :
|
|
115967
|
-
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } :
|
|
115968
|
-
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
|
|
116917
|
+
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
116918
|
+
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
115969
116919
|
});
|
|
115970
116920
|
var referencedMap;
|
|
115971
116921
|
if (state.referencedMap) {
|
|
@@ -116385,10 +117335,10 @@ var ts;
|
|
|
116385
117335
|
}
|
|
116386
117336
|
function toBuilderStateFileInfo(fileInfo) {
|
|
116387
117337
|
return ts.isString(fileInfo) ?
|
|
116388
|
-
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
|
|
117338
|
+
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
|
|
116389
117339
|
ts.isString(fileInfo.signature) ?
|
|
116390
117340
|
fileInfo :
|
|
116391
|
-
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
|
|
117341
|
+
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
116392
117342
|
}
|
|
116393
117343
|
ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
|
|
116394
117344
|
function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
|
|
@@ -116726,14 +117676,14 @@ var ts;
|
|
|
116726
117676
|
}
|
|
116727
117677
|
function resolveNamesWithLocalCache(_a) {
|
|
116728
117678
|
var _b, _c, _d;
|
|
116729
|
-
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges;
|
|
117679
|
+
var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile;
|
|
116730
117680
|
var path = resolutionHost.toPath(containingFile);
|
|
116731
|
-
var resolutionsInFile = cache.get(path) || cache.set(path,
|
|
117681
|
+
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
116732
117682
|
var dirPath = ts.getDirectoryPath(path);
|
|
116733
117683
|
var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
116734
117684
|
var perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
116735
117685
|
if (!perDirectoryResolution) {
|
|
116736
|
-
perDirectoryResolution =
|
|
117686
|
+
perDirectoryResolution = ts.createModeAwareCache();
|
|
116737
117687
|
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
116738
117688
|
}
|
|
116739
117689
|
var resolvedModules = [];
|
|
@@ -116745,17 +117695,20 @@ var ts;
|
|
|
116745
117695
|
var unmatchedRedirects = oldRedirect ?
|
|
116746
117696
|
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
|
116747
117697
|
!!redirectedReference;
|
|
116748
|
-
var seenNamesInFile =
|
|
116749
|
-
|
|
116750
|
-
|
|
116751
|
-
var
|
|
117698
|
+
var seenNamesInFile = ts.createModeAwareCache();
|
|
117699
|
+
var i = 0;
|
|
117700
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
117701
|
+
var name = names_4[_i];
|
|
117702
|
+
var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
117703
|
+
i++;
|
|
117704
|
+
var resolution = resolutionsInFile.get(name, mode);
|
|
116752
117705
|
// Resolution is valid if it is present and not invalidated
|
|
116753
|
-
if (!seenNamesInFile.has(name) &&
|
|
117706
|
+
if (!seenNamesInFile.has(name, mode) &&
|
|
116754
117707
|
unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
116755
117708
|
// If the name is unresolved import that was invalidated, recalculate
|
|
116756
117709
|
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
116757
117710
|
var existingResolution = resolution;
|
|
116758
|
-
var resolutionInDirectory = perDirectoryResolution.get(name);
|
|
117711
|
+
var resolutionInDirectory = perDirectoryResolution.get(name, mode);
|
|
116759
117712
|
if (resolutionInDirectory) {
|
|
116760
117713
|
resolution = resolutionInDirectory;
|
|
116761
117714
|
var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
@@ -116775,10 +117728,10 @@ var ts;
|
|
|
116775
117728
|
}
|
|
116776
117729
|
}
|
|
116777
117730
|
else {
|
|
116778
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference);
|
|
116779
|
-
perDirectoryResolution.set(name, resolution);
|
|
117731
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
117732
|
+
perDirectoryResolution.set(name, mode, resolution);
|
|
116780
117733
|
}
|
|
116781
|
-
resolutionsInFile.set(name, resolution);
|
|
117734
|
+
resolutionsInFile.set(name, mode, resolution);
|
|
116782
117735
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
116783
117736
|
if (existingResolution) {
|
|
116784
117737
|
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
|
@@ -116791,7 +117744,7 @@ var ts;
|
|
|
116791
117744
|
}
|
|
116792
117745
|
else {
|
|
116793
117746
|
var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost;
|
|
116794
|
-
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) {
|
|
117747
|
+
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
116795
117748
|
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
116796
117749
|
ts.trace(host, loader === resolveModuleName ?
|
|
116797
117750
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
@@ -116807,14 +117760,14 @@ var ts;
|
|
|
116807
117760
|
}
|
|
116808
117761
|
}
|
|
116809
117762
|
ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
|
|
116810
|
-
seenNamesInFile.set(name, true);
|
|
117763
|
+
seenNamesInFile.set(name, mode, true);
|
|
116811
117764
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
116812
117765
|
}
|
|
116813
117766
|
// Stop watching and remove the unused name
|
|
116814
|
-
resolutionsInFile.forEach(function (resolution, name) {
|
|
116815
|
-
if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
|
|
117767
|
+
resolutionsInFile.forEach(function (resolution, name, mode) {
|
|
117768
|
+
if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
|
|
116816
117769
|
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
116817
|
-
resolutionsInFile.delete(name);
|
|
117770
|
+
resolutionsInFile.delete(name, mode);
|
|
116818
117771
|
}
|
|
116819
117772
|
});
|
|
116820
117773
|
return resolvedModules;
|
|
@@ -116848,7 +117801,7 @@ var ts;
|
|
|
116848
117801
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
116849
117802
|
});
|
|
116850
117803
|
}
|
|
116851
|
-
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
117804
|
+
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
116852
117805
|
return resolveNamesWithLocalCache({
|
|
116853
117806
|
names: moduleNames,
|
|
116854
117807
|
containingFile: containingFile,
|
|
@@ -116860,11 +117813,14 @@ var ts;
|
|
|
116860
117813
|
shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
|
|
116861
117814
|
reusedNames: reusedNames,
|
|
116862
117815
|
logChanges: logChangesWhenResolvingModule,
|
|
117816
|
+
containingSourceFile: containingSourceFile,
|
|
116863
117817
|
});
|
|
116864
117818
|
}
|
|
116865
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
117819
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
|
|
116866
117820
|
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
|
|
116867
|
-
|
|
117821
|
+
if (!cache)
|
|
117822
|
+
return undefined;
|
|
117823
|
+
return cache.get(moduleName, resolutionMode);
|
|
116868
117824
|
}
|
|
116869
117825
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
116870
117826
|
return ts.endsWith(dirPath, "/node_modules/@types");
|
|
@@ -117263,7 +118219,7 @@ var ts;
|
|
|
117263
118219
|
Ending[Ending["Index"] = 1] = "Index";
|
|
117264
118220
|
Ending[Ending["JsExtension"] = 2] = "JsExtension";
|
|
117265
118221
|
})(Ending || (Ending = {}));
|
|
117266
|
-
function getPreferences(_a, compilerOptions, importingSourceFile) {
|
|
118222
|
+
function getPreferences(host, _a, compilerOptions, importingSourceFile) {
|
|
117267
118223
|
var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
|
|
117268
118224
|
return {
|
|
117269
118225
|
relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ :
|
|
@@ -117277,21 +118233,39 @@ var ts;
|
|
|
117277
118233
|
case "minimal": return 0 /* Minimal */;
|
|
117278
118234
|
case "index": return 1 /* Index */;
|
|
117279
118235
|
case "js": return 2 /* JsExtension */;
|
|
117280
|
-
default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */
|
|
118236
|
+
default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */
|
|
117281
118237
|
: ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */;
|
|
117282
118238
|
}
|
|
117283
118239
|
}
|
|
117284
118240
|
}
|
|
117285
|
-
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
|
|
118241
|
+
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) {
|
|
117286
118242
|
return {
|
|
117287
118243
|
relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */,
|
|
117288
|
-
ending: ts.hasJSFileExtension(oldImportSpecifier) ?
|
|
118244
|
+
ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ?
|
|
117289
118245
|
2 /* JsExtension */ :
|
|
117290
118246
|
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */,
|
|
117291
118247
|
};
|
|
117292
118248
|
}
|
|
118249
|
+
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
118250
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
|
|
118251
|
+
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118252
|
+
return false;
|
|
118253
|
+
}
|
|
118254
|
+
return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
|
|
118255
|
+
}
|
|
118256
|
+
function getModuleResolutionHost(host) {
|
|
118257
|
+
var _a;
|
|
118258
|
+
return {
|
|
118259
|
+
fileExists: host.fileExists,
|
|
118260
|
+
readFile: ts.Debug.checkDefined(host.readFile),
|
|
118261
|
+
directoryExists: host.directoryExists,
|
|
118262
|
+
getCurrentDirectory: host.getCurrentDirectory,
|
|
118263
|
+
realpath: host.realpath,
|
|
118264
|
+
useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
|
|
118265
|
+
};
|
|
118266
|
+
}
|
|
117293
118267
|
function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
|
|
117294
|
-
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier), {});
|
|
118268
|
+
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
|
|
117295
118269
|
if (res === oldImportSpecifier)
|
|
117296
118270
|
return undefined;
|
|
117297
118271
|
return res;
|
|
@@ -117299,7 +118273,7 @@ var ts;
|
|
|
117299
118273
|
moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
|
|
117300
118274
|
// Note: importingSourceFile is just for usesJsExtensionOnImports
|
|
117301
118275
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
|
|
117302
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {});
|
|
118276
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
117303
118277
|
}
|
|
117304
118278
|
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
|
|
117305
118279
|
function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
|
|
@@ -117353,7 +118327,7 @@ var ts;
|
|
|
117353
118327
|
moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo;
|
|
117354
118328
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) {
|
|
117355
118329
|
var info = getInfo(importingSourceFile.path, host);
|
|
117356
|
-
var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
118330
|
+
var preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile);
|
|
117357
118331
|
var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) {
|
|
117358
118332
|
if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path)
|
|
117359
118333
|
return undefined;
|
|
@@ -117789,7 +118763,7 @@ var ts;
|
|
|
117789
118763
|
if (!host.fileExists)
|
|
117790
118764
|
return;
|
|
117791
118765
|
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
|
|
117792
|
-
var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]);
|
|
118766
|
+
var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]));
|
|
117793
118767
|
for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
|
|
117794
118768
|
var e = extensions_3[_i];
|
|
117795
118769
|
var fullPath = path + e;
|
|
@@ -117857,9 +118831,11 @@ var ts;
|
|
|
117857
118831
|
});
|
|
117858
118832
|
}
|
|
117859
118833
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
117860
|
-
if (ts.
|
|
118834
|
+
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
117861
118835
|
return fileName;
|
|
117862
118836
|
var noExtension = ts.removeFileExtension(fileName);
|
|
118837
|
+
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
118838
|
+
return noExtension + getJSExtensionForFile(fileName, options);
|
|
117863
118839
|
switch (ending) {
|
|
117864
118840
|
case 0 /* Minimal */:
|
|
117865
118841
|
return ts.removeSuffix(noExtension, "/index");
|
|
@@ -117887,6 +118863,14 @@ var ts;
|
|
|
117887
118863
|
case ".jsx" /* Jsx */:
|
|
117888
118864
|
case ".json" /* Json */:
|
|
117889
118865
|
return ext;
|
|
118866
|
+
case ".d.mts" /* Dmts */:
|
|
118867
|
+
case ".mts" /* Mts */:
|
|
118868
|
+
case ".mjs" /* Mjs */:
|
|
118869
|
+
return ".mjs" /* Mjs */;
|
|
118870
|
+
case ".d.cts" /* Dcts */:
|
|
118871
|
+
case ".cts" /* Cts */:
|
|
118872
|
+
case ".cjs" /* Cjs */:
|
|
118873
|
+
return ".cjs" /* Cjs */;
|
|
117890
118874
|
default:
|
|
117891
118875
|
return undefined;
|
|
117892
118876
|
}
|
|
@@ -118161,7 +119145,7 @@ var ts;
|
|
|
118161
119145
|
case ts.FileIncludeKind.LibFile:
|
|
118162
119146
|
if (reason.index !== undefined)
|
|
118163
119147
|
return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]);
|
|
118164
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
119148
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
118165
119149
|
return ts.chainDiagnosticMessages(
|
|
118166
119150
|
/*details*/ undefined, target ?
|
|
118167
119151
|
ts.Diagnostics.Default_library_for_target_0 :
|
|
@@ -118584,7 +119568,7 @@ var ts;
|
|
|
118584
119568
|
}
|
|
118585
119569
|
return host.resolveModuleNames.apply(host, args);
|
|
118586
119570
|
}) :
|
|
118587
|
-
(function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
|
|
119571
|
+
(function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
|
|
118588
119572
|
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
|
118589
119573
|
(function () {
|
|
118590
119574
|
var args = [];
|
|
@@ -119312,10 +120296,11 @@ var ts;
|
|
|
119312
120296
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
119313
120297
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
119314
120298
|
if (!compilerHost.resolveModuleNames) {
|
|
119315
|
-
var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
|
|
119316
|
-
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
|
|
119317
|
-
return ts.
|
|
120299
|
+
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
|
|
120300
|
+
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
120301
|
+
return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
|
|
119318
120302
|
};
|
|
120303
|
+
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
119319
120304
|
}
|
|
119320
120305
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
119321
120306
|
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|