typescript 4.5.0-dev.20210924 → 4.5.0-dev.20210928
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/de/diagnosticMessages.generated.json +17 -5
- package/lib/es/diagnosticMessages.generated.json +2 -1
- package/lib/fr/diagnosticMessages.generated.json +2 -1
- package/lib/it/diagnosticMessages.generated.json +17 -5
- package/lib/ja/diagnosticMessages.generated.json +2 -1
- package/lib/ko/diagnosticMessages.generated.json +17 -5
- package/lib/lib.dom.d.ts +669 -1896
- package/lib/lib.dom.iterable.d.ts +16 -48
- package/lib/lib.webworker.d.ts +183 -520
- package/lib/lib.webworker.iterable.d.ts +10 -30
- package/lib/pl/diagnosticMessages.generated.json +2 -1
- package/lib/pt-br/diagnosticMessages.generated.json +2 -1
- package/lib/ru/diagnosticMessages.generated.json +17 -5
- package/lib/tr/diagnosticMessages.generated.json +2 -1
- package/lib/tsc.js +1364 -426
- package/lib/tsserver.js +2027 -693
- package/lib/tsserverlibrary.d.ts +76 -23
- package/lib/tsserverlibrary.js +2027 -693
- package/lib/typescript.d.ts +74 -21
- package/lib/typescript.js +2022 -687
- package/lib/typescriptServices.d.ts +74 -21
- package/lib/typescriptServices.js +2022 -687
- package/lib/typingsInstaller.js +1544 -475
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +17 -5
- 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.20210928";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -4855,7 +4855,7 @@ var ts;
|
|
|
4855
4855
|
TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
|
|
4856
4856
|
// The following flags are used for different purposes during union and intersection type construction
|
|
4857
4857
|
/* @internal */
|
|
4858
|
-
TypeFlags[TypeFlags["
|
|
4858
|
+
TypeFlags[TypeFlags["IncludesMissingType"] = 262144] = "IncludesMissingType";
|
|
4859
4859
|
/* @internal */
|
|
4860
4860
|
TypeFlags[TypeFlags["IncludesNonWideningType"] = 4194304] = "IncludesNonWideningType";
|
|
4861
4861
|
/* @internal */
|
|
@@ -5101,6 +5101,12 @@ var ts;
|
|
|
5101
5101
|
(function (ModuleResolutionKind) {
|
|
5102
5102
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
5103
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";
|
|
5104
5110
|
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
|
|
5105
5111
|
var WatchFileKind;
|
|
5106
5112
|
(function (WatchFileKind) {
|
|
@@ -5138,6 +5144,9 @@ var ts;
|
|
|
5138
5144
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5139
5145
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5140
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";
|
|
5141
5150
|
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
|
|
5142
5151
|
var JsxEmit;
|
|
5143
5152
|
(function (JsxEmit) {
|
|
@@ -5337,6 +5346,12 @@ var ts;
|
|
|
5337
5346
|
Extension["Jsx"] = ".jsx";
|
|
5338
5347
|
Extension["Json"] = ".json";
|
|
5339
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";
|
|
5340
5355
|
})(Extension = ts.Extension || (ts.Extension = {}));
|
|
5341
5356
|
/* @internal */
|
|
5342
5357
|
var TransformFlags;
|
|
@@ -5483,9 +5498,10 @@ var ts;
|
|
|
5483
5498
|
ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 262144] = "MakeTemplateObject";
|
|
5484
5499
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 524288] = "ClassPrivateFieldGet";
|
|
5485
5500
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 1048576] = "ClassPrivateFieldSet";
|
|
5486
|
-
ExternalEmitHelpers[ExternalEmitHelpers["
|
|
5501
|
+
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldIn"] = 2097152] = "ClassPrivateFieldIn";
|
|
5502
|
+
ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 4194304] = "CreateBinding";
|
|
5487
5503
|
ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper";
|
|
5488
|
-
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] =
|
|
5504
|
+
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 4194304] = "LastEmitHelper";
|
|
5489
5505
|
// Helpers included by ES2015 for..of
|
|
5490
5506
|
ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes";
|
|
5491
5507
|
// Helpers included by ES2017 for..await..of
|
|
@@ -8044,7 +8060,7 @@ var ts;
|
|
|
8044
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."),
|
|
8045
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."),
|
|
8046
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."),
|
|
8047
|
-
|
|
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'."),
|
|
8048
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'."),
|
|
8049
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."),
|
|
8050
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."),
|
|
@@ -8062,7 +8078,7 @@ var ts;
|
|
|
8062
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."),
|
|
8063
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}')'?"),
|
|
8064
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."),
|
|
8065
|
-
|
|
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'."),
|
|
8066
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."),
|
|
8067
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."),
|
|
8068
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."),
|
|
@@ -8093,7 +8109,7 @@ var ts;
|
|
|
8093
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."),
|
|
8094
8110
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8095
8111
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8096
|
-
|
|
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."),
|
|
8097
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'."),
|
|
8098
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'."),
|
|
8099
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 `}`?"),
|
|
@@ -8145,7 +8161,7 @@ var ts;
|
|
|
8145
8161
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8146
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:"),
|
|
8147
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."),
|
|
8148
|
-
|
|
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."),
|
|
8149
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."),
|
|
8150
8166
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8151
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}'?"),
|
|
@@ -8162,12 +8178,17 @@ var ts;
|
|
|
8162
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."),
|
|
8163
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."),
|
|
8164
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."),
|
|
8165
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."),
|
|
8166
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."),
|
|
8167
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),
|
|
8168
8187
|
Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8169
8188
|
Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8170
8189
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8190
|
+
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8191
|
+
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8171
8192
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8172
8193
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8173
8194
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -8226,7 +8247,7 @@ var ts;
|
|
|
8226
8247
|
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."),
|
|
8227
8248
|
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."),
|
|
8228
8249
|
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."),
|
|
8229
|
-
|
|
8250
|
+
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'."),
|
|
8230
8251
|
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."),
|
|
8231
8252
|
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."),
|
|
8232
8253
|
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."),
|
|
@@ -9031,6 +9052,13 @@ var ts;
|
|
|
9031
9052
|
Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"),
|
|
9032
9053
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9033
9054
|
_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"),
|
|
9055
|
+
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."),
|
|
9056
|
+
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}'."),
|
|
9057
|
+
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."),
|
|
9058
|
+
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."),
|
|
9059
|
+
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."),
|
|
9060
|
+
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}'"),
|
|
9061
|
+
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}'."),
|
|
9034
9062
|
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
|
|
9035
9063
|
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."),
|
|
9036
9064
|
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}'."),
|
|
@@ -9290,6 +9318,8 @@ var ts;
|
|
|
9290
9318
|
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."),
|
|
9291
9319
|
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."),
|
|
9292
9320
|
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}';`"),
|
|
9321
|
+
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."),
|
|
9322
|
+
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."),
|
|
9293
9323
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9294
9324
|
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."),
|
|
9295
9325
|
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."),
|
|
@@ -11896,7 +11926,7 @@ var ts;
|
|
|
11896
11926
|
}
|
|
11897
11927
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
|
|
11898
11928
|
function getDefaultLibFileName(options) {
|
|
11899
|
-
switch (options
|
|
11929
|
+
switch (ts.getEmitScriptTarget(options)) {
|
|
11900
11930
|
case 99 /* ESNext */:
|
|
11901
11931
|
return "lib.esnext.full.d.ts";
|
|
11902
11932
|
case 8 /* ES2021 */:
|
|
@@ -12946,7 +12976,7 @@ var ts;
|
|
|
12946
12976
|
switch (node.kind) {
|
|
12947
12977
|
case 269 /* ImportSpecifier */:
|
|
12948
12978
|
case 274 /* ExportSpecifier */:
|
|
12949
|
-
return node.parent.parent.isTypeOnly;
|
|
12979
|
+
return node.isTypeOnly || node.parent.parent.isTypeOnly;
|
|
12950
12980
|
case 267 /* NamespaceImport */:
|
|
12951
12981
|
return node.parent.isTypeOnly;
|
|
12952
12982
|
case 266 /* ImportClause */:
|
|
@@ -13317,6 +13347,7 @@ var ts;
|
|
|
13317
13347
|
case 225 /* ClassExpression */:
|
|
13318
13348
|
case 212 /* FunctionExpression */:
|
|
13319
13349
|
case 79 /* Identifier */:
|
|
13350
|
+
case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
|
|
13320
13351
|
case 13 /* RegularExpressionLiteral */:
|
|
13321
13352
|
case 8 /* NumericLiteral */:
|
|
13322
13353
|
case 9 /* BigIntLiteral */:
|
|
@@ -13959,22 +13990,22 @@ var ts;
|
|
|
13959
13990
|
return node.end - node.pos;
|
|
13960
13991
|
}
|
|
13961
13992
|
ts.getFullWidth = getFullWidth;
|
|
13962
|
-
function getResolvedModule(sourceFile, moduleNameText) {
|
|
13963
|
-
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
|
|
13993
|
+
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
13994
|
+
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
|
|
13964
13995
|
}
|
|
13965
13996
|
ts.getResolvedModule = getResolvedModule;
|
|
13966
|
-
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
|
|
13997
|
+
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
13967
13998
|
if (!sourceFile.resolvedModules) {
|
|
13968
|
-
sourceFile.resolvedModules =
|
|
13999
|
+
sourceFile.resolvedModules = ts.createModeAwareCache();
|
|
13969
14000
|
}
|
|
13970
|
-
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
|
14001
|
+
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
13971
14002
|
}
|
|
13972
14003
|
ts.setResolvedModule = setResolvedModule;
|
|
13973
14004
|
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
13974
14005
|
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
13975
|
-
sourceFile.resolvedTypeReferenceDirectiveNames =
|
|
14006
|
+
sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
|
|
13976
14007
|
}
|
|
13977
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
|
14008
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
|
|
13978
14009
|
}
|
|
13979
14010
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
13980
14011
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
@@ -14006,11 +14037,11 @@ var ts;
|
|
|
14006
14037
|
&& oldResolution.originalPath === newResolution.originalPath;
|
|
14007
14038
|
}
|
|
14008
14039
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
14009
|
-
function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
|
|
14040
|
+
function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
|
|
14010
14041
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14011
14042
|
for (var i = 0; i < names.length; i++) {
|
|
14012
14043
|
var newResolution = newResolutions[i];
|
|
14013
|
-
var oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
|
14044
|
+
var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
|
|
14014
14045
|
var changed = oldResolution
|
|
14015
14046
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14016
14047
|
: newResolution;
|
|
@@ -14545,8 +14576,11 @@ var ts;
|
|
|
14545
14576
|
return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
|
|
14546
14577
|
}
|
|
14547
14578
|
ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
|
|
14579
|
+
function isCommonJSContainingModuleKind(kind) {
|
|
14580
|
+
return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext;
|
|
14581
|
+
}
|
|
14548
14582
|
function isEffectiveExternalModule(node, compilerOptions) {
|
|
14549
|
-
return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions)
|
|
14583
|
+
return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
|
14550
14584
|
}
|
|
14551
14585
|
ts.isEffectiveExternalModule = isEffectiveExternalModule;
|
|
14552
14586
|
/**
|
|
@@ -15664,6 +15698,8 @@ var ts;
|
|
|
15664
15698
|
node = node.parent;
|
|
15665
15699
|
}
|
|
15666
15700
|
return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
|
|
15701
|
+
case 80 /* PrivateIdentifier */:
|
|
15702
|
+
return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */;
|
|
15667
15703
|
case 79 /* Identifier */:
|
|
15668
15704
|
if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
|
|
15669
15705
|
return true;
|
|
@@ -17330,6 +17366,7 @@ var ts;
|
|
|
17330
17366
|
case 108 /* ThisKeyword */:
|
|
17331
17367
|
case 106 /* SuperKeyword */:
|
|
17332
17368
|
case 79 /* Identifier */:
|
|
17369
|
+
case 80 /* PrivateIdentifier */:
|
|
17333
17370
|
case 104 /* NullKeyword */:
|
|
17334
17371
|
case 110 /* TrueKeyword */:
|
|
17335
17372
|
case 95 /* FalseKeyword */:
|
|
@@ -17836,9 +17873,17 @@ var ts;
|
|
|
17836
17873
|
var path = outputDir
|
|
17837
17874
|
? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
|
|
17838
17875
|
: fileName;
|
|
17839
|
-
|
|
17876
|
+
var declarationExtension = getDeclarationEmitExtensionForPath(path);
|
|
17877
|
+
return removeFileExtension(path) + declarationExtension;
|
|
17840
17878
|
}
|
|
17841
17879
|
ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
|
|
17880
|
+
function getDeclarationEmitExtensionForPath(path) {
|
|
17881
|
+
return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ :
|
|
17882
|
+
ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ :
|
|
17883
|
+
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
|
|
17884
|
+
".d.ts" /* Dts */;
|
|
17885
|
+
}
|
|
17886
|
+
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
17842
17887
|
function outFile(options) {
|
|
17843
17888
|
return options.outFile || options.out;
|
|
17844
17889
|
}
|
|
@@ -18578,7 +18623,7 @@ var ts;
|
|
|
18578
18623
|
}
|
|
18579
18624
|
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
|
18580
18625
|
function tryExtractTSExtension(fileName) {
|
|
18581
|
-
return ts.find(
|
|
18626
|
+
return ts.find(supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
18582
18627
|
}
|
|
18583
18628
|
ts.tryExtractTSExtension = tryExtractTSExtension;
|
|
18584
18629
|
/**
|
|
@@ -19530,7 +19575,10 @@ var ts;
|
|
|
19530
19575
|
}
|
|
19531
19576
|
ts.getLanguageVariant = getLanguageVariant;
|
|
19532
19577
|
function getEmitScriptTarget(compilerOptions) {
|
|
19533
|
-
return compilerOptions.target ||
|
|
19578
|
+
return compilerOptions.target ||
|
|
19579
|
+
(compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
|
|
19580
|
+
(compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) ||
|
|
19581
|
+
0 /* ES3 */;
|
|
19534
19582
|
}
|
|
19535
19583
|
ts.getEmitScriptTarget = getEmitScriptTarget;
|
|
19536
19584
|
function getEmitModuleKind(compilerOptions) {
|
|
@@ -19542,7 +19590,20 @@ var ts;
|
|
|
19542
19590
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
19543
19591
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
19544
19592
|
if (moduleResolution === undefined) {
|
|
19545
|
-
|
|
19593
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19594
|
+
case ts.ModuleKind.CommonJS:
|
|
19595
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
19596
|
+
break;
|
|
19597
|
+
case ts.ModuleKind.Node12:
|
|
19598
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
19599
|
+
break;
|
|
19600
|
+
case ts.ModuleKind.NodeNext:
|
|
19601
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
19602
|
+
break;
|
|
19603
|
+
default:
|
|
19604
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
19605
|
+
break;
|
|
19606
|
+
}
|
|
19546
19607
|
}
|
|
19547
19608
|
return moduleResolution;
|
|
19548
19609
|
}
|
|
@@ -19572,11 +19633,23 @@ var ts;
|
|
|
19572
19633
|
return !!(getEmitDeclarations(options) && options.declarationMap);
|
|
19573
19634
|
}
|
|
19574
19635
|
ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
|
|
19636
|
+
function getESModuleInterop(compilerOptions) {
|
|
19637
|
+
if (compilerOptions.esModuleInterop !== undefined) {
|
|
19638
|
+
return compilerOptions.esModuleInterop;
|
|
19639
|
+
}
|
|
19640
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19641
|
+
case ts.ModuleKind.Node12:
|
|
19642
|
+
case ts.ModuleKind.NodeNext:
|
|
19643
|
+
return true;
|
|
19644
|
+
}
|
|
19645
|
+
return undefined;
|
|
19646
|
+
}
|
|
19647
|
+
ts.getESModuleInterop = getESModuleInterop;
|
|
19575
19648
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
19576
19649
|
var moduleKind = getEmitModuleKind(compilerOptions);
|
|
19577
19650
|
return compilerOptions.allowSyntheticDefaultImports !== undefined
|
|
19578
19651
|
? compilerOptions.allowSyntheticDefaultImports
|
|
19579
|
-
: compilerOptions
|
|
19652
|
+
: getESModuleInterop(compilerOptions) ||
|
|
19580
19653
|
moduleKind === ts.ModuleKind.System;
|
|
19581
19654
|
}
|
|
19582
19655
|
ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
|
|
@@ -19601,7 +19674,7 @@ var ts;
|
|
|
19601
19674
|
}
|
|
19602
19675
|
ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
|
|
19603
19676
|
function getUseDefineForClassFields(compilerOptions) {
|
|
19604
|
-
return compilerOptions.useDefineForClassFields === undefined ? compilerOptions
|
|
19677
|
+
return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ : compilerOptions.useDefineForClassFields;
|
|
19605
19678
|
}
|
|
19606
19679
|
ts.getUseDefineForClassFields = getUseDefineForClassFields;
|
|
19607
19680
|
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
|
|
@@ -19714,7 +19787,8 @@ var ts;
|
|
|
19714
19787
|
var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd));
|
|
19715
19788
|
var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd));
|
|
19716
19789
|
var isDirectory = false;
|
|
19717
|
-
while (
|
|
19790
|
+
while (aParts.length >= 2 && bParts.length >= 2 &&
|
|
19791
|
+
!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
|
|
19718
19792
|
!isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
|
|
19719
19793
|
getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
|
|
19720
19794
|
aParts.pop();
|
|
@@ -19726,7 +19800,7 @@ var ts;
|
|
|
19726
19800
|
// KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
|
|
19727
19801
|
// ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
|
|
19728
19802
|
function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
|
|
19729
|
-
return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
|
|
19803
|
+
return s !== undefined && (getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"));
|
|
19730
19804
|
}
|
|
19731
19805
|
function stripLeadingDirectorySeparator(s) {
|
|
19732
19806
|
return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
|
|
@@ -20041,51 +20115,54 @@ var ts;
|
|
|
20041
20115
|
}
|
|
20042
20116
|
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
20043
20117
|
/**
|
|
20044
|
-
*
|
|
20118
|
+
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
|
|
20045
20119
|
*/
|
|
20046
|
-
ts.supportedTSExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */];
|
|
20047
|
-
ts.
|
|
20120
|
+
ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
|
|
20121
|
+
ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions);
|
|
20122
|
+
var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false);
|
|
20048
20123
|
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
|
20049
|
-
|
|
20050
|
-
ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */];
|
|
20051
|
-
ts.
|
|
20052
|
-
var allSupportedExtensions =
|
|
20053
|
-
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(
|
|
20124
|
+
var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */];
|
|
20125
|
+
ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
|
|
20126
|
+
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20127
|
+
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 */]];
|
|
20128
|
+
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20054
20129
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20055
20130
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20056
20131
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
20057
20132
|
return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20058
20133
|
}
|
|
20059
|
-
var
|
|
20060
|
-
|
|
20134
|
+
var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20135
|
+
var flatBuiltins = ts.flatten(builtins);
|
|
20136
|
+
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);
|
|
20137
|
+
return extensions;
|
|
20061
20138
|
}
|
|
20062
20139
|
ts.getSupportedExtensions = getSupportedExtensions;
|
|
20063
|
-
function
|
|
20140
|
+
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
|
|
20064
20141
|
if (!options || !options.resolveJsonModule)
|
|
20065
20142
|
return supportedExtensions;
|
|
20066
20143
|
if (supportedExtensions === allSupportedExtensions)
|
|
20067
20144
|
return allSupportedExtensionsWithJson;
|
|
20068
20145
|
if (supportedExtensions === ts.supportedTSExtensions)
|
|
20069
|
-
return
|
|
20070
|
-
return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false);
|
|
20146
|
+
return supportedTSExtensionsWithJson;
|
|
20147
|
+
return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false);
|
|
20071
20148
|
}
|
|
20072
|
-
ts.
|
|
20149
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule;
|
|
20073
20150
|
function isJSLike(scriptKind) {
|
|
20074
20151
|
return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
|
|
20075
20152
|
}
|
|
20076
20153
|
function hasJSFileExtension(fileName) {
|
|
20077
|
-
return ts.some(ts.
|
|
20154
|
+
return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20078
20155
|
}
|
|
20079
20156
|
ts.hasJSFileExtension = hasJSFileExtension;
|
|
20080
20157
|
function hasTSFileExtension(fileName) {
|
|
20081
|
-
return ts.some(ts.
|
|
20158
|
+
return ts.some(ts.supportedTSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20082
20159
|
}
|
|
20083
20160
|
ts.hasTSFileExtension = hasTSFileExtension;
|
|
20084
20161
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
20085
20162
|
if (!fileName)
|
|
20086
20163
|
return false;
|
|
20087
20164
|
var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
|
|
20088
|
-
for (var _i = 0, _a =
|
|
20165
|
+
for (var _i = 0, _a = ts.flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)); _i < _a.length; _i++) {
|
|
20089
20166
|
var extension = _a[_i];
|
|
20090
20167
|
if (ts.fileExtensionIs(fileName, extension)) {
|
|
20091
20168
|
return true;
|
|
@@ -20102,57 +20179,7 @@ var ts;
|
|
|
20102
20179
|
return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
|
|
20103
20180
|
}
|
|
20104
20181
|
ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
|
|
20105
|
-
|
|
20106
|
-
* Extension boundaries by priority. Lower numbers indicate higher priorities, and are
|
|
20107
|
-
* aligned to the offset of the highest priority extension in the
|
|
20108
|
-
* allSupportedExtensions array.
|
|
20109
|
-
*/
|
|
20110
|
-
var ExtensionPriority;
|
|
20111
|
-
(function (ExtensionPriority) {
|
|
20112
|
-
ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles";
|
|
20113
|
-
ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles";
|
|
20114
|
-
ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest";
|
|
20115
|
-
ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest";
|
|
20116
|
-
})(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {}));
|
|
20117
|
-
function getExtensionPriority(path, supportedExtensions) {
|
|
20118
|
-
for (var i = supportedExtensions.length - 1; i >= 0; i--) {
|
|
20119
|
-
if (ts.fileExtensionIs(path, supportedExtensions[i])) {
|
|
20120
|
-
return adjustExtensionPriority(i, supportedExtensions);
|
|
20121
|
-
}
|
|
20122
|
-
}
|
|
20123
|
-
// If its not in the list of supported extensions, this is likely a
|
|
20124
|
-
// TypeScript file with a non-ts extension
|
|
20125
|
-
return 0 /* Highest */;
|
|
20126
|
-
}
|
|
20127
|
-
ts.getExtensionPriority = getExtensionPriority;
|
|
20128
|
-
/**
|
|
20129
|
-
* Adjusts an extension priority to be the highest priority within the same range.
|
|
20130
|
-
*/
|
|
20131
|
-
function adjustExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20132
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20133
|
-
return 0 /* TypeScriptFiles */;
|
|
20134
|
-
}
|
|
20135
|
-
else if (extensionPriority < supportedExtensions.length) {
|
|
20136
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20137
|
-
}
|
|
20138
|
-
else {
|
|
20139
|
-
return supportedExtensions.length;
|
|
20140
|
-
}
|
|
20141
|
-
}
|
|
20142
|
-
ts.adjustExtensionPriority = adjustExtensionPriority;
|
|
20143
|
-
/**
|
|
20144
|
-
* Gets the next lowest extension priority for a given priority.
|
|
20145
|
-
*/
|
|
20146
|
-
function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20147
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20148
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20149
|
-
}
|
|
20150
|
-
else {
|
|
20151
|
-
return supportedExtensions.length;
|
|
20152
|
-
}
|
|
20153
|
-
}
|
|
20154
|
-
ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
|
|
20155
|
-
var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
20182
|
+
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 */];
|
|
20156
20183
|
function removeFileExtension(path) {
|
|
20157
20184
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
|
|
20158
20185
|
var ext = extensionsToRemove_1[_i];
|
|
@@ -20205,7 +20232,7 @@ var ts;
|
|
|
20205
20232
|
ts.positionIsSynthesized = positionIsSynthesized;
|
|
20206
20233
|
/** True if an extension is one of the supported TypeScript extensions. */
|
|
20207
20234
|
function extensionIsTS(ext) {
|
|
20208
|
-
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */;
|
|
20235
|
+
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 */;
|
|
20209
20236
|
}
|
|
20210
20237
|
ts.extensionIsTS = extensionIsTS;
|
|
20211
20238
|
function resolutionExtensionIsTSOrJson(ext) {
|
|
@@ -20404,10 +20431,6 @@ var ts;
|
|
|
20404
20431
|
|| !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
|
|
20405
20432
|
}
|
|
20406
20433
|
ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
|
|
20407
|
-
function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
|
|
20408
|
-
return typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
20409
|
-
}
|
|
20410
|
-
ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
|
|
20411
20434
|
function isShorthandPropertyNameUseSite(useSite) {
|
|
20412
20435
|
return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite;
|
|
20413
20436
|
}
|
|
@@ -24429,8 +24452,9 @@ var ts;
|
|
|
24429
24452
|
: node;
|
|
24430
24453
|
}
|
|
24431
24454
|
// @api
|
|
24432
|
-
function createImportSpecifier(propertyName, name) {
|
|
24455
|
+
function createImportSpecifier(isTypeOnly, propertyName, name) {
|
|
24433
24456
|
var node = createBaseNode(269 /* ImportSpecifier */);
|
|
24457
|
+
node.isTypeOnly = isTypeOnly;
|
|
24434
24458
|
node.propertyName = propertyName;
|
|
24435
24459
|
node.name = name;
|
|
24436
24460
|
node.transformFlags |=
|
|
@@ -24440,10 +24464,11 @@ var ts;
|
|
|
24440
24464
|
return node;
|
|
24441
24465
|
}
|
|
24442
24466
|
// @api
|
|
24443
|
-
function updateImportSpecifier(node, propertyName, name) {
|
|
24444
|
-
return node.
|
|
24467
|
+
function updateImportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24468
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24469
|
+
|| node.propertyName !== propertyName
|
|
24445
24470
|
|| node.name !== name
|
|
24446
|
-
? update(createImportSpecifier(propertyName, name), node)
|
|
24471
|
+
? update(createImportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24447
24472
|
: node;
|
|
24448
24473
|
}
|
|
24449
24474
|
// @api
|
|
@@ -24504,8 +24529,9 @@ var ts;
|
|
|
24504
24529
|
: node;
|
|
24505
24530
|
}
|
|
24506
24531
|
// @api
|
|
24507
|
-
function createExportSpecifier(propertyName, name) {
|
|
24532
|
+
function createExportSpecifier(isTypeOnly, propertyName, name) {
|
|
24508
24533
|
var node = createBaseNode(274 /* ExportSpecifier */);
|
|
24534
|
+
node.isTypeOnly = isTypeOnly;
|
|
24509
24535
|
node.propertyName = asName(propertyName);
|
|
24510
24536
|
node.name = asName(name);
|
|
24511
24537
|
node.transformFlags |=
|
|
@@ -24515,10 +24541,11 @@ var ts;
|
|
|
24515
24541
|
return node;
|
|
24516
24542
|
}
|
|
24517
24543
|
// @api
|
|
24518
|
-
function updateExportSpecifier(node, propertyName, name) {
|
|
24519
|
-
return node.
|
|
24544
|
+
function updateExportSpecifier(node, isTypeOnly, propertyName, name) {
|
|
24545
|
+
return node.isTypeOnly !== isTypeOnly
|
|
24546
|
+
|| node.propertyName !== propertyName
|
|
24520
24547
|
|| node.name !== name
|
|
24521
|
-
? update(createExportSpecifier(propertyName, name), node)
|
|
24548
|
+
? update(createExportSpecifier(isTypeOnly, propertyName, name), node)
|
|
24522
24549
|
: node;
|
|
24523
24550
|
}
|
|
24524
24551
|
// @api
|
|
@@ -25366,6 +25393,7 @@ var ts;
|
|
|
25366
25393
|
node.transformFlags =
|
|
25367
25394
|
propagateChildrenFlags(node.statements) |
|
|
25368
25395
|
propagateChildFlags(node.endOfFileToken);
|
|
25396
|
+
node.impliedNodeFormat = source.impliedNodeFormat;
|
|
25369
25397
|
return node;
|
|
25370
25398
|
}
|
|
25371
25399
|
// @api
|
|
@@ -25625,7 +25653,7 @@ var ts;
|
|
|
25625
25653
|
/*decorators*/ undefined,
|
|
25626
25654
|
/*modifiers*/ undefined,
|
|
25627
25655
|
/*isTypeOnly*/ false, createNamedExports([
|
|
25628
|
-
createExportSpecifier(/*propertyName*/ undefined, exportName)
|
|
25656
|
+
createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, exportName)
|
|
25629
25657
|
]));
|
|
25630
25658
|
}
|
|
25631
25659
|
//
|
|
@@ -26939,6 +26967,7 @@ var ts;
|
|
|
26939
26967
|
// Class Fields Helpers
|
|
26940
26968
|
createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
|
|
26941
26969
|
createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
|
|
26970
|
+
createClassPrivateFieldInHelper: createClassPrivateFieldInHelper
|
|
26942
26971
|
};
|
|
26943
26972
|
/**
|
|
26944
26973
|
* Gets an identifier for the name of an *unscoped* emit helper.
|
|
@@ -26979,7 +27008,7 @@ var ts;
|
|
|
26979
27008
|
}
|
|
26980
27009
|
// ES2018 Helpers
|
|
26981
27010
|
function createAssignHelper(attributesSegments) {
|
|
26982
|
-
if (context.getCompilerOptions()
|
|
27011
|
+
if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
|
|
26983
27012
|
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
|
|
26984
27013
|
/*typeArguments*/ undefined, attributesSegments);
|
|
26985
27014
|
}
|
|
@@ -27149,6 +27178,10 @@ var ts;
|
|
|
27149
27178
|
}
|
|
27150
27179
|
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args);
|
|
27151
27180
|
}
|
|
27181
|
+
function createClassPrivateFieldInHelper(state, receiver) {
|
|
27182
|
+
context.requestEmitHelper(ts.classPrivateFieldInHelper);
|
|
27183
|
+
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]);
|
|
27184
|
+
}
|
|
27152
27185
|
}
|
|
27153
27186
|
ts.createEmitHelperFactory = createEmitHelperFactory;
|
|
27154
27187
|
/* @internal */
|
|
@@ -27506,6 +27539,24 @@ var ts;
|
|
|
27506
27539
|
scoped: false,
|
|
27507
27540
|
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 };"
|
|
27508
27541
|
};
|
|
27542
|
+
/**
|
|
27543
|
+
* Parameters:
|
|
27544
|
+
* @param state — One of the following:
|
|
27545
|
+
* - A WeakMap when the member is a private instance field.
|
|
27546
|
+
* - A WeakSet when the member is a private instance method or accessor.
|
|
27547
|
+
* - A function value that should be the undecorated class constructor when the member is a private static field, method, or accessor.
|
|
27548
|
+
* @param receiver — The object being checked if it has the private member.
|
|
27549
|
+
*
|
|
27550
|
+
* Usage:
|
|
27551
|
+
* This helper is used to transform `#field in expression` to
|
|
27552
|
+
* `__classPrivateFieldIn(<weakMap/weakSet/constructor>, expression)`
|
|
27553
|
+
*/
|
|
27554
|
+
ts.classPrivateFieldInHelper = {
|
|
27555
|
+
name: "typescript:classPrivateFieldIn",
|
|
27556
|
+
importName: "__classPrivateFieldIn",
|
|
27557
|
+
scoped: false,
|
|
27558
|
+
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 };"
|
|
27559
|
+
};
|
|
27509
27560
|
var allUnscopedEmitHelpers;
|
|
27510
27561
|
function getAllUnscopedEmitHelpers() {
|
|
27511
27562
|
return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
|
|
@@ -27530,6 +27581,7 @@ var ts;
|
|
|
27530
27581
|
ts.exportStarHelper,
|
|
27531
27582
|
ts.classPrivateFieldGetHelper,
|
|
27532
27583
|
ts.classPrivateFieldSetHelper,
|
|
27584
|
+
ts.classPrivateFieldInHelper,
|
|
27533
27585
|
ts.createBindingHelper,
|
|
27534
27586
|
ts.setModuleDefaultHelper
|
|
27535
27587
|
], function (helper) { return helper.name; }));
|
|
@@ -28849,7 +28901,7 @@ var ts;
|
|
|
28849
28901
|
if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
28850
28902
|
var namedBindings = void 0;
|
|
28851
28903
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28852
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
|
|
28904
|
+
if ((moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
28853
28905
|
// use named imports
|
|
28854
28906
|
var helpers = ts.getEmitHelpers(sourceFile);
|
|
28855
28907
|
if (helpers) {
|
|
@@ -28868,8 +28920,8 @@ var ts;
|
|
|
28868
28920
|
// Alias the imports if the names are used somewhere in the file.
|
|
28869
28921
|
// NOTE: We don't need to care about global import collisions as this is a module.
|
|
28870
28922
|
namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
|
|
28871
|
-
? nodeFactory.createImportSpecifier(/*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28872
|
-
: nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28923
|
+
? nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, nodeFactory.createIdentifier(name))
|
|
28924
|
+
: nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
|
|
28873
28925
|
var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
|
|
28874
28926
|
var emitNode = ts.getOrCreateEmitNode(parseNode);
|
|
28875
28927
|
emitNode.externalHelpers = true;
|
|
@@ -28901,9 +28953,9 @@ var ts;
|
|
|
28901
28953
|
return externalHelpersModuleName;
|
|
28902
28954
|
}
|
|
28903
28955
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28904
|
-
var create = (hasExportStarsToExportValues || (compilerOptions
|
|
28956
|
+
var create = (hasExportStarsToExportValues || (ts.getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
|
|
28905
28957
|
&& moduleKind !== ts.ModuleKind.System
|
|
28906
|
-
&& moduleKind < ts.ModuleKind.ES2015;
|
|
28958
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || node.impliedNodeFormat === ts.ModuleKind.CommonJS);
|
|
28907
28959
|
if (!create) {
|
|
28908
28960
|
var helpers = ts.getEmitHelpers(node);
|
|
28909
28961
|
if (helpers) {
|
|
@@ -34455,6 +34507,8 @@ var ts;
|
|
|
34455
34507
|
break;
|
|
34456
34508
|
case 15 /* TemplateHead */:
|
|
34457
34509
|
return parseTemplateExpression(/* isTaggedTemplate */ false);
|
|
34510
|
+
case 80 /* PrivateIdentifier */:
|
|
34511
|
+
return parsePrivateIdentifier();
|
|
34458
34512
|
}
|
|
34459
34513
|
return parseIdentifier(ts.Diagnostics.Expression_expected);
|
|
34460
34514
|
}
|
|
@@ -35994,27 +36048,74 @@ var ts;
|
|
|
35994
36048
|
var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
35995
36049
|
var checkIdentifierStart = scanner.getTokenPos();
|
|
35996
36050
|
var checkIdentifierEnd = scanner.getTextPos();
|
|
35997
|
-
var
|
|
36051
|
+
var isTypeOnly = false;
|
|
35998
36052
|
var propertyName;
|
|
35999
|
-
var
|
|
36000
|
-
|
|
36001
|
-
|
|
36002
|
-
|
|
36003
|
-
|
|
36004
|
-
|
|
36005
|
-
|
|
36006
|
-
|
|
36053
|
+
var canParseAsKeyword = true;
|
|
36054
|
+
var name = parseIdentifierName();
|
|
36055
|
+
if (name.escapedText === "type") {
|
|
36056
|
+
// If the first token of an import specifier is 'type', there are a lot of possibilities,
|
|
36057
|
+
// especially if we see 'as' afterwards:
|
|
36058
|
+
//
|
|
36059
|
+
// import { type } from "mod"; - isTypeOnly: false, name: type
|
|
36060
|
+
// import { type as } from "mod"; - isTypeOnly: true, name: as
|
|
36061
|
+
// import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type
|
|
36062
|
+
// import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as
|
|
36063
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36064
|
+
// { type as ...? }
|
|
36065
|
+
var firstAs = parseIdentifierName();
|
|
36066
|
+
if (token() === 127 /* AsKeyword */) {
|
|
36067
|
+
// { type as as ...? }
|
|
36068
|
+
var secondAs = parseIdentifierName();
|
|
36069
|
+
if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36070
|
+
// { type as as something }
|
|
36071
|
+
isTypeOnly = true;
|
|
36072
|
+
propertyName = firstAs;
|
|
36073
|
+
name = parseNameWithKeywordCheck();
|
|
36074
|
+
canParseAsKeyword = false;
|
|
36075
|
+
}
|
|
36076
|
+
else {
|
|
36077
|
+
// { type as as }
|
|
36078
|
+
propertyName = name;
|
|
36079
|
+
name = secondAs;
|
|
36080
|
+
canParseAsKeyword = false;
|
|
36081
|
+
}
|
|
36082
|
+
}
|
|
36083
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36084
|
+
// { type as something }
|
|
36085
|
+
propertyName = name;
|
|
36086
|
+
canParseAsKeyword = false;
|
|
36087
|
+
name = parseNameWithKeywordCheck();
|
|
36088
|
+
}
|
|
36089
|
+
else {
|
|
36090
|
+
// { type as }
|
|
36091
|
+
isTypeOnly = true;
|
|
36092
|
+
name = firstAs;
|
|
36093
|
+
}
|
|
36094
|
+
}
|
|
36095
|
+
else if (ts.tokenIsIdentifierOrKeyword(token())) {
|
|
36096
|
+
// { type something ...? }
|
|
36097
|
+
isTypeOnly = true;
|
|
36098
|
+
name = parseNameWithKeywordCheck();
|
|
36099
|
+
}
|
|
36007
36100
|
}
|
|
36008
|
-
|
|
36009
|
-
|
|
36101
|
+
if (canParseAsKeyword && token() === 127 /* AsKeyword */) {
|
|
36102
|
+
propertyName = name;
|
|
36103
|
+
parseExpected(127 /* AsKeyword */);
|
|
36104
|
+
name = parseNameWithKeywordCheck();
|
|
36010
36105
|
}
|
|
36011
36106
|
if (kind === 269 /* ImportSpecifier */ && checkIdentifierIsKeyword) {
|
|
36012
36107
|
parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
|
|
36013
36108
|
}
|
|
36014
36109
|
var node = kind === 269 /* ImportSpecifier */
|
|
36015
|
-
? factory.createImportSpecifier(propertyName, name)
|
|
36016
|
-
: factory.createExportSpecifier(propertyName, name);
|
|
36110
|
+
? factory.createImportSpecifier(isTypeOnly, propertyName, name)
|
|
36111
|
+
: factory.createExportSpecifier(isTypeOnly, propertyName, name);
|
|
36017
36112
|
return finishNode(node, pos);
|
|
36113
|
+
function parseNameWithKeywordCheck() {
|
|
36114
|
+
checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
|
|
36115
|
+
checkIdentifierStart = scanner.getTokenPos();
|
|
36116
|
+
checkIdentifierEnd = scanner.getTextPos();
|
|
36117
|
+
return parseIdentifierName();
|
|
36118
|
+
}
|
|
36018
36119
|
}
|
|
36019
36120
|
function parseNamespaceExport(pos) {
|
|
36020
36121
|
return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
|
|
@@ -37156,6 +37257,7 @@ var ts;
|
|
|
37156
37257
|
// are already correct.
|
|
37157
37258
|
var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
|
|
37158
37259
|
result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
|
|
37260
|
+
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
|
|
37159
37261
|
return result;
|
|
37160
37262
|
}
|
|
37161
37263
|
IncrementalParser.updateSourceFile = updateSourceFile;
|
|
@@ -37605,7 +37707,7 @@ var ts;
|
|
|
37605
37707
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
37606
37708
|
/** @internal */
|
|
37607
37709
|
function isDeclarationFileName(fileName) {
|
|
37608
|
-
return ts.
|
|
37710
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37609
37711
|
}
|
|
37610
37712
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37611
37713
|
/*@internal*/
|
|
@@ -38218,7 +38320,9 @@ var ts;
|
|
|
38218
38320
|
es6: ts.ModuleKind.ES2015,
|
|
38219
38321
|
es2015: ts.ModuleKind.ES2015,
|
|
38220
38322
|
es2020: ts.ModuleKind.ES2020,
|
|
38221
|
-
esnext: ts.ModuleKind.ESNext
|
|
38323
|
+
esnext: ts.ModuleKind.ESNext,
|
|
38324
|
+
node12: ts.ModuleKind.Node12,
|
|
38325
|
+
nodenext: ts.ModuleKind.NodeNext,
|
|
38222
38326
|
})),
|
|
38223
38327
|
affectsModuleResolution: true,
|
|
38224
38328
|
affectsEmit: true,
|
|
@@ -39123,7 +39227,7 @@ var ts;
|
|
|
39123
39227
|
/* @internal */
|
|
39124
39228
|
ts.defaultInitCompilerOptions = {
|
|
39125
39229
|
module: ts.ModuleKind.CommonJS,
|
|
39126
|
-
target:
|
|
39230
|
+
target: 3 /* ES2016 */,
|
|
39127
39231
|
strict: true,
|
|
39128
39232
|
esModuleInterop: true,
|
|
39129
39233
|
forceConsistentCasingInFileNames: true,
|
|
@@ -40644,7 +40748,7 @@ var ts;
|
|
|
40644
40748
|
// Rather than re-query this for each file and filespec, we query the supported extensions
|
|
40645
40749
|
// once and store it on the expansion context.
|
|
40646
40750
|
var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
|
|
40647
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
40751
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
40648
40752
|
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
|
40649
40753
|
// remove a literal file.
|
|
40650
40754
|
if (validatedFilesSpec) {
|
|
@@ -40692,7 +40796,7 @@ var ts;
|
|
|
40692
40796
|
wildcardFileMap.set(key, file);
|
|
40693
40797
|
}
|
|
40694
40798
|
};
|
|
40695
|
-
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40799
|
+
for (var _a = 0, _b = host.readDirectory(basePath, ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40696
40800
|
var file = _b[_a];
|
|
40697
40801
|
_loop_6(file);
|
|
40698
40802
|
}
|
|
@@ -40855,16 +40959,25 @@ var ts;
|
|
|
40855
40959
|
* extension priority.
|
|
40856
40960
|
*
|
|
40857
40961
|
* @param file The path to the file.
|
|
40858
|
-
* @param extensionPriority The priority of the extension.
|
|
40859
|
-
* @param context The expansion context.
|
|
40860
40962
|
*/
|
|
40861
40963
|
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
|
|
40862
|
-
var
|
|
40863
|
-
|
|
40864
|
-
|
|
40865
|
-
|
|
40866
|
-
|
|
40964
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40965
|
+
if (!extensionGroup) {
|
|
40966
|
+
return false;
|
|
40967
|
+
}
|
|
40968
|
+
for (var _i = 0, extensionGroup_1 = extensionGroup; _i < extensionGroup_1.length; _i++) {
|
|
40969
|
+
var ext = extensionGroup_1[_i];
|
|
40970
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
40971
|
+
return false;
|
|
40972
|
+
}
|
|
40973
|
+
var higherPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40867
40974
|
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
|
|
40975
|
+
if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) {
|
|
40976
|
+
// LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
|
|
40977
|
+
// files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
|
|
40978
|
+
// prevent breakage.
|
|
40979
|
+
continue;
|
|
40980
|
+
}
|
|
40868
40981
|
return true;
|
|
40869
40982
|
}
|
|
40870
40983
|
}
|
|
@@ -40875,15 +40988,18 @@ var ts;
|
|
|
40875
40988
|
* already been included.
|
|
40876
40989
|
*
|
|
40877
40990
|
* @param file The path to the file.
|
|
40878
|
-
* @param extensionPriority The priority of the extension.
|
|
40879
|
-
* @param context The expansion context.
|
|
40880
40991
|
*/
|
|
40881
40992
|
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
|
|
40882
|
-
var
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40993
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40994
|
+
if (!extensionGroup) {
|
|
40995
|
+
return;
|
|
40996
|
+
}
|
|
40997
|
+
for (var i = extensionGroup.length - 1; i >= 0; i--) {
|
|
40998
|
+
var ext = extensionGroup[i];
|
|
40999
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
41000
|
+
return;
|
|
41001
|
+
}
|
|
41002
|
+
var lowerPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40887
41003
|
wildcardFiles.delete(lowerPriorityPath);
|
|
40888
41004
|
}
|
|
40889
41005
|
}
|
|
@@ -41143,7 +41259,7 @@ var ts;
|
|
|
41143
41259
|
}
|
|
41144
41260
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41145
41261
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41146
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName);
|
|
41262
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
|
|
41147
41263
|
if (result) {
|
|
41148
41264
|
if (traceEnabled) {
|
|
41149
41265
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41177,7 +41293,7 @@ var ts;
|
|
|
41177
41293
|
}
|
|
41178
41294
|
}
|
|
41179
41295
|
var failedLookupLocations = [];
|
|
41180
|
-
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
41296
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
|
|
41181
41297
|
var resolved = primaryLookup();
|
|
41182
41298
|
var primary = true;
|
|
41183
41299
|
if (!resolved) {
|
|
@@ -41197,7 +41313,7 @@ var ts;
|
|
|
41197
41313
|
};
|
|
41198
41314
|
}
|
|
41199
41315
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41200
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result);
|
|
41316
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
|
|
41201
41317
|
if (traceEnabled)
|
|
41202
41318
|
traceResult(result);
|
|
41203
41319
|
return result;
|
|
@@ -41410,9 +41526,56 @@ var ts;
|
|
|
41410
41526
|
}
|
|
41411
41527
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
41412
41528
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
41413
|
-
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return
|
|
41529
|
+
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
|
|
41530
|
+
}
|
|
41531
|
+
}
|
|
41532
|
+
/* @internal */
|
|
41533
|
+
function createModeAwareCache() {
|
|
41534
|
+
var underlying = new ts.Map();
|
|
41535
|
+
var memoizedReverseKeys = new ts.Map();
|
|
41536
|
+
var cache = {
|
|
41537
|
+
get: function (specifier, mode) {
|
|
41538
|
+
return underlying.get(getUnderlyingCacheKey(specifier, mode));
|
|
41539
|
+
},
|
|
41540
|
+
set: function (specifier, mode, value) {
|
|
41541
|
+
underlying.set(getUnderlyingCacheKey(specifier, mode), value);
|
|
41542
|
+
return cache;
|
|
41543
|
+
},
|
|
41544
|
+
delete: function (specifier, mode) {
|
|
41545
|
+
underlying.delete(getUnderlyingCacheKey(specifier, mode));
|
|
41546
|
+
return cache;
|
|
41547
|
+
},
|
|
41548
|
+
has: function (specifier, mode) {
|
|
41549
|
+
return underlying.has(getUnderlyingCacheKey(specifier, mode));
|
|
41550
|
+
},
|
|
41551
|
+
forEach: function (cb) {
|
|
41552
|
+
return underlying.forEach(function (elem, key) {
|
|
41553
|
+
var _a = memoizedReverseKeys.get(key), specifier = _a[0], mode = _a[1];
|
|
41554
|
+
return cb(elem, specifier, mode);
|
|
41555
|
+
});
|
|
41556
|
+
},
|
|
41557
|
+
size: function () {
|
|
41558
|
+
return underlying.size;
|
|
41559
|
+
}
|
|
41560
|
+
};
|
|
41561
|
+
return cache;
|
|
41562
|
+
function getUnderlyingCacheKey(specifier, mode) {
|
|
41563
|
+
var result = mode === undefined ? specifier : mode + "|" + specifier;
|
|
41564
|
+
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
41565
|
+
return result;
|
|
41566
|
+
}
|
|
41567
|
+
}
|
|
41568
|
+
ts.createModeAwareCache = createModeAwareCache;
|
|
41569
|
+
/* @internal */
|
|
41570
|
+
function zipToModeAwareCache(file, keys, values) {
|
|
41571
|
+
ts.Debug.assert(keys.length === values.length);
|
|
41572
|
+
var map = createModeAwareCache();
|
|
41573
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
41574
|
+
map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
|
|
41414
41575
|
}
|
|
41576
|
+
return map;
|
|
41415
41577
|
}
|
|
41578
|
+
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
41416
41579
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
41417
41580
|
var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
41418
41581
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
@@ -41426,9 +41589,9 @@ var ts;
|
|
|
41426
41589
|
function update(options) {
|
|
41427
41590
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
41428
41591
|
}
|
|
41429
|
-
function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
|
|
41592
|
+
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
41430
41593
|
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
41431
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
|
|
41594
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
|
|
41432
41595
|
}
|
|
41433
41596
|
function createPerModuleNameCache() {
|
|
41434
41597
|
var directoryPathMap = new ts.Map();
|
|
@@ -41507,13 +41670,15 @@ var ts;
|
|
|
41507
41670
|
}
|
|
41508
41671
|
}
|
|
41509
41672
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
41510
|
-
function resolveModuleNameFromCache(moduleName, containingFile, cache) {
|
|
41673
|
+
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
41511
41674
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41512
41675
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
41513
|
-
|
|
41676
|
+
if (!perFolderCache)
|
|
41677
|
+
return undefined;
|
|
41678
|
+
return perFolderCache.get(moduleName, mode);
|
|
41514
41679
|
}
|
|
41515
41680
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
41516
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
41681
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41517
41682
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41518
41683
|
if (redirectedReference) {
|
|
41519
41684
|
compilerOptions = redirectedReference.commandLine.options;
|
|
@@ -41526,7 +41691,7 @@ var ts;
|
|
|
41526
41691
|
}
|
|
41527
41692
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41528
41693
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
|
|
41529
|
-
var result = perFolderCache && perFolderCache.get(moduleName);
|
|
41694
|
+
var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
41530
41695
|
if (result) {
|
|
41531
41696
|
if (traceEnabled) {
|
|
41532
41697
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -41535,7 +41700,20 @@ var ts;
|
|
|
41535
41700
|
else {
|
|
41536
41701
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
41537
41702
|
if (moduleResolution === undefined) {
|
|
41538
|
-
|
|
41703
|
+
switch (ts.getEmitModuleKind(compilerOptions)) {
|
|
41704
|
+
case ts.ModuleKind.CommonJS:
|
|
41705
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
41706
|
+
break;
|
|
41707
|
+
case ts.ModuleKind.Node12:
|
|
41708
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
41709
|
+
break;
|
|
41710
|
+
case ts.ModuleKind.NodeNext:
|
|
41711
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
41712
|
+
break;
|
|
41713
|
+
default:
|
|
41714
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
41715
|
+
break;
|
|
41716
|
+
}
|
|
41539
41717
|
if (traceEnabled) {
|
|
41540
41718
|
trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
41541
41719
|
}
|
|
@@ -41547,6 +41725,12 @@ var ts;
|
|
|
41547
41725
|
}
|
|
41548
41726
|
ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
|
|
41549
41727
|
switch (moduleResolution) {
|
|
41728
|
+
case ts.ModuleResolutionKind.Node12:
|
|
41729
|
+
result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41730
|
+
break;
|
|
41731
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
41732
|
+
result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41733
|
+
break;
|
|
41550
41734
|
case ts.ModuleResolutionKind.NodeJs:
|
|
41551
41735
|
result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
41552
41736
|
break;
|
|
@@ -41560,10 +41744,10 @@ var ts;
|
|
|
41560
41744
|
ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
|
|
41561
41745
|
ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
41562
41746
|
if (perFolderCache) {
|
|
41563
|
-
perFolderCache.set(moduleName, result);
|
|
41747
|
+
perFolderCache.set(moduleName, resolutionMode, result);
|
|
41564
41748
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41565
41749
|
// put result in per-module name cache
|
|
41566
|
-
cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
|
|
41750
|
+
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
41567
41751
|
}
|
|
41568
41752
|
}
|
|
41569
41753
|
}
|
|
@@ -41770,22 +41954,60 @@ var ts;
|
|
|
41770
41954
|
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
41771
41955
|
}
|
|
41772
41956
|
ts.tryResolveJSModule = tryResolveJSModule;
|
|
41957
|
+
/* @internal */
|
|
41958
|
+
var NodeResolutionFeatures;
|
|
41959
|
+
(function (NodeResolutionFeatures) {
|
|
41960
|
+
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
41961
|
+
// resolving `#local` names in your own package.json
|
|
41962
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Imports"] = 2] = "Imports";
|
|
41963
|
+
// resolving `your-own-name` from your own package.json
|
|
41964
|
+
NodeResolutionFeatures[NodeResolutionFeatures["SelfName"] = 4] = "SelfName";
|
|
41965
|
+
// respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
|
|
41966
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
|
|
41967
|
+
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
|
|
41968
|
+
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
41969
|
+
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
41970
|
+
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
41971
|
+
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
41972
|
+
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
41973
|
+
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41974
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41975
|
+
}
|
|
41976
|
+
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41977
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41978
|
+
}
|
|
41979
|
+
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41980
|
+
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41981
|
+
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
41982
|
+
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
41983
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
|
|
41984
|
+
}
|
|
41773
41985
|
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
41774
41986
|
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
41775
41987
|
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
41776
41988
|
var tsconfigExtensions = [Extensions.TSConfig];
|
|
41777
41989
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
41778
|
-
return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41990
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41779
41991
|
}
|
|
41780
41992
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
41781
|
-
return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41993
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41782
41994
|
}
|
|
41783
41995
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
41784
|
-
function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41996
|
+
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41785
41997
|
var _a, _b;
|
|
41786
41998
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41787
41999
|
var failedLookupLocations = [];
|
|
41788
|
-
|
|
42000
|
+
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42001
|
+
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
42002
|
+
var state = {
|
|
42003
|
+
compilerOptions: compilerOptions,
|
|
42004
|
+
host: host,
|
|
42005
|
+
traceEnabled: traceEnabled,
|
|
42006
|
+
failedLookupLocations: failedLookupLocations,
|
|
42007
|
+
packageJsonInfoCache: cache,
|
|
42008
|
+
features: features,
|
|
42009
|
+
conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
|
|
42010
|
+
};
|
|
41789
42011
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
41790
42012
|
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);
|
|
41791
42013
|
function tryResolve(extensions) {
|
|
@@ -41795,10 +42017,19 @@ var ts;
|
|
|
41795
42017
|
return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
41796
42018
|
}
|
|
41797
42019
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41798
|
-
|
|
41799
|
-
|
|
42020
|
+
var resolved_1;
|
|
42021
|
+
if (features & NodeResolutionFeatures.Imports && ts.startsWith(moduleName, "#")) {
|
|
42022
|
+
resolved_1 = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42023
|
+
}
|
|
42024
|
+
if (!resolved_1 && features & NodeResolutionFeatures.SelfName) {
|
|
42025
|
+
resolved_1 = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42026
|
+
}
|
|
42027
|
+
if (!resolved_1) {
|
|
42028
|
+
if (traceEnabled) {
|
|
42029
|
+
trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
|
|
42030
|
+
}
|
|
42031
|
+
resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41800
42032
|
}
|
|
41801
|
-
var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41802
42033
|
if (!resolved_1)
|
|
41803
42034
|
return undefined;
|
|
41804
42035
|
var resolvedValue = resolved_1.value;
|
|
@@ -41907,26 +42138,40 @@ var ts;
|
|
|
41907
42138
|
function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
|
|
41908
42139
|
if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
|
|
41909
42140
|
var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
|
|
41910
|
-
|
|
42141
|
+
var extension = extensionLess ? candidate.substring(extensionLess.length) : "";
|
|
42142
|
+
return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
|
|
41911
42143
|
}
|
|
41912
|
-
//
|
|
41913
|
-
|
|
41914
|
-
|
|
41915
|
-
|
|
42144
|
+
// esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
|
|
42145
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42146
|
+
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
|
|
42147
|
+
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
|
|
42148
|
+
if (resolvedByAddingExtension) {
|
|
42149
|
+
return resolvedByAddingExtension;
|
|
42150
|
+
}
|
|
41916
42151
|
}
|
|
42152
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
42153
|
+
}
|
|
42154
|
+
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
41917
42155
|
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
|
|
41918
42156
|
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
|
|
41919
|
-
if (ts.hasJSFileExtension(candidate)) {
|
|
42157
|
+
if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) {
|
|
41920
42158
|
var extensionless = ts.removeFileExtension(candidate);
|
|
42159
|
+
var extension = candidate.substring(extensionless.length);
|
|
41921
42160
|
if (state.traceEnabled) {
|
|
41922
|
-
var extension = candidate.substring(extensionless.length);
|
|
41923
42161
|
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
41924
42162
|
}
|
|
41925
|
-
return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
|
|
42163
|
+
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
42164
|
+
}
|
|
42165
|
+
}
|
|
42166
|
+
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
42167
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
|
|
42168
|
+
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
42169
|
+
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;
|
|
41926
42170
|
}
|
|
42171
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
41927
42172
|
}
|
|
41928
42173
|
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
|
|
41929
|
-
function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
|
|
42174
|
+
function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecordFailures, state) {
|
|
41930
42175
|
if (!onlyRecordFailures) {
|
|
41931
42176
|
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
|
41932
42177
|
var directory = ts.getDirectoryPath(candidate);
|
|
@@ -41936,11 +42181,51 @@ var ts;
|
|
|
41936
42181
|
}
|
|
41937
42182
|
switch (extensions) {
|
|
41938
42183
|
case Extensions.DtsOnly:
|
|
41939
|
-
|
|
42184
|
+
switch (originalExtension) {
|
|
42185
|
+
case ".mjs" /* Mjs */:
|
|
42186
|
+
case ".mts" /* Mts */:
|
|
42187
|
+
case ".d.mts" /* Dmts */:
|
|
42188
|
+
return tryExtension(".d.mts" /* Dmts */);
|
|
42189
|
+
case ".cjs" /* Cjs */:
|
|
42190
|
+
case ".cts" /* Cts */:
|
|
42191
|
+
case ".d.cts" /* Dcts */:
|
|
42192
|
+
return tryExtension(".d.cts" /* Dcts */);
|
|
42193
|
+
case ".json" /* Json */:
|
|
42194
|
+
candidate += ".json" /* Json */;
|
|
42195
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42196
|
+
default: return tryExtension(".d.ts" /* Dts */);
|
|
42197
|
+
}
|
|
41940
42198
|
case Extensions.TypeScript:
|
|
41941
|
-
|
|
42199
|
+
switch (originalExtension) {
|
|
42200
|
+
case ".mjs" /* Mjs */:
|
|
42201
|
+
case ".mts" /* Mts */:
|
|
42202
|
+
case ".d.mts" /* Dmts */:
|
|
42203
|
+
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
42204
|
+
case ".cjs" /* Cjs */:
|
|
42205
|
+
case ".cts" /* Cts */:
|
|
42206
|
+
case ".d.cts" /* Dcts */:
|
|
42207
|
+
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
42208
|
+
case ".json" /* Json */:
|
|
42209
|
+
candidate += ".json" /* Json */;
|
|
42210
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42211
|
+
default:
|
|
42212
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
42213
|
+
}
|
|
41942
42214
|
case Extensions.JavaScript:
|
|
41943
|
-
|
|
42215
|
+
switch (originalExtension) {
|
|
42216
|
+
case ".mjs" /* Mjs */:
|
|
42217
|
+
case ".mts" /* Mts */:
|
|
42218
|
+
case ".d.mts" /* Dmts */:
|
|
42219
|
+
return tryExtension(".mjs" /* Mjs */);
|
|
42220
|
+
case ".cjs" /* Cjs */:
|
|
42221
|
+
case ".cts" /* Cts */:
|
|
42222
|
+
case ".d.cts" /* Dcts */:
|
|
42223
|
+
return tryExtension(".cjs" /* Cjs */);
|
|
42224
|
+
case ".json" /* Json */:
|
|
42225
|
+
return tryExtension(".json" /* Json */);
|
|
42226
|
+
default:
|
|
42227
|
+
return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
|
|
42228
|
+
}
|
|
41944
42229
|
case Extensions.TSConfig:
|
|
41945
42230
|
case Extensions.Json:
|
|
41946
42231
|
return tryExtension(".json" /* Json */);
|
|
@@ -41975,6 +42260,33 @@ var ts;
|
|
|
41975
42260
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
41976
42261
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
41977
42262
|
}
|
|
42263
|
+
/**
|
|
42264
|
+
* A function for locating the package.json scope for a given path
|
|
42265
|
+
*/
|
|
42266
|
+
/*@internal*/
|
|
42267
|
+
function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
|
|
42268
|
+
var state = {
|
|
42269
|
+
host: host,
|
|
42270
|
+
compilerOptions: options,
|
|
42271
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42272
|
+
failedLookupLocations: [],
|
|
42273
|
+
packageJsonInfoCache: packageJsonInfoCache,
|
|
42274
|
+
features: 0,
|
|
42275
|
+
conditions: [],
|
|
42276
|
+
};
|
|
42277
|
+
var parts = ts.getPathComponents(fileName);
|
|
42278
|
+
parts.pop();
|
|
42279
|
+
while (parts.length > 0) {
|
|
42280
|
+
var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
|
42281
|
+
if (pkg) {
|
|
42282
|
+
return pkg;
|
|
42283
|
+
}
|
|
42284
|
+
parts.pop();
|
|
42285
|
+
}
|
|
42286
|
+
return undefined;
|
|
42287
|
+
}
|
|
42288
|
+
ts.getPackageScopeForPath = getPackageScopeForPath;
|
|
42289
|
+
/*@internal*/
|
|
41978
42290
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
41979
42291
|
var _a, _b, _c;
|
|
41980
42292
|
var host = state.host, traceEnabled = state.traceEnabled;
|
|
@@ -42017,6 +42329,7 @@ var ts;
|
|
|
42017
42329
|
state.failedLookupLocations.push(packageJsonPath);
|
|
42018
42330
|
}
|
|
42019
42331
|
}
|
|
42332
|
+
ts.getPackageJsonInfo = getPackageJsonInfo;
|
|
42020
42333
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
42021
42334
|
var packageFile;
|
|
42022
42335
|
if (jsonContent) {
|
|
@@ -42072,7 +42385,10 @@ var ts;
|
|
|
42072
42385
|
var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
|
|
42073
42386
|
if (packageFileResult)
|
|
42074
42387
|
return packageFileResult;
|
|
42075
|
-
|
|
42388
|
+
// esm mode resolutions don't do package `index` lookups
|
|
42389
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42390
|
+
return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
|
|
42391
|
+
}
|
|
42076
42392
|
}
|
|
42077
42393
|
/** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
|
|
42078
42394
|
function resolvedIfExtensionMatches(extensions, path) {
|
|
@@ -42102,6 +42418,226 @@ var ts;
|
|
|
42102
42418
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42103
42419
|
}
|
|
42104
42420
|
ts.parsePackageName = parsePackageName;
|
|
42421
|
+
function allKeysStartWithDot(obj) {
|
|
42422
|
+
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42423
|
+
}
|
|
42424
|
+
function noKeyStartsWithDot(obj) {
|
|
42425
|
+
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42426
|
+
}
|
|
42427
|
+
function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42428
|
+
var _a, _b;
|
|
42429
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42430
|
+
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));
|
|
42431
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42432
|
+
if (!scope || !scope.packageJsonContent.exports) {
|
|
42433
|
+
return undefined;
|
|
42434
|
+
}
|
|
42435
|
+
var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
|
|
42436
|
+
if (scope.packageJsonContent.name !== parts[1]) {
|
|
42437
|
+
return undefined;
|
|
42438
|
+
}
|
|
42439
|
+
var trailingParts = parts.slice(2);
|
|
42440
|
+
return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference);
|
|
42441
|
+
}
|
|
42442
|
+
function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
|
|
42443
|
+
if (!scope.packageJsonContent.exports) {
|
|
42444
|
+
return undefined;
|
|
42445
|
+
}
|
|
42446
|
+
if (subpath === ".") {
|
|
42447
|
+
var mainExport = void 0;
|
|
42448
|
+
if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports))) {
|
|
42449
|
+
mainExport = scope.packageJsonContent.exports;
|
|
42450
|
+
}
|
|
42451
|
+
else if (ts.hasProperty(scope.packageJsonContent.exports, ".")) {
|
|
42452
|
+
mainExport = scope.packageJsonContent.exports["."];
|
|
42453
|
+
}
|
|
42454
|
+
if (mainExport) {
|
|
42455
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
42456
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
42457
|
+
}
|
|
42458
|
+
}
|
|
42459
|
+
else if (allKeysStartWithDot(scope.packageJsonContent.exports)) {
|
|
42460
|
+
if (typeof scope.packageJsonContent.exports !== "object") {
|
|
42461
|
+
if (state.traceEnabled) {
|
|
42462
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42463
|
+
}
|
|
42464
|
+
return toSearchResult(/*value*/ undefined);
|
|
42465
|
+
}
|
|
42466
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false);
|
|
42467
|
+
if (result) {
|
|
42468
|
+
return result;
|
|
42469
|
+
}
|
|
42470
|
+
}
|
|
42471
|
+
if (state.traceEnabled) {
|
|
42472
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42473
|
+
}
|
|
42474
|
+
return toSearchResult(/*value*/ undefined);
|
|
42475
|
+
}
|
|
42476
|
+
function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42477
|
+
var _a, _b;
|
|
42478
|
+
if (moduleName === "#" || ts.startsWith(moduleName, "#/")) {
|
|
42479
|
+
if (state.traceEnabled) {
|
|
42480
|
+
trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
|
|
42481
|
+
}
|
|
42482
|
+
return toSearchResult(/*value*/ undefined);
|
|
42483
|
+
}
|
|
42484
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42485
|
+
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));
|
|
42486
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42487
|
+
if (!scope) {
|
|
42488
|
+
if (state.traceEnabled) {
|
|
42489
|
+
trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
|
|
42490
|
+
}
|
|
42491
|
+
return toSearchResult(/*value*/ undefined);
|
|
42492
|
+
}
|
|
42493
|
+
if (!scope.packageJsonContent.imports) {
|
|
42494
|
+
if (state.traceEnabled) {
|
|
42495
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
|
|
42496
|
+
}
|
|
42497
|
+
return toSearchResult(/*value*/ undefined);
|
|
42498
|
+
}
|
|
42499
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
|
|
42500
|
+
if (result) {
|
|
42501
|
+
return result;
|
|
42502
|
+
}
|
|
42503
|
+
if (state.traceEnabled) {
|
|
42504
|
+
trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
|
|
42505
|
+
}
|
|
42506
|
+
return toSearchResult(/*value*/ undefined);
|
|
42507
|
+
}
|
|
42508
|
+
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
42509
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
42510
|
+
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
42511
|
+
var target = lookupTable[moduleName];
|
|
42512
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
42513
|
+
}
|
|
42514
|
+
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; });
|
|
42515
|
+
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
42516
|
+
var potentialTarget = expandingKeys_1[_i];
|
|
42517
|
+
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
42518
|
+
var target = lookupTable[potentialTarget];
|
|
42519
|
+
var starPos = potentialTarget.indexOf("*");
|
|
42520
|
+
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
42521
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42522
|
+
}
|
|
42523
|
+
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
42524
|
+
var target = lookupTable[potentialTarget];
|
|
42525
|
+
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
42526
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42527
|
+
}
|
|
42528
|
+
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
42529
|
+
var target = lookupTable[potentialTarget];
|
|
42530
|
+
var subpath = moduleName.substring(potentialTarget.length);
|
|
42531
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
42532
|
+
}
|
|
42533
|
+
}
|
|
42534
|
+
function matchesPatternWithTrailer(target, name) {
|
|
42535
|
+
if (ts.endsWith(target, "*"))
|
|
42536
|
+
return false; // handled by next case in loop
|
|
42537
|
+
var starPos = target.indexOf("*");
|
|
42538
|
+
if (starPos === -1)
|
|
42539
|
+
return false; // handled by last case in loop
|
|
42540
|
+
return ts.startsWith(name, target.substring(0, starPos)) && ts.endsWith(name, target.substring(starPos + 1));
|
|
42541
|
+
}
|
|
42542
|
+
}
|
|
42543
|
+
/**
|
|
42544
|
+
* Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
|
|
42545
|
+
*/
|
|
42546
|
+
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
42547
|
+
return loadModuleFromTargetImportOrExport;
|
|
42548
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
42549
|
+
var _a, _b;
|
|
42550
|
+
if (typeof target === "string") {
|
|
42551
|
+
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
42552
|
+
if (state.traceEnabled) {
|
|
42553
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42554
|
+
}
|
|
42555
|
+
return toSearchResult(/*value*/ undefined);
|
|
42556
|
+
}
|
|
42557
|
+
if (!ts.startsWith(target, "./")) {
|
|
42558
|
+
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
42559
|
+
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
42560
|
+
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
42561
|
+
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
42562
|
+
}
|
|
42563
|
+
if (state.traceEnabled) {
|
|
42564
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42565
|
+
}
|
|
42566
|
+
return toSearchResult(/*value*/ undefined);
|
|
42567
|
+
}
|
|
42568
|
+
var parts = ts.pathIsRelative(target) ? ts.getPathComponents(target).slice(1) : ts.getPathComponents(target);
|
|
42569
|
+
var partsAfterFirst = parts.slice(1);
|
|
42570
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42571
|
+
if (state.traceEnabled) {
|
|
42572
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42573
|
+
}
|
|
42574
|
+
return toSearchResult(/*value*/ undefined);
|
|
42575
|
+
}
|
|
42576
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42577
|
+
// TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
|
|
42578
|
+
// to be in the business of validating everyone's import and export map correctness.
|
|
42579
|
+
var subpathParts = ts.getPathComponents(subpath);
|
|
42580
|
+
if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) {
|
|
42581
|
+
if (state.traceEnabled) {
|
|
42582
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42583
|
+
}
|
|
42584
|
+
return toSearchResult(/*value*/ undefined);
|
|
42585
|
+
}
|
|
42586
|
+
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));
|
|
42587
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
42588
|
+
}
|
|
42589
|
+
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
42590
|
+
if (!Array.isArray(target)) {
|
|
42591
|
+
for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
|
|
42592
|
+
var key = _c[_i];
|
|
42593
|
+
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
42594
|
+
var subTarget = target[key];
|
|
42595
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
42596
|
+
if (result) {
|
|
42597
|
+
return result;
|
|
42598
|
+
}
|
|
42599
|
+
}
|
|
42600
|
+
}
|
|
42601
|
+
return undefined;
|
|
42602
|
+
}
|
|
42603
|
+
else {
|
|
42604
|
+
if (!ts.length(target)) {
|
|
42605
|
+
if (state.traceEnabled) {
|
|
42606
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42607
|
+
}
|
|
42608
|
+
return toSearchResult(/*value*/ undefined);
|
|
42609
|
+
}
|
|
42610
|
+
for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
|
|
42611
|
+
var elem = target_1[_d];
|
|
42612
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
42613
|
+
if (result) {
|
|
42614
|
+
return result;
|
|
42615
|
+
}
|
|
42616
|
+
}
|
|
42617
|
+
}
|
|
42618
|
+
}
|
|
42619
|
+
else if (target === null) { // eslint-disable-line no-null/no-null
|
|
42620
|
+
if (state.traceEnabled) {
|
|
42621
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName);
|
|
42622
|
+
}
|
|
42623
|
+
return toSearchResult(/*value*/ undefined);
|
|
42624
|
+
}
|
|
42625
|
+
if (state.traceEnabled) {
|
|
42626
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42627
|
+
}
|
|
42628
|
+
return toSearchResult(/*value*/ undefined);
|
|
42629
|
+
}
|
|
42630
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42631
|
+
if (conditions.indexOf("types") === -1)
|
|
42632
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42633
|
+
if (!ts.startsWith(key, "types@"))
|
|
42634
|
+
return false;
|
|
42635
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42636
|
+
if (!range)
|
|
42637
|
+
return false;
|
|
42638
|
+
return range.test(ts.version);
|
|
42639
|
+
}
|
|
42640
|
+
}
|
|
42105
42641
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42106
42642
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42107
42643
|
}
|
|
@@ -42110,24 +42646,24 @@ var ts;
|
|
|
42110
42646
|
return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42111
42647
|
}
|
|
42112
42648
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42113
|
-
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42649
|
+
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
|
|
42114
42650
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
42115
42651
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
42116
42652
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
|
|
42117
42653
|
if (resolutionFromCache) {
|
|
42118
42654
|
return resolutionFromCache;
|
|
42119
42655
|
}
|
|
42120
|
-
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
|
|
42656
|
+
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
|
|
42121
42657
|
}
|
|
42122
42658
|
});
|
|
42123
42659
|
}
|
|
42124
|
-
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
|
|
42660
|
+
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42125
42661
|
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
|
|
42126
42662
|
var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
|
|
42127
42663
|
if (!nodeModulesFolderExists && state.traceEnabled) {
|
|
42128
42664
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
|
|
42129
42665
|
}
|
|
42130
|
-
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
|
|
42666
|
+
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
|
|
42131
42667
|
if (packageResult) {
|
|
42132
42668
|
return packageResult;
|
|
42133
42669
|
}
|
|
@@ -42140,27 +42676,35 @@ var ts;
|
|
|
42140
42676
|
}
|
|
42141
42677
|
nodeModulesAtTypesExists = false;
|
|
42142
42678
|
}
|
|
42143
|
-
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
|
|
42679
|
+
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state, cache, redirectedReference);
|
|
42144
42680
|
}
|
|
42145
42681
|
}
|
|
42146
|
-
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
|
|
42682
|
+
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
|
|
42147
42683
|
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
|
|
42148
42684
|
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
|
|
42149
42685
|
var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
|
|
42150
|
-
if (
|
|
42151
|
-
|
|
42152
|
-
if (
|
|
42153
|
-
|
|
42686
|
+
// But only if we're not respecting export maps (if we are, we might redirect around this location)
|
|
42687
|
+
if (!(state.features & NodeResolutionFeatures.Exports)) {
|
|
42688
|
+
if (packageInfo) {
|
|
42689
|
+
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
|
|
42690
|
+
if (fromFile) {
|
|
42691
|
+
return noPackageId(fromFile);
|
|
42692
|
+
}
|
|
42693
|
+
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42694
|
+
return withPackageId(packageInfo, fromDirectory);
|
|
42154
42695
|
}
|
|
42155
|
-
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42156
|
-
return withPackageId(packageInfo, fromDirectory);
|
|
42157
42696
|
}
|
|
42697
|
+
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42158
42698
|
var loader = function (extensions, candidate, onlyRecordFailures, state) {
|
|
42699
|
+
var _a;
|
|
42700
|
+
// package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
|
|
42701
|
+
if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
|
|
42702
|
+
return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
|
|
42703
|
+
}
|
|
42159
42704
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
42160
42705
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
42161
42706
|
return withPackageId(packageInfo, pathAndExtension);
|
|
42162
42707
|
};
|
|
42163
|
-
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42164
42708
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
42165
42709
|
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
|
|
42166
42710
|
// 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.
|
|
@@ -42262,7 +42806,7 @@ var ts;
|
|
|
42262
42806
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
42263
42807
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
42264
42808
|
var failedLookupLocations = [];
|
|
42265
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
42809
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42266
42810
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
42267
42811
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
42268
42812
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
@@ -42273,7 +42817,7 @@ var ts;
|
|
|
42273
42817
|
return { value: resolvedUsingSettings };
|
|
42274
42818
|
}
|
|
42275
42819
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
42276
|
-
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42820
|
+
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
|
|
42277
42821
|
// Climb up parent directories looking for a module.
|
|
42278
42822
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
42279
42823
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
|
|
@@ -42309,8 +42853,8 @@ var ts;
|
|
|
42309
42853
|
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);
|
|
42310
42854
|
}
|
|
42311
42855
|
var failedLookupLocations = [];
|
|
42312
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache };
|
|
42313
|
-
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false);
|
|
42856
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42857
|
+
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42314
42858
|
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
42315
42859
|
}
|
|
42316
42860
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
@@ -44491,7 +45035,7 @@ var ts;
|
|
|
44491
45035
|
}
|
|
44492
45036
|
function checkStrictModeLabeledStatement(node) {
|
|
44493
45037
|
// Grammar checking for labeledStatement
|
|
44494
|
-
if (inStrictMode && options
|
|
45038
|
+
if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) {
|
|
44495
45039
|
if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
|
|
44496
45040
|
errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
|
|
44497
45041
|
}
|
|
@@ -46007,7 +46551,7 @@ var ts;
|
|
|
46007
46551
|
host.getSourceFiles().forEach(function (sf) {
|
|
46008
46552
|
if (!sf.resolvedModules)
|
|
46009
46553
|
return;
|
|
46010
|
-
|
|
46554
|
+
sf.resolvedModules.forEach(function (r) {
|
|
46011
46555
|
if (r && r.packageId)
|
|
46012
46556
|
map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
|
|
46013
46557
|
});
|
|
@@ -46401,6 +46945,7 @@ var ts;
|
|
|
46401
46945
|
getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
|
|
46402
46946
|
isDeclarationVisible: isDeclarationVisible,
|
|
46403
46947
|
isPropertyAccessible: isPropertyAccessible,
|
|
46948
|
+
getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
|
|
46404
46949
|
};
|
|
46405
46950
|
function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
|
|
46406
46951
|
var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
|
|
@@ -47153,7 +47698,7 @@ var ts;
|
|
|
47153
47698
|
}
|
|
47154
47699
|
else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
47155
47700
|
// foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
|
|
47156
|
-
return !(compilerOptions
|
|
47701
|
+
return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47157
47702
|
&& ts.getContainingClass(declaration) === ts.getContainingClass(usage)
|
|
47158
47703
|
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
47159
47704
|
}
|
|
@@ -47181,7 +47726,7 @@ var ts;
|
|
|
47181
47726
|
return true;
|
|
47182
47727
|
}
|
|
47183
47728
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
47184
|
-
if (compilerOptions
|
|
47729
|
+
if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47185
47730
|
&& ts.getContainingClass(declaration)
|
|
47186
47731
|
&& (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
47187
47732
|
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
|
@@ -47359,7 +47904,7 @@ var ts;
|
|
|
47359
47904
|
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, issueSuggestions);
|
|
47360
47905
|
}
|
|
47361
47906
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, issueSuggestions) {
|
|
47362
|
-
var _a;
|
|
47907
|
+
var _a, _b, _c;
|
|
47363
47908
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
47364
47909
|
var result;
|
|
47365
47910
|
var lastLocation;
|
|
@@ -47429,7 +47974,7 @@ var ts;
|
|
|
47429
47974
|
isInExternalModule = true;
|
|
47430
47975
|
// falls through
|
|
47431
47976
|
case 260 /* ModuleDeclaration */:
|
|
47432
|
-
var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
|
|
47977
|
+
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
47433
47978
|
if (location.kind === 303 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
47434
47979
|
// It's an external module. First see if the module has an export default and if the local
|
|
47435
47980
|
// name of that export default matches.
|
|
@@ -47460,7 +48005,7 @@ var ts;
|
|
|
47460
48005
|
}
|
|
47461
48006
|
// ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs)
|
|
47462
48007
|
if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) {
|
|
47463
|
-
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((
|
|
48008
|
+
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) {
|
|
47464
48009
|
result = undefined;
|
|
47465
48010
|
}
|
|
47466
48011
|
else {
|
|
@@ -47469,7 +48014,7 @@ var ts;
|
|
|
47469
48014
|
}
|
|
47470
48015
|
break;
|
|
47471
48016
|
case 259 /* EnumDeclaration */:
|
|
47472
|
-
if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
|
|
48017
|
+
if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
|
|
47473
48018
|
break loop;
|
|
47474
48019
|
}
|
|
47475
48020
|
break;
|
|
@@ -47552,7 +48097,7 @@ var ts;
|
|
|
47552
48097
|
case 213 /* ArrowFunction */:
|
|
47553
48098
|
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
|
47554
48099
|
// for lower compile targets the resolved symbol is used to emit an error
|
|
47555
|
-
if (compilerOptions
|
|
48100
|
+
if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
|
|
47556
48101
|
break;
|
|
47557
48102
|
}
|
|
47558
48103
|
// falls through
|
|
@@ -47720,7 +48265,7 @@ var ts;
|
|
|
47720
48265
|
}
|
|
47721
48266
|
// Perform extra checks only if error reporting was requested
|
|
47722
48267
|
if (nameNotFoundMessage) {
|
|
47723
|
-
if (propertyWithInvalidInitializer && !(compilerOptions
|
|
48268
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
47724
48269
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
47725
48270
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
47726
48271
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -47777,8 +48322,7 @@ var ts;
|
|
|
47777
48322
|
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
47778
48323
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
47779
48324
|
if (typeOnlyDeclaration) {
|
|
47780
|
-
var
|
|
47781
|
-
var message = isExport
|
|
48325
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
47782
48326
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
47783
48327
|
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
47784
48328
|
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
@@ -47789,7 +48333,7 @@ var ts;
|
|
|
47789
48333
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
47790
48334
|
if (!typeOnlyDeclaration)
|
|
47791
48335
|
return diagnostic;
|
|
47792
|
-
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration,
|
|
48336
|
+
return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName));
|
|
47793
48337
|
}
|
|
47794
48338
|
function getIsDeferredContext(location, lastLocation) {
|
|
47795
48339
|
if (location.kind !== 213 /* ArrowFunction */ && location.kind !== 212 /* FunctionExpression */) {
|
|
@@ -48113,15 +48657,13 @@ var ts;
|
|
|
48113
48657
|
function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
|
|
48114
48658
|
if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) {
|
|
48115
48659
|
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
|
|
48116
|
-
var isExport =
|
|
48660
|
+
var isExport = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */;
|
|
48117
48661
|
var message = isExport
|
|
48118
48662
|
? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
|
|
48119
48663
|
: ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
|
|
48120
48664
|
var relatedMessage = isExport
|
|
48121
48665
|
? ts.Diagnostics._0_was_exported_here
|
|
48122
48666
|
: ts.Diagnostics._0_was_imported_here;
|
|
48123
|
-
// Non-null assertion is safe because the optionality comes from ImportClause,
|
|
48124
|
-
// but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`.
|
|
48125
48667
|
var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
|
|
48126
48668
|
ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
|
|
48127
48669
|
}
|
|
@@ -48298,7 +48840,7 @@ var ts;
|
|
|
48298
48840
|
if (!ts.isIdentifier(name)) {
|
|
48299
48841
|
return undefined;
|
|
48300
48842
|
}
|
|
48301
|
-
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions
|
|
48843
|
+
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
|
|
48302
48844
|
var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
|
|
48303
48845
|
if (targetSymbol) {
|
|
48304
48846
|
if (name.escapedText) {
|
|
@@ -48376,18 +48918,18 @@ var ts;
|
|
|
48376
48918
|
}
|
|
48377
48919
|
function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
|
|
48378
48920
|
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
48379
|
-
var message = compilerOptions
|
|
48921
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
|
|
48380
48922
|
ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48381
48923
|
error(name, message, declarationName);
|
|
48382
48924
|
}
|
|
48383
48925
|
else {
|
|
48384
48926
|
if (ts.isInJSFile(node)) {
|
|
48385
|
-
var message = compilerOptions
|
|
48927
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
|
|
48386
48928
|
ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48387
48929
|
error(name, message, declarationName);
|
|
48388
48930
|
}
|
|
48389
48931
|
else {
|
|
48390
|
-
var message = compilerOptions
|
|
48932
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
|
|
48391
48933
|
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;
|
|
48392
48934
|
error(name, message, declarationName, declarationName, moduleName);
|
|
48393
48935
|
}
|
|
@@ -48537,13 +49079,13 @@ var ts;
|
|
|
48537
49079
|
* and issue an error if so.
|
|
48538
49080
|
*
|
|
48539
49081
|
* @param aliasDeclaration The alias declaration not marked as type-only
|
|
49082
|
+
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
49083
|
+
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
49084
|
+
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
48540
49085
|
* has already been marked as not resolving to a type-only alias. Used when recursively resolving qualified
|
|
48541
49086
|
* names of import aliases, e.g. `import C = a.b.C`. If namespace `a` is not found to be type-only, the
|
|
48542
49087
|
* import declaration will initially be marked as not resolving to a type-only symbol. But, namespace `b`
|
|
48543
49088
|
* must still be checked for a type-only marker, overwriting the previous negative result if found.
|
|
48544
|
-
* @param immediateTarget The symbol to which the alias declaration immediately resolves
|
|
48545
|
-
* @param finalTarget The symbol to which the alias declaration ultimately resolves
|
|
48546
|
-
* @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration`
|
|
48547
49089
|
*/
|
|
48548
49090
|
function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
|
|
48549
49091
|
if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration))
|
|
@@ -48828,6 +49370,7 @@ var ts;
|
|
|
48828
49370
|
: undefined;
|
|
48829
49371
|
}
|
|
48830
49372
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
49373
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48831
49374
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
48832
49375
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
48833
49376
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -48839,7 +49382,15 @@ var ts;
|
|
|
48839
49382
|
return ambientModule;
|
|
48840
49383
|
}
|
|
48841
49384
|
var currentSourceFile = ts.getSourceFileOfNode(location);
|
|
48842
|
-
var
|
|
49385
|
+
var contextSpecifier = ts.isStringLiteralLike(location)
|
|
49386
|
+
? location
|
|
49387
|
+
: ((_a = ts.findAncestor(location, ts.isImportCall)) === null || _a === void 0 ? void 0 : _a.arguments[0]) ||
|
|
49388
|
+
((_b = ts.findAncestor(location, ts.isImportDeclaration)) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) ||
|
|
49389
|
+
((_c = ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) ||
|
|
49390
|
+
((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
|
|
49391
|
+
((_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) ||
|
|
49392
|
+
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49393
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
|
|
48843
49394
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
48844
49395
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
48845
49396
|
if (sourceFile) {
|
|
@@ -48847,6 +49398,12 @@ var ts;
|
|
|
48847
49398
|
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
48848
49399
|
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
|
48849
49400
|
}
|
|
49401
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
|
|
49402
|
+
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
|
|
49403
|
+
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49404
|
+
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);
|
|
49405
|
+
}
|
|
49406
|
+
}
|
|
48850
49407
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
48851
49408
|
return getMergedSymbol(sourceFile.symbol);
|
|
48852
49409
|
}
|
|
@@ -48904,15 +49461,14 @@ var ts;
|
|
|
48904
49461
|
* Direct users to import source with .js extension if outputting an ES module.
|
|
48905
49462
|
* @see https://github.com/microsoft/TypeScript/issues/42151
|
|
48906
49463
|
*/
|
|
48907
|
-
|
|
48908
|
-
|
|
48909
|
-
replacedImportSource += ".js";
|
|
49464
|
+
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
49465
|
+
replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js";
|
|
48910
49466
|
}
|
|
48911
49467
|
error(errorNode, diag, tsExtension, replacedImportSource);
|
|
48912
49468
|
}
|
|
48913
49469
|
else if (!compilerOptions.resolveJsonModule &&
|
|
48914
49470
|
ts.fileExtensionIs(moduleReference, ".json" /* Json */) &&
|
|
48915
|
-
ts.getEmitModuleResolutionKind(compilerOptions)
|
|
49471
|
+
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic &&
|
|
48916
49472
|
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
48917
49473
|
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
48918
49474
|
}
|
|
@@ -48985,7 +49541,7 @@ var ts;
|
|
|
48985
49541
|
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);
|
|
48986
49542
|
return symbol;
|
|
48987
49543
|
}
|
|
48988
|
-
if (compilerOptions
|
|
49544
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
48989
49545
|
var referenceParent = referencingLocation.parent;
|
|
48990
49546
|
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
48991
49547
|
ts.isImportCall(referenceParent)) {
|
|
@@ -49952,6 +50508,7 @@ var ts;
|
|
|
49952
50508
|
isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
|
|
49953
50509
|
fileExists: function (fileName) { return host.fileExists(fileName); },
|
|
49954
50510
|
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
|
|
50511
|
+
readFile: host.readFile ? (function (fileName) { return host.readFile(fileName); }) : undefined,
|
|
49955
50512
|
} : undefined },
|
|
49956
50513
|
encounteredError: false,
|
|
49957
50514
|
reportedDiagnostic: false,
|
|
@@ -51123,7 +51680,7 @@ var ts;
|
|
|
51123
51680
|
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
|
|
51124
51681
|
var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
|
|
51125
51682
|
var specifier = getSpecifierForModuleSymbol(chain[0], context);
|
|
51126
|
-
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions)
|
|
51683
|
+
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
|
|
51127
51684
|
// If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
|
|
51128
51685
|
// since declaration files with these kinds of references are liable to fail when published :(
|
|
51129
51686
|
context.encounteredError = true;
|
|
@@ -51346,7 +51903,7 @@ var ts;
|
|
|
51346
51903
|
if (nameType) {
|
|
51347
51904
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
51348
51905
|
var name = "" + nameType.value;
|
|
51349
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
51906
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
51350
51907
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51351
51908
|
}
|
|
51352
51909
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -51360,7 +51917,7 @@ var ts;
|
|
|
51360
51917
|
}
|
|
51361
51918
|
}
|
|
51362
51919
|
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
51363
|
-
return ts.isIdentifierText(name, compilerOptions
|
|
51920
|
+
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
51364
51921
|
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
51365
51922
|
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51366
51923
|
}
|
|
@@ -51661,7 +52218,7 @@ var ts;
|
|
|
51661
52218
|
ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], ns.body.statements, true), [ts.factory.createExportDeclaration(
|
|
51662
52219
|
/*decorators*/ undefined,
|
|
51663
52220
|
/*modifiers*/ undefined,
|
|
51664
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*alias*/ undefined, id); })),
|
|
52221
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id); })),
|
|
51665
52222
|
/*moduleSpecifier*/ undefined)], false))));
|
|
51666
52223
|
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true);
|
|
51667
52224
|
}
|
|
@@ -51889,7 +52446,7 @@ var ts;
|
|
|
51889
52446
|
addResult(ts.factory.createExportDeclaration(
|
|
51890
52447
|
/*decorators*/ undefined,
|
|
51891
52448
|
/*modifiers*/ undefined,
|
|
51892
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0 /* None */);
|
|
52449
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */);
|
|
51893
52450
|
context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */);
|
|
51894
52451
|
}
|
|
51895
52452
|
else {
|
|
@@ -51922,7 +52479,7 @@ var ts;
|
|
|
51922
52479
|
addResult(ts.factory.createExportDeclaration(
|
|
51923
52480
|
/*decorators*/ undefined,
|
|
51924
52481
|
/*modifiers*/ undefined,
|
|
51925
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */);
|
|
52482
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */);
|
|
51926
52483
|
needsExportDeclaration = false;
|
|
51927
52484
|
needsPostExportDefault = false;
|
|
51928
52485
|
}
|
|
@@ -51980,7 +52537,7 @@ var ts;
|
|
|
51980
52537
|
addResult(ts.factory.createExportDeclaration(
|
|
51981
52538
|
/*decorators*/ undefined,
|
|
51982
52539
|
/*modifiers*/ undefined,
|
|
51983
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
52540
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */);
|
|
51984
52541
|
}
|
|
51985
52542
|
}
|
|
51986
52543
|
function includePrivateSymbol(symbol) {
|
|
@@ -52102,7 +52659,7 @@ var ts;
|
|
|
52102
52659
|
var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true);
|
|
52103
52660
|
includePrivateSymbol(target || s);
|
|
52104
52661
|
var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
|
|
52105
|
-
return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name);
|
|
52662
|
+
return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name);
|
|
52106
52663
|
})))]);
|
|
52107
52664
|
addResult(ts.factory.createModuleDeclaration(
|
|
52108
52665
|
/*decorators*/ undefined,
|
|
@@ -52193,7 +52750,7 @@ var ts;
|
|
|
52193
52750
|
var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration(
|
|
52194
52751
|
/*decorators*/ undefined,
|
|
52195
52752
|
/*modifiers*/ undefined,
|
|
52196
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52753
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; });
|
|
52197
52754
|
var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
|
|
52198
52755
|
fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
|
|
52199
52756
|
addResult(fakespace, modifierFlags); // namespaces can never be default exported
|
|
@@ -52294,6 +52851,27 @@ var ts;
|
|
|
52294
52851
|
/*decorators*/ undefined,
|
|
52295
52852
|
/*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);
|
|
52296
52853
|
}
|
|
52854
|
+
function getSomeTargetNameFromDeclarations(declarations) {
|
|
52855
|
+
return ts.firstDefined(declarations, function (d) {
|
|
52856
|
+
if (ts.isImportSpecifier(d) || ts.isExportSpecifier(d)) {
|
|
52857
|
+
return ts.idText(d.propertyName || d.name);
|
|
52858
|
+
}
|
|
52859
|
+
if (ts.isBinaryExpression(d) || ts.isExportAssignment(d)) {
|
|
52860
|
+
var expression = ts.isExportAssignment(d) ? d.expression : d.right;
|
|
52861
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
52862
|
+
return ts.idText(expression.name);
|
|
52863
|
+
}
|
|
52864
|
+
}
|
|
52865
|
+
if (isAliasSymbolDeclaration(d)) {
|
|
52866
|
+
// This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module.
|
|
52867
|
+
var name = ts.getNameOfDeclaration(d);
|
|
52868
|
+
if (name && ts.isIdentifier(name)) {
|
|
52869
|
+
return ts.idText(name);
|
|
52870
|
+
}
|
|
52871
|
+
}
|
|
52872
|
+
return undefined;
|
|
52873
|
+
});
|
|
52874
|
+
}
|
|
52297
52875
|
function serializeAsAlias(symbol, localName, modifierFlags) {
|
|
52298
52876
|
var _a, _b, _c, _d, _e;
|
|
52299
52877
|
// synthesize an alias, eg `export { symbolName as Name }`
|
|
@@ -52306,8 +52884,10 @@ var ts;
|
|
|
52306
52884
|
if (!target) {
|
|
52307
52885
|
return;
|
|
52308
52886
|
}
|
|
52309
|
-
|
|
52310
|
-
|
|
52887
|
+
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
|
|
52888
|
+
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
|
|
52889
|
+
var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName);
|
|
52890
|
+
if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
|
|
52311
52891
|
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
|
|
52312
52892
|
verbatimTargetName = "default" /* Default */;
|
|
52313
52893
|
}
|
|
@@ -52321,7 +52901,8 @@ var ts;
|
|
|
52321
52901
|
var propertyName = node.propertyName;
|
|
52322
52902
|
addResult(ts.factory.createImportDeclaration(
|
|
52323
52903
|
/*decorators*/ undefined,
|
|
52324
|
-
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52904
|
+
/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(
|
|
52905
|
+
/*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1),
|
|
52325
52906
|
/*importClause*/ undefined), 0 /* None */);
|
|
52326
52907
|
break;
|
|
52327
52908
|
}
|
|
@@ -52405,7 +52986,8 @@ var ts;
|
|
|
52405
52986
|
/*modifiers*/ undefined, ts.factory.createImportClause(
|
|
52406
52987
|
/*isTypeOnly*/ false,
|
|
52407
52988
|
/*importClause*/ undefined, ts.factory.createNamedImports([
|
|
52408
|
-
ts.factory.createImportSpecifier(
|
|
52989
|
+
ts.factory.createImportSpecifier(
|
|
52990
|
+
/*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
|
|
52409
52991
|
])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)),
|
|
52410
52992
|
/*assertClause*/ undefined), 0 /* None */);
|
|
52411
52993
|
break;
|
|
@@ -52441,7 +53023,7 @@ var ts;
|
|
|
52441
53023
|
addResult(ts.factory.createExportDeclaration(
|
|
52442
53024
|
/*decorators*/ undefined,
|
|
52443
53025
|
/*modifiers*/ undefined,
|
|
52444
|
-
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
53026
|
+
/*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */);
|
|
52445
53027
|
}
|
|
52446
53028
|
/**
|
|
52447
53029
|
* Returns `true` if an export assignment or declaration was produced for the symbol
|
|
@@ -52854,7 +53436,7 @@ var ts;
|
|
|
52854
53436
|
if (nameType) {
|
|
52855
53437
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52856
53438
|
var name = "" + nameType.value;
|
|
52857
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
53439
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52858
53440
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
52859
53441
|
}
|
|
52860
53442
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -55936,6 +56518,23 @@ var ts;
|
|
|
55936
56518
|
function getIsLateCheckFlag(s) {
|
|
55937
56519
|
return ts.getCheckFlags(s) & 4096 /* Late */;
|
|
55938
56520
|
}
|
|
56521
|
+
function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) {
|
|
56522
|
+
for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
|
|
56523
|
+
var prop = _a[_i];
|
|
56524
|
+
cb(getLiteralTypeFromProperty(prop, include));
|
|
56525
|
+
}
|
|
56526
|
+
if (type.flags & 1 /* Any */) {
|
|
56527
|
+
cb(stringType);
|
|
56528
|
+
}
|
|
56529
|
+
else {
|
|
56530
|
+
for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) {
|
|
56531
|
+
var info = _c[_b];
|
|
56532
|
+
if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
56533
|
+
cb(info.keyType);
|
|
56534
|
+
}
|
|
56535
|
+
}
|
|
56536
|
+
}
|
|
56537
|
+
}
|
|
55939
56538
|
/** Resolve the members of a mapped type { [P in K]: T } */
|
|
55940
56539
|
function resolveMappedTypeMembers(type) {
|
|
55941
56540
|
var members = ts.createSymbolTable();
|
|
@@ -55953,21 +56552,7 @@ var ts;
|
|
|
55953
56552
|
var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */;
|
|
55954
56553
|
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
55955
56554
|
// We have a { [P in keyof T]: X }
|
|
55956
|
-
|
|
55957
|
-
var prop = _a[_i];
|
|
55958
|
-
addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
|
|
55959
|
-
}
|
|
55960
|
-
if (modifiersType.flags & 1 /* Any */) {
|
|
55961
|
-
addMemberForKeyType(stringType);
|
|
55962
|
-
}
|
|
55963
|
-
else {
|
|
55964
|
-
for (var _b = 0, _c = getIndexInfosOfType(modifiersType); _b < _c.length; _b++) {
|
|
55965
|
-
var info = _c[_b];
|
|
55966
|
-
if (!keyofStringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) {
|
|
55967
|
-
addMemberForKeyType(info.keyType);
|
|
55968
|
-
}
|
|
55969
|
-
}
|
|
55970
|
-
}
|
|
56555
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType);
|
|
55971
56556
|
}
|
|
55972
56557
|
else {
|
|
55973
56558
|
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
@@ -58474,8 +59059,6 @@ var ts;
|
|
|
58474
59059
|
// We ignore 'never' types in unions
|
|
58475
59060
|
if (!(flags & 131072 /* Never */)) {
|
|
58476
59061
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58477
|
-
if (flags & 469499904 /* StructuredOrInstantiable */)
|
|
58478
|
-
includes |= 262144 /* IncludesStructuredOrInstantiable */;
|
|
58479
59062
|
if (type === wildcardType)
|
|
58480
59063
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58481
59064
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -58781,13 +59364,19 @@ var ts;
|
|
|
58781
59364
|
if (type === wildcardType)
|
|
58782
59365
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58783
59366
|
}
|
|
58784
|
-
else if (
|
|
58785
|
-
if (
|
|
58786
|
-
|
|
58787
|
-
|
|
58788
|
-
|
|
59367
|
+
else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
59368
|
+
if (exactOptionalPropertyTypes && type === missingType) {
|
|
59369
|
+
includes |= 262144 /* IncludesMissingType */;
|
|
59370
|
+
type = undefinedType;
|
|
59371
|
+
}
|
|
59372
|
+
if (!typeSet.has(type.id.toString())) {
|
|
59373
|
+
if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) {
|
|
59374
|
+
// We have seen two distinct unit types which means we should reduce to an
|
|
59375
|
+
// empty intersection. Adding TypeFlags.NonPrimitive causes that to happen.
|
|
59376
|
+
includes |= 67108864 /* NonPrimitive */;
|
|
59377
|
+
}
|
|
59378
|
+
typeSet.set(type.id.toString(), type);
|
|
58789
59379
|
}
|
|
58790
|
-
typeSet.set(type.id.toString(), type);
|
|
58791
59380
|
}
|
|
58792
59381
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58793
59382
|
}
|
|
@@ -58860,14 +59449,13 @@ var ts;
|
|
|
58860
59449
|
}
|
|
58861
59450
|
return false;
|
|
58862
59451
|
}
|
|
58863
|
-
function
|
|
58864
|
-
|
|
58865
|
-
|
|
58866
|
-
|
|
58867
|
-
|
|
58868
|
-
return
|
|
59452
|
+
function eachIsUnionContaining(types, flag) {
|
|
59453
|
+
return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
|
|
59454
|
+
}
|
|
59455
|
+
function removeFromEach(types, flag) {
|
|
59456
|
+
for (var i = 0; i < types.length; i++) {
|
|
59457
|
+
types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
|
|
58869
59458
|
}
|
|
58870
|
-
return false;
|
|
58871
59459
|
}
|
|
58872
59460
|
// If the given list of types contains more than one union of primitive types, replace the
|
|
58873
59461
|
// first with a union containing an intersection of those primitive types, then remove the
|
|
@@ -58976,6 +59564,9 @@ var ts;
|
|
|
58976
59564
|
if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
|
|
58977
59565
|
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
|
|
58978
59566
|
}
|
|
59567
|
+
if (includes & 262144 /* IncludesMissingType */) {
|
|
59568
|
+
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
59569
|
+
}
|
|
58979
59570
|
if (typeSet.length === 0) {
|
|
58980
59571
|
return unknownType;
|
|
58981
59572
|
}
|
|
@@ -58992,10 +59583,13 @@ var ts;
|
|
|
58992
59583
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
58993
59584
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
58994
59585
|
}
|
|
58995
|
-
else if (
|
|
58996
|
-
|
|
59586
|
+
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
59587
|
+
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
59588
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
59589
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
58997
59590
|
}
|
|
58998
|
-
else if (
|
|
59591
|
+
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
59592
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
58999
59593
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
59000
59594
|
}
|
|
59001
59595
|
else {
|
|
@@ -59075,18 +59669,56 @@ var ts;
|
|
|
59075
59669
|
type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) :
|
|
59076
59670
|
type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false));
|
|
59077
59671
|
}
|
|
59078
|
-
|
|
59079
|
-
|
|
59080
|
-
|
|
59081
|
-
|
|
59082
|
-
|
|
59083
|
-
|
|
59084
|
-
|
|
59085
|
-
|
|
59086
|
-
var
|
|
59087
|
-
|
|
59088
|
-
|
|
59089
|
-
|
|
59672
|
+
/**
|
|
59673
|
+
* This roughly mirrors `resolveMappedTypeMembers` in the nongeneric case, except only reports a union of the keys calculated,
|
|
59674
|
+
* rather than manufacturing the properties. We can't just fetch the `constraintType` since that would ignore mappings
|
|
59675
|
+
* and mapping the `constraintType` directly ignores how mapped types map _properties_ and not keys (thus ignoring subtype
|
|
59676
|
+
* reduction in the constraintType) when possible.
|
|
59677
|
+
* @param noIndexSignatures Indicates if _string_ index signatures should be elided. (other index signatures are always reported)
|
|
59678
|
+
*/
|
|
59679
|
+
function getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) {
|
|
59680
|
+
var typeParameter = getTypeParameterFromMappedType(type);
|
|
59681
|
+
var constraintType = getConstraintTypeFromMappedType(type);
|
|
59682
|
+
var nameType = getNameTypeFromMappedType(type.target || type);
|
|
59683
|
+
if (!nameType && !noIndexSignatures) {
|
|
59684
|
+
// no mapping and no filtering required, just quickly bail to returning the constraint in the common case
|
|
59685
|
+
return constraintType;
|
|
59686
|
+
}
|
|
59687
|
+
var keyTypes = [];
|
|
59688
|
+
if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
|
|
59689
|
+
// We have a { [P in keyof T]: X }
|
|
59690
|
+
// `getApparentType` on the T in a generic mapped type can trigger a circularity
|
|
59691
|
+
// (conditionals and `infer` types create a circular dependency in the constraint resolution)
|
|
59692
|
+
// so we only eagerly manifest the keys if the constraint is nongeneric
|
|
59693
|
+
if (!isGenericIndexType(constraintType)) {
|
|
59694
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T'
|
|
59695
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType);
|
|
59696
|
+
}
|
|
59697
|
+
else {
|
|
59698
|
+
// we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later
|
|
59699
|
+
// since it's not safe to resolve the shape of modifier type
|
|
59700
|
+
return getIndexTypeForGenericType(type, stringsOnly);
|
|
59701
|
+
}
|
|
59702
|
+
}
|
|
59703
|
+
else {
|
|
59704
|
+
forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
|
|
59705
|
+
}
|
|
59706
|
+
if (isGenericIndexType(constraintType)) { // include the generic component in the resulting type
|
|
59707
|
+
forEachType(constraintType, addMemberForKeyType);
|
|
59708
|
+
}
|
|
59709
|
+
// we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType,
|
|
59710
|
+
// so we can return the union that preserves aliases/origin data if possible
|
|
59711
|
+
var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes);
|
|
59712
|
+
if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) {
|
|
59713
|
+
return constraintType;
|
|
59714
|
+
}
|
|
59715
|
+
return result;
|
|
59716
|
+
function addMemberForKeyType(keyType) {
|
|
59717
|
+
var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType;
|
|
59718
|
+
// `keyof` currently always returns `string | number` for concrete `string` index signatures - the below ternary keeps that behavior for mapped types
|
|
59719
|
+
// See `getLiteralTypeFromProperties` where there's a similar ternary to cause the same behavior.
|
|
59720
|
+
keyTypes.push(propNameType === stringType ? stringOrNumberType : propNameType);
|
|
59721
|
+
}
|
|
59090
59722
|
}
|
|
59091
59723
|
// Ordinarily we reduce a keyof M, where M is a mapped type { [P in K as N<P>]: X }, to simply N<K>. This however presumes
|
|
59092
59724
|
// that N distributes over union types, i.e. that N<A | B | C> is equivalent to N<A> | N<B> | N<C>. Specifically, we only
|
|
@@ -59144,7 +59776,7 @@ var ts;
|
|
|
59144
59776
|
return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59145
59777
|
type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
|
|
59146
59778
|
type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
|
|
59147
|
-
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) :
|
|
59779
|
+
ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
|
|
59148
59780
|
type === wildcardType ? wildcardType :
|
|
59149
59781
|
type.flags & 2 /* Unknown */ ? neverType :
|
|
59150
59782
|
type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType :
|
|
@@ -61988,7 +62620,7 @@ var ts;
|
|
|
61988
62620
|
path = "" + str;
|
|
61989
62621
|
}
|
|
61990
62622
|
// Otherwise write a dotted name if possible
|
|
61991
|
-
else if (ts.isIdentifierText(str, compilerOptions
|
|
62623
|
+
else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) {
|
|
61992
62624
|
path = path + "." + str;
|
|
61993
62625
|
}
|
|
61994
62626
|
// Failing that, check if the name is already a computed name
|
|
@@ -62903,24 +63535,24 @@ var ts;
|
|
|
62903
63535
|
}
|
|
62904
63536
|
}
|
|
62905
63537
|
else if (target.flags & 4194304 /* Index */) {
|
|
62906
|
-
var
|
|
63538
|
+
var targetType_1 = target.type;
|
|
62907
63539
|
// A keyof S is related to a keyof T if T is related to S.
|
|
62908
63540
|
if (source.flags & 4194304 /* Index */) {
|
|
62909
|
-
if (result = isRelatedTo(
|
|
63541
|
+
if (result = isRelatedTo(targetType_1, source.type, /*reportErrors*/ false)) {
|
|
62910
63542
|
return result;
|
|
62911
63543
|
}
|
|
62912
63544
|
}
|
|
62913
|
-
if (isTupleType(
|
|
63545
|
+
if (isTupleType(targetType_1)) {
|
|
62914
63546
|
// An index type can have a tuple type target when the tuple type contains variadic elements.
|
|
62915
63547
|
// Check if the source is related to the known keys of the tuple type.
|
|
62916
|
-
if (result = isRelatedTo(source, getKnownKeysOfTupleType(
|
|
63548
|
+
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), reportErrors)) {
|
|
62917
63549
|
return result;
|
|
62918
63550
|
}
|
|
62919
63551
|
}
|
|
62920
63552
|
else {
|
|
62921
63553
|
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
|
|
62922
63554
|
// simplified form of T or, if T doesn't simplify, the constraint of T.
|
|
62923
|
-
var constraint = getSimplifiedTypeOrConstraint(
|
|
63555
|
+
var constraint = getSimplifiedTypeOrConstraint(targetType_1);
|
|
62924
63556
|
if (constraint) {
|
|
62925
63557
|
// We require Ternary.True here such that circular constraints don't cause
|
|
62926
63558
|
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
|
@@ -62930,6 +63562,30 @@ var ts;
|
|
|
62930
63562
|
return -1 /* True */;
|
|
62931
63563
|
}
|
|
62932
63564
|
}
|
|
63565
|
+
else if (isGenericMappedType(targetType_1)) {
|
|
63566
|
+
// generic mapped types that don't simplify or have a constraint still have a very simple set of keys we can compare against
|
|
63567
|
+
// - their nameType or constraintType.
|
|
63568
|
+
// In many ways, this comparison is a deferred version of what `getIndexTypeForMappedType` does to actually resolve the keys for _non_-generic types
|
|
63569
|
+
var nameType_1 = getNameTypeFromMappedType(targetType_1);
|
|
63570
|
+
var constraintType = getConstraintTypeFromMappedType(targetType_1);
|
|
63571
|
+
var targetKeys = void 0;
|
|
63572
|
+
if (nameType_1 && isMappedTypeWithKeyofConstraintDeclaration(targetType_1)) {
|
|
63573
|
+
// we need to get the apparent mappings and union them with the generic mappings, since some properties may be
|
|
63574
|
+
// missing from the `constraintType` which will otherwise be mapped in the object
|
|
63575
|
+
var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1));
|
|
63576
|
+
var mappedKeys_1 = [];
|
|
63577
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */,
|
|
63578
|
+
/*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); });
|
|
63579
|
+
// We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side)
|
|
63580
|
+
targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false));
|
|
63581
|
+
}
|
|
63582
|
+
else {
|
|
63583
|
+
targetKeys = nameType_1 || constraintType;
|
|
63584
|
+
}
|
|
63585
|
+
if (isRelatedTo(source, targetKeys, reportErrors) === -1 /* True */) {
|
|
63586
|
+
return -1 /* True */;
|
|
63587
|
+
}
|
|
63588
|
+
}
|
|
62933
63589
|
}
|
|
62934
63590
|
}
|
|
62935
63591
|
else if (target.flags & 8388608 /* IndexedAccess */) {
|
|
@@ -65960,8 +66616,16 @@ var ts;
|
|
|
65960
66616
|
function inferToTemplateLiteralType(source, target) {
|
|
65961
66617
|
var matches = inferTypesFromTemplateLiteralType(source, target);
|
|
65962
66618
|
var types = target.types;
|
|
65963
|
-
|
|
65964
|
-
|
|
66619
|
+
// When the target template literal contains only placeholders (meaning that inference is intended to extract
|
|
66620
|
+
// single characters and remainder strings) and inference fails to produce matches, we want to infer 'never' for
|
|
66621
|
+
// each placeholder such that instantiation with the inferred value(s) produces 'never', a type for which an
|
|
66622
|
+
// assignment check will fail. If we make no inferences, we'll likely end up with the constraint 'string' which,
|
|
66623
|
+
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
66624
|
+
// succeed. That would be a pointless and confusing outcome.
|
|
66625
|
+
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
66626
|
+
for (var i = 0; i < types.length; i++) {
|
|
66627
|
+
inferFromTypes(matches ? matches[i] : neverType, types[i]);
|
|
66628
|
+
}
|
|
65965
66629
|
}
|
|
65966
66630
|
}
|
|
65967
66631
|
function inferFromObjectTypes(source, target) {
|
|
@@ -67867,6 +68531,9 @@ var ts;
|
|
|
67867
68531
|
case 102 /* InstanceOfKeyword */:
|
|
67868
68532
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
67869
68533
|
case 101 /* InKeyword */:
|
|
68534
|
+
if (ts.isPrivateIdentifier(expr.left)) {
|
|
68535
|
+
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
68536
|
+
}
|
|
67870
68537
|
var target = getReferenceCandidate(expr.right);
|
|
67871
68538
|
var leftType = getTypeOfNode(expr.left);
|
|
67872
68539
|
if (leftType.flags & 128 /* StringLiteral */) {
|
|
@@ -67896,6 +68563,22 @@ var ts;
|
|
|
67896
68563
|
}
|
|
67897
68564
|
return type;
|
|
67898
68565
|
}
|
|
68566
|
+
function narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue) {
|
|
68567
|
+
var target = getReferenceCandidate(expr.right);
|
|
68568
|
+
if (!isMatchingReference(reference, target)) {
|
|
68569
|
+
return type;
|
|
68570
|
+
}
|
|
68571
|
+
ts.Debug.assertNode(expr.left, ts.isPrivateIdentifier);
|
|
68572
|
+
var symbol = getSymbolForPrivateIdentifierExpression(expr.left);
|
|
68573
|
+
if (symbol === undefined) {
|
|
68574
|
+
return type;
|
|
68575
|
+
}
|
|
68576
|
+
var classSymbol = symbol.parent;
|
|
68577
|
+
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
68578
|
+
? getTypeOfSymbol(classSymbol)
|
|
68579
|
+
: getDeclaredTypeOfSymbol(classSymbol);
|
|
68580
|
+
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
|
68581
|
+
}
|
|
67899
68582
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
67900
68583
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
67901
68584
|
// When operator is === and type of value excludes undefined, null and undefined is removed from type of obj in true branch.
|
|
@@ -69659,9 +70342,9 @@ var ts;
|
|
|
69659
70342
|
return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName);
|
|
69660
70343
|
}
|
|
69661
70344
|
if (element.name) {
|
|
69662
|
-
var
|
|
70345
|
+
var nameType_2 = getLiteralTypeFromPropertyName(element.name);
|
|
69663
70346
|
// We avoid calling getApplicableIndexInfo here because it performs potentially expensive intersection reduction.
|
|
69664
|
-
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t),
|
|
70347
|
+
return mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType_2)) === null || _a === void 0 ? void 0 : _a.type; }, /*noReductions*/ true);
|
|
69665
70348
|
}
|
|
69666
70349
|
}
|
|
69667
70350
|
return undefined;
|
|
@@ -71375,6 +72058,36 @@ var ts;
|
|
|
71375
72058
|
}
|
|
71376
72059
|
}
|
|
71377
72060
|
}
|
|
72061
|
+
function checkGrammarPrivateIdentifierExpression(privId) {
|
|
72062
|
+
if (!ts.getContainingClass(privId)) {
|
|
72063
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
72064
|
+
}
|
|
72065
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72066
|
+
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);
|
|
72067
|
+
}
|
|
72068
|
+
if (!getSymbolForPrivateIdentifierExpression(privId)) {
|
|
72069
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId));
|
|
72070
|
+
}
|
|
72071
|
+
return false;
|
|
72072
|
+
}
|
|
72073
|
+
function checkPrivateIdentifierExpression(privId) {
|
|
72074
|
+
checkGrammarPrivateIdentifierExpression(privId);
|
|
72075
|
+
var symbol = getSymbolForPrivateIdentifierExpression(privId);
|
|
72076
|
+
if (symbol) {
|
|
72077
|
+
markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false);
|
|
72078
|
+
}
|
|
72079
|
+
return anyType;
|
|
72080
|
+
}
|
|
72081
|
+
function getSymbolForPrivateIdentifierExpression(privId) {
|
|
72082
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72083
|
+
return undefined;
|
|
72084
|
+
}
|
|
72085
|
+
var links = getNodeLinks(privId);
|
|
72086
|
+
if (links.resolvedSymbol === undefined) {
|
|
72087
|
+
links.resolvedSymbol = lookupSymbolForPrivateIdentifierDeclaration(privId.escapedText, privId);
|
|
72088
|
+
}
|
|
72089
|
+
return links.resolvedSymbol;
|
|
72090
|
+
}
|
|
71378
72091
|
function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
|
|
71379
72092
|
return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
|
|
71380
72093
|
}
|
|
@@ -71438,7 +72151,7 @@ var ts;
|
|
|
71438
72151
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
71439
72152
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
71440
72153
|
}
|
|
71441
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions
|
|
72154
|
+
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
71442
72155
|
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
71443
72156
|
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
71444
72157
|
if (n === lexicalClass_1)
|
|
@@ -74047,6 +74760,12 @@ var ts;
|
|
|
74047
74760
|
return getReturnTypeOfSignature(signature);
|
|
74048
74761
|
}
|
|
74049
74762
|
function checkAssertion(node) {
|
|
74763
|
+
if (node.kind === 210 /* TypeAssertionExpression */) {
|
|
74764
|
+
var file = ts.getSourceFileOfNode(node);
|
|
74765
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
74766
|
+
grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
74767
|
+
}
|
|
74768
|
+
}
|
|
74050
74769
|
return checkAssertionWorker(node, node.type, node.expression);
|
|
74051
74770
|
}
|
|
74052
74771
|
function isValidConstAssertionArgument(node) {
|
|
@@ -74145,7 +74864,14 @@ var ts;
|
|
|
74145
74864
|
}
|
|
74146
74865
|
function checkImportMetaProperty(node) {
|
|
74147
74866
|
if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
|
|
74148
|
-
|
|
74867
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74868
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74869
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74870
|
+
}
|
|
74871
|
+
}
|
|
74872
|
+
else {
|
|
74873
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74874
|
+
}
|
|
74149
74875
|
}
|
|
74150
74876
|
var file = ts.getSourceFileOfNode(node);
|
|
74151
74877
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
@@ -75089,9 +75815,9 @@ var ts;
|
|
|
75089
75815
|
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);
|
|
75090
75816
|
diagnostics.add(diagnostic);
|
|
75091
75817
|
}
|
|
75092
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
75818
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75093
75819
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
75094
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75820
|
+
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);
|
|
75095
75821
|
diagnostics.add(diagnostic);
|
|
75096
75822
|
}
|
|
75097
75823
|
}
|
|
@@ -75265,11 +75991,29 @@ var ts;
|
|
|
75265
75991
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75266
75992
|
return silentNeverType;
|
|
75267
75993
|
}
|
|
75268
|
-
|
|
75994
|
+
if (ts.isPrivateIdentifier(left)) {
|
|
75995
|
+
if (languageVersion < 99 /* ESNext */) {
|
|
75996
|
+
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
75997
|
+
}
|
|
75998
|
+
// Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type
|
|
75999
|
+
// which provides us with the opportunity to emit more detailed errors
|
|
76000
|
+
if (!getNodeLinks(left).resolvedSymbol && ts.getContainingClass(left)) {
|
|
76001
|
+
var isUncheckedJS = isUncheckedJSSuggestion(left, rightType.symbol, /*excludeClasses*/ true);
|
|
76002
|
+
reportNonexistentProperty(left, rightType, isUncheckedJS);
|
|
76003
|
+
}
|
|
76004
|
+
}
|
|
76005
|
+
else {
|
|
76006
|
+
leftType = checkNonNullType(leftType, left);
|
|
76007
|
+
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
76008
|
+
// Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
|
|
76009
|
+
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
76010
|
+
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
76011
|
+
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);
|
|
76012
|
+
}
|
|
76013
|
+
}
|
|
75269
76014
|
rightType = checkNonNullType(rightType, right);
|
|
75270
76015
|
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
75271
|
-
// The in operator requires the
|
|
75272
|
-
// and the right operand to be
|
|
76016
|
+
// The in operator requires the right operand to be
|
|
75273
76017
|
//
|
|
75274
76018
|
// 1. assignable to the non-primitive type,
|
|
75275
76019
|
// 2. an unconstrained type parameter,
|
|
@@ -75287,10 +76031,6 @@ var ts;
|
|
|
75287
76031
|
// unless *all* instantiations would result in an error.
|
|
75288
76032
|
//
|
|
75289
76033
|
// The result is always of the Boolean primitive type.
|
|
75290
|
-
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
75291
|
-
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
75292
|
-
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
|
75293
|
-
}
|
|
75294
76034
|
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
75295
76035
|
if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
75296
76036
|
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
@@ -76536,6 +77276,8 @@ var ts;
|
|
|
76536
77276
|
switch (kind) {
|
|
76537
77277
|
case 79 /* Identifier */:
|
|
76538
77278
|
return checkIdentifier(node, checkMode);
|
|
77279
|
+
case 80 /* PrivateIdentifier */:
|
|
77280
|
+
return checkPrivateIdentifierExpression(node);
|
|
76539
77281
|
case 108 /* ThisKeyword */:
|
|
76540
77282
|
return checkThisExpression(node);
|
|
76541
77283
|
case 106 /* SuperKeyword */:
|
|
@@ -77129,7 +77871,7 @@ var ts;
|
|
|
77129
77871
|
// - The containing class is a derived class.
|
|
77130
77872
|
// - The constructor declares parameter properties
|
|
77131
77873
|
// or the containing class declares instance member variables with initializers.
|
|
77132
|
-
var superCallShouldBeFirst = (compilerOptions
|
|
77874
|
+
var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
77133
77875
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
77134
77876
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
77135
77877
|
// Skip past any prologue directives to find the first statement
|
|
@@ -78873,7 +79615,7 @@ var ts;
|
|
|
78873
79615
|
}
|
|
78874
79616
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
78875
79617
|
// No need to check for require or exports for ES6 modules and later
|
|
78876
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
79618
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
78877
79619
|
return;
|
|
78878
79620
|
}
|
|
78879
79621
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -80434,8 +81176,8 @@ var ts;
|
|
|
80434
81176
|
* The name cannot be used as 'Object' of user defined types with special target.
|
|
80435
81177
|
*/
|
|
80436
81178
|
function checkClassNameCollisionWithObject(name) {
|
|
80437
|
-
if (languageVersion
|
|
80438
|
-
&& moduleKind < ts.ModuleKind.ES2015) {
|
|
81179
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object"
|
|
81180
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
80439
81181
|
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
|
|
80440
81182
|
}
|
|
80441
81183
|
}
|
|
@@ -81605,8 +82347,8 @@ var ts;
|
|
|
81605
82347
|
checkAliasSymbol(node);
|
|
81606
82348
|
if (node.kind === 269 /* ImportSpecifier */ &&
|
|
81607
82349
|
ts.idText(node.propertyName || node.name) === "default" &&
|
|
81608
|
-
compilerOptions
|
|
81609
|
-
moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82350
|
+
ts.getESModuleInterop(compilerOptions) &&
|
|
82351
|
+
moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81610
82352
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81611
82353
|
}
|
|
81612
82354
|
}
|
|
@@ -81638,7 +82380,7 @@ var ts;
|
|
|
81638
82380
|
if (importClause.namedBindings) {
|
|
81639
82381
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
81640
82382
|
checkImportBinding(importClause.namedBindings);
|
|
81641
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions
|
|
82383
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
|
|
81642
82384
|
// import * as ns from "foo";
|
|
81643
82385
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81644
82386
|
}
|
|
@@ -81684,7 +82426,7 @@ var ts;
|
|
|
81684
82426
|
}
|
|
81685
82427
|
}
|
|
81686
82428
|
else {
|
|
81687
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
82429
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
81688
82430
|
// Import equals declaration is deprecated in es6 or above
|
|
81689
82431
|
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);
|
|
81690
82432
|
}
|
|
@@ -81700,7 +82442,7 @@ var ts;
|
|
|
81700
82442
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
81701
82443
|
}
|
|
81702
82444
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
81703
|
-
checkExternalEmitHelpers(node,
|
|
82445
|
+
checkExternalEmitHelpers(node, 4194304 /* CreateBinding */);
|
|
81704
82446
|
}
|
|
81705
82447
|
checkGrammarExportDeclaration(node);
|
|
81706
82448
|
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
|
|
@@ -81725,12 +82467,12 @@ var ts;
|
|
|
81725
82467
|
else if (node.exportClause) {
|
|
81726
82468
|
checkAliasSymbol(node.exportClause);
|
|
81727
82469
|
}
|
|
81728
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82470
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81729
82471
|
if (node.exportClause) {
|
|
81730
82472
|
// export * as ns from "foo";
|
|
81731
82473
|
// 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.
|
|
81732
82474
|
// We only use the helper here when in esModuleInterop
|
|
81733
|
-
if (compilerOptions
|
|
82475
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
81734
82476
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81735
82477
|
}
|
|
81736
82478
|
}
|
|
@@ -81745,11 +82487,15 @@ var ts;
|
|
|
81745
82487
|
}
|
|
81746
82488
|
function checkGrammarExportDeclaration(node) {
|
|
81747
82489
|
var _a;
|
|
81748
|
-
|
|
81749
|
-
|
|
81750
|
-
|
|
82490
|
+
if (node.isTypeOnly) {
|
|
82491
|
+
if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 272 /* NamedExports */) {
|
|
82492
|
+
return checkGrammarNamedImportsOrExports(node.exportClause);
|
|
82493
|
+
}
|
|
82494
|
+
else {
|
|
82495
|
+
return grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
|
|
82496
|
+
}
|
|
81751
82497
|
}
|
|
81752
|
-
return
|
|
82498
|
+
return false;
|
|
81753
82499
|
}
|
|
81754
82500
|
function checkGrammarModuleElementContext(node, errorMessage) {
|
|
81755
82501
|
var isInAppropriateContext = node.parent.kind === 303 /* SourceFile */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 260 /* ModuleDeclaration */;
|
|
@@ -81814,9 +82560,9 @@ var ts;
|
|
|
81814
82560
|
}
|
|
81815
82561
|
}
|
|
81816
82562
|
else {
|
|
81817
|
-
if (compilerOptions
|
|
82563
|
+
if (ts.getESModuleInterop(compilerOptions) &&
|
|
81818
82564
|
moduleKind !== ts.ModuleKind.System &&
|
|
81819
|
-
moduleKind < ts.ModuleKind.ES2015 &&
|
|
82565
|
+
(moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) &&
|
|
81820
82566
|
ts.idText(node.propertyName || node.name) === "default") {
|
|
81821
82567
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81822
82568
|
}
|
|
@@ -81875,7 +82621,7 @@ var ts;
|
|
|
81875
82621
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
81876
82622
|
}
|
|
81877
82623
|
if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
|
|
81878
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
82624
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
81879
82625
|
// export assignment is not supported in es6 modules
|
|
81880
82626
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
81881
82627
|
}
|
|
@@ -82669,6 +83415,9 @@ var ts;
|
|
|
82669
83415
|
}
|
|
82670
83416
|
return result;
|
|
82671
83417
|
}
|
|
83418
|
+
else if (ts.isPrivateIdentifier(name)) {
|
|
83419
|
+
return getSymbolForPrivateIdentifierExpression(name);
|
|
83420
|
+
}
|
|
82672
83421
|
else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) {
|
|
82673
83422
|
var links = getNodeLinks(name);
|
|
82674
83423
|
if (links.resolvedSymbol) {
|
|
@@ -83929,7 +84678,7 @@ var ts;
|
|
|
83929
84678
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
83930
84679
|
if (helpersModule !== unknownSymbol) {
|
|
83931
84680
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
83932
|
-
for (var helper = 1 /* FirstEmitHelper */; helper <=
|
|
84681
|
+
for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) {
|
|
83933
84682
|
if (uncheckedHelpers & helper) {
|
|
83934
84683
|
var name = getHelperName(helper);
|
|
83935
84684
|
var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */);
|
|
@@ -83981,7 +84730,8 @@ var ts;
|
|
|
83981
84730
|
case 262144 /* MakeTemplateObject */: return "__makeTemplateObject";
|
|
83982
84731
|
case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet";
|
|
83983
84732
|
case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet";
|
|
83984
|
-
case 2097152 /*
|
|
84733
|
+
case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn";
|
|
84734
|
+
case 4194304 /* CreateBinding */: return "__createBinding";
|
|
83985
84735
|
default: return ts.Debug.fail("Unrecognized helper");
|
|
83986
84736
|
}
|
|
83987
84737
|
}
|
|
@@ -84413,6 +85163,11 @@ var ts;
|
|
|
84413
85163
|
if (!ts.isArrowFunction(node)) {
|
|
84414
85164
|
return false;
|
|
84415
85165
|
}
|
|
85166
|
+
if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
|
|
85167
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) {
|
|
85168
|
+
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);
|
|
85169
|
+
}
|
|
85170
|
+
}
|
|
84416
85171
|
var equalsGreaterThanToken = node.equalsGreaterThanToken;
|
|
84417
85172
|
var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
|
|
84418
85173
|
var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
|
|
@@ -84745,8 +85500,8 @@ var ts;
|
|
|
84745
85500
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
84746
85501
|
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));
|
|
84747
85502
|
}
|
|
84748
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
84749
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85503
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85504
|
+
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));
|
|
84750
85505
|
}
|
|
84751
85506
|
}
|
|
84752
85507
|
}
|
|
@@ -85087,8 +85842,7 @@ var ts;
|
|
|
85087
85842
|
: ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
|
85088
85843
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
85089
85844
|
}
|
|
85090
|
-
|
|
85091
|
-
if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
|
|
85845
|
+
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
85092
85846
|
!(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
85093
85847
|
checkESModuleMarker(node.name);
|
|
85094
85848
|
}
|
|
@@ -85416,14 +86170,27 @@ var ts;
|
|
|
85416
86170
|
return ambientModulesCache;
|
|
85417
86171
|
}
|
|
85418
86172
|
function checkGrammarImportClause(node) {
|
|
86173
|
+
var _a;
|
|
85419
86174
|
if (node.isTypeOnly && node.name && node.namedBindings) {
|
|
85420
86175
|
return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
|
|
85421
86176
|
}
|
|
86177
|
+
if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamedImports */) {
|
|
86178
|
+
return checkGrammarNamedImportsOrExports(node.namedBindings);
|
|
86179
|
+
}
|
|
85422
86180
|
return false;
|
|
85423
86181
|
}
|
|
86182
|
+
function checkGrammarNamedImportsOrExports(namedBindings) {
|
|
86183
|
+
return !!ts.forEach(namedBindings.elements, function (specifier) {
|
|
86184
|
+
if (specifier.isTypeOnly) {
|
|
86185
|
+
return grammarErrorOnFirstToken(specifier, specifier.kind === 269 /* ImportSpecifier */
|
|
86186
|
+
? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement
|
|
86187
|
+
: ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement);
|
|
86188
|
+
}
|
|
86189
|
+
});
|
|
86190
|
+
}
|
|
85424
86191
|
function checkGrammarImportCallExpression(node) {
|
|
85425
86192
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
85426
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
86193
|
+
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);
|
|
85427
86194
|
}
|
|
85428
86195
|
if (node.typeArguments) {
|
|
85429
86196
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -86152,7 +86919,7 @@ var ts;
|
|
|
86152
86919
|
return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
|
|
86153
86920
|
case 269 /* ImportSpecifier */:
|
|
86154
86921
|
ts.Debug.type(node);
|
|
86155
|
-
return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86922
|
+
return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86156
86923
|
case 270 /* ExportAssignment */:
|
|
86157
86924
|
ts.Debug.type(node);
|
|
86158
86925
|
return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -86164,7 +86931,7 @@ var ts;
|
|
|
86164
86931
|
return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
|
|
86165
86932
|
case 274 /* ExportSpecifier */:
|
|
86166
86933
|
ts.Debug.type(node);
|
|
86167
|
-
return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86934
|
+
return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
|
|
86168
86935
|
// Module references
|
|
86169
86936
|
case 276 /* ExternalModuleReference */:
|
|
86170
86937
|
ts.Debug.type(node);
|
|
@@ -90105,9 +90872,11 @@ var ts;
|
|
|
90105
90872
|
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90106
90873
|
}
|
|
90107
90874
|
else {
|
|
90108
|
-
// Elide named imports if all of its import specifiers are elided.
|
|
90875
|
+
// Elide named imports if all of its import specifiers are elided and settings allow.
|
|
90876
|
+
var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
90877
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
90109
90878
|
var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
|
|
90110
|
-
return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
90879
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
|
|
90111
90880
|
}
|
|
90112
90881
|
}
|
|
90113
90882
|
/**
|
|
@@ -90116,7 +90885,7 @@ var ts;
|
|
|
90116
90885
|
* @param node The import specifier node.
|
|
90117
90886
|
*/
|
|
90118
90887
|
function visitImportSpecifier(node) {
|
|
90119
|
-
return shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90888
|
+
return !node.isTypeOnly && shouldEmitAliasDeclaration(node) ? node : undefined;
|
|
90120
90889
|
}
|
|
90121
90890
|
/**
|
|
90122
90891
|
* Visits an export assignment, eliding it if it does not contain a clause that resolves
|
|
@@ -90145,12 +90914,10 @@ var ts;
|
|
|
90145
90914
|
// type checker doesn't know about any exports
|
|
90146
90915
|
return node;
|
|
90147
90916
|
}
|
|
90148
|
-
if (!resolver.isValueAliasDeclaration(node)) {
|
|
90149
|
-
// Elide the export declaration if it does not export a value.
|
|
90150
|
-
return undefined;
|
|
90151
|
-
}
|
|
90152
90917
|
// Elide the export declaration if all of its named exports are elided.
|
|
90153
|
-
var
|
|
90918
|
+
var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ ||
|
|
90919
|
+
compilerOptions.importsNotUsedAsValues === 2 /* Error */);
|
|
90920
|
+
var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings);
|
|
90154
90921
|
return exportClause
|
|
90155
90922
|
? factory.updateExportDeclaration(node,
|
|
90156
90923
|
/*decorators*/ undefined,
|
|
@@ -90163,16 +90930,16 @@ var ts;
|
|
|
90163
90930
|
*
|
|
90164
90931
|
* @param node The named exports node.
|
|
90165
90932
|
*/
|
|
90166
|
-
function visitNamedExports(node) {
|
|
90933
|
+
function visitNamedExports(node, allowEmpty) {
|
|
90167
90934
|
// Elide the named exports if all of its export specifiers were elided.
|
|
90168
90935
|
var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
|
|
90169
|
-
return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
90936
|
+
return allowEmpty || ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
|
|
90170
90937
|
}
|
|
90171
90938
|
function visitNamespaceExports(node) {
|
|
90172
90939
|
return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
|
|
90173
90940
|
}
|
|
90174
|
-
function visitNamedExportBindings(node) {
|
|
90175
|
-
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
|
|
90941
|
+
function visitNamedExportBindings(node, allowEmpty) {
|
|
90942
|
+
return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node, allowEmpty);
|
|
90176
90943
|
}
|
|
90177
90944
|
/**
|
|
90178
90945
|
* Visits an export specifier, eliding it if it does not resolve to a value.
|
|
@@ -90181,7 +90948,7 @@ var ts;
|
|
|
90181
90948
|
*/
|
|
90182
90949
|
function visitExportSpecifier(node) {
|
|
90183
90950
|
// Elide an export specifier if it does not reference a value.
|
|
90184
|
-
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
90951
|
+
return !node.isTypeOnly && resolver.isValueAliasDeclaration(node) ? node : undefined;
|
|
90185
90952
|
}
|
|
90186
90953
|
/**
|
|
90187
90954
|
* Determines whether to emit an import equals declaration.
|
|
@@ -90583,7 +91350,7 @@ var ts;
|
|
|
90583
91350
|
function transformSourceFile(node) {
|
|
90584
91351
|
var options = context.getCompilerOptions();
|
|
90585
91352
|
if (node.isDeclarationFile
|
|
90586
|
-
|| useDefineForClassFields && options
|
|
91353
|
+
|| useDefineForClassFields && ts.getEmitScriptTarget(options) === 99 /* ESNext */) {
|
|
90587
91354
|
return node;
|
|
90588
91355
|
}
|
|
90589
91356
|
var visited = ts.visitEachChild(node, visitor, context);
|
|
@@ -90671,14 +91438,37 @@ var ts;
|
|
|
90671
91438
|
}
|
|
90672
91439
|
/**
|
|
90673
91440
|
* If we visit a private name, this means it is an undeclared private name.
|
|
90674
|
-
* Replace it with an empty identifier to indicate a problem with the code
|
|
91441
|
+
* Replace it with an empty identifier to indicate a problem with the code,
|
|
91442
|
+
* unless we are in a statement position - otherwise this will not trigger
|
|
91443
|
+
* a SyntaxError.
|
|
90675
91444
|
*/
|
|
90676
91445
|
function visitPrivateIdentifier(node) {
|
|
90677
91446
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
90678
91447
|
return node;
|
|
90679
91448
|
}
|
|
91449
|
+
if (ts.isStatement(node.parent)) {
|
|
91450
|
+
return node;
|
|
91451
|
+
}
|
|
90680
91452
|
return ts.setOriginalNode(factory.createIdentifier(""), node);
|
|
90681
91453
|
}
|
|
91454
|
+
/**
|
|
91455
|
+
* Visits `#id in expr`
|
|
91456
|
+
*/
|
|
91457
|
+
function visitPrivateIdentifierInInExpression(node) {
|
|
91458
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
91459
|
+
return node;
|
|
91460
|
+
}
|
|
91461
|
+
var privId = node.left;
|
|
91462
|
+
ts.Debug.assertNode(privId, ts.isPrivateIdentifier);
|
|
91463
|
+
ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */);
|
|
91464
|
+
var info = accessPrivateIdentifier(privId);
|
|
91465
|
+
if (info) {
|
|
91466
|
+
var receiver = ts.visitNode(node.right, visitor, ts.isExpression);
|
|
91467
|
+
return ts.setOriginalNode(context.getEmitHelperFactory().createClassPrivateFieldInHelper(info.brandCheckIdentifier, receiver), node);
|
|
91468
|
+
}
|
|
91469
|
+
// Private name has not been declared. Subsequent transformers will handle this error
|
|
91470
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91471
|
+
}
|
|
90682
91472
|
/**
|
|
90683
91473
|
* Visits the members of a class that has fields.
|
|
90684
91474
|
*
|
|
@@ -91065,6 +91855,9 @@ var ts;
|
|
|
91065
91855
|
}
|
|
91066
91856
|
}
|
|
91067
91857
|
}
|
|
91858
|
+
if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
|
|
91859
|
+
return visitPrivateIdentifierInInExpression(node);
|
|
91860
|
+
}
|
|
91068
91861
|
return ts.visitEachChild(node, visitor, context);
|
|
91069
91862
|
}
|
|
91070
91863
|
function createPrivateIdentifierAssignment(info, receiver, right, operator) {
|
|
@@ -93756,7 +94549,7 @@ var ts;
|
|
|
93756
94549
|
currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
|
|
93757
94550
|
}
|
|
93758
94551
|
var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */);
|
|
93759
|
-
var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
|
|
94552
|
+
var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName);
|
|
93760
94553
|
generatedName.generatedImportReference = specifier;
|
|
93761
94554
|
specifierSourceImports.set(name, specifier);
|
|
93762
94555
|
return generatedName;
|
|
@@ -93959,7 +94752,7 @@ var ts;
|
|
|
93959
94752
|
// When there are no attributes, React wants "null"
|
|
93960
94753
|
}
|
|
93961
94754
|
else {
|
|
93962
|
-
var target = compilerOptions
|
|
94755
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
93963
94756
|
if (target && target >= 5 /* ES2018 */) {
|
|
93964
94757
|
objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
93965
94758
|
return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
|
|
@@ -94158,7 +94951,8 @@ var ts;
|
|
|
94158
94951
|
}
|
|
94159
94952
|
}
|
|
94160
94953
|
function visitJsxExpression(node) {
|
|
94161
|
-
|
|
94954
|
+
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
94955
|
+
return node.dotDotDotToken ? factory.createSpreadElement(expression) : expression;
|
|
94162
94956
|
}
|
|
94163
94957
|
}
|
|
94164
94958
|
ts.transformJsx = transformJsx;
|
|
@@ -100794,7 +101588,7 @@ var ts;
|
|
|
100794
101588
|
case 348 /* PartiallyEmittedExpression */:
|
|
100795
101589
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
100796
101590
|
case 207 /* CallExpression */:
|
|
100797
|
-
if (ts.isImportCall(node)) {
|
|
101591
|
+
if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
|
|
100798
101592
|
return visitImportCallExpression(node);
|
|
100799
101593
|
}
|
|
100800
101594
|
break;
|
|
@@ -101017,7 +101811,7 @@ var ts;
|
|
|
101017
101811
|
}
|
|
101018
101812
|
}
|
|
101019
101813
|
var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
|
101020
|
-
if (compilerOptions
|
|
101814
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
101021
101815
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
|
|
101022
101816
|
}
|
|
101023
101817
|
return promise;
|
|
@@ -101030,7 +101824,7 @@ var ts;
|
|
|
101030
101824
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
101031
101825
|
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
|
101032
101826
|
var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
|
101033
|
-
if (compilerOptions
|
|
101827
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
101034
101828
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
101035
101829
|
}
|
|
101036
101830
|
var func;
|
|
@@ -101060,7 +101854,7 @@ var ts;
|
|
|
101060
101854
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
101061
101855
|
}
|
|
101062
101856
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
101063
|
-
if (!compilerOptions
|
|
101857
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101064
101858
|
return innerExpr;
|
|
101065
101859
|
}
|
|
101066
101860
|
if (ts.getExportNeedsImportStarHelper(node)) {
|
|
@@ -101069,7 +101863,7 @@ var ts;
|
|
|
101069
101863
|
return innerExpr;
|
|
101070
101864
|
}
|
|
101071
101865
|
function getHelperExpressionForImport(node, innerExpr) {
|
|
101072
|
-
if (!compilerOptions
|
|
101866
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101073
101867
|
return innerExpr;
|
|
101074
101868
|
}
|
|
101075
101869
|
if (ts.getImportNeedsImportStarHelper(node)) {
|
|
@@ -101223,7 +102017,7 @@ var ts;
|
|
|
101223
102017
|
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));
|
|
101224
102018
|
}
|
|
101225
102019
|
else {
|
|
101226
|
-
var exportNeedsImportDefault = !!compilerOptions
|
|
102020
|
+
var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) &&
|
|
101227
102021
|
!(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) &&
|
|
101228
102022
|
ts.idText(specifier.propertyName || specifier.name) === "default";
|
|
101229
102023
|
var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
|
|
@@ -103392,7 +104186,10 @@ var ts;
|
|
|
103392
104186
|
(function (ts) {
|
|
103393
104187
|
function transformECMAScriptModule(context) {
|
|
103394
104188
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
|
|
104189
|
+
var host = context.getEmitHost();
|
|
104190
|
+
var resolver = context.getEmitResolver();
|
|
103395
104191
|
var compilerOptions = context.getCompilerOptions();
|
|
104192
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
103396
104193
|
var previousOnEmitNode = context.onEmitNode;
|
|
103397
104194
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
103398
104195
|
context.onEmitNode = onEmitNode;
|
|
@@ -103400,13 +104197,21 @@ var ts;
|
|
|
103400
104197
|
context.enableEmitNotification(303 /* SourceFile */);
|
|
103401
104198
|
context.enableSubstitution(79 /* Identifier */);
|
|
103402
104199
|
var helperNameSubstitutions;
|
|
104200
|
+
var currentSourceFile;
|
|
104201
|
+
var importRequireStatements;
|
|
103403
104202
|
return ts.chainBundle(context, transformSourceFile);
|
|
103404
104203
|
function transformSourceFile(node) {
|
|
103405
104204
|
if (node.isDeclarationFile) {
|
|
103406
104205
|
return node;
|
|
103407
104206
|
}
|
|
103408
104207
|
if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
|
|
104208
|
+
currentSourceFile = node;
|
|
104209
|
+
importRequireStatements = undefined;
|
|
103409
104210
|
var result = updateExternalModule(node);
|
|
104211
|
+
currentSourceFile = undefined;
|
|
104212
|
+
if (importRequireStatements) {
|
|
104213
|
+
result = factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(ts.insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements));
|
|
104214
|
+
}
|
|
103410
104215
|
if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
|
|
103411
104216
|
return result;
|
|
103412
104217
|
}
|
|
@@ -103430,8 +104235,10 @@ var ts;
|
|
|
103430
104235
|
function visitor(node) {
|
|
103431
104236
|
switch (node.kind) {
|
|
103432
104237
|
case 264 /* ImportEqualsDeclaration */:
|
|
103433
|
-
//
|
|
103434
|
-
|
|
104238
|
+
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
104239
|
+
// 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`
|
|
104240
|
+
// is available, just because the output is reasonable for a node-like runtime.
|
|
104241
|
+
return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
|
|
103435
104242
|
case 270 /* ExportAssignment */:
|
|
103436
104243
|
return visitExportAssignment(node);
|
|
103437
104244
|
case 271 /* ExportDeclaration */:
|
|
@@ -103440,6 +104247,68 @@ var ts;
|
|
|
103440
104247
|
}
|
|
103441
104248
|
return node;
|
|
103442
104249
|
}
|
|
104250
|
+
/**
|
|
104251
|
+
* Creates a `require()` call to import an external module.
|
|
104252
|
+
*
|
|
104253
|
+
* @param importNode The declaration to import.
|
|
104254
|
+
*/
|
|
104255
|
+
function createRequireCall(importNode) {
|
|
104256
|
+
var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, ts.Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
|
|
104257
|
+
var args = [];
|
|
104258
|
+
if (moduleName) {
|
|
104259
|
+
args.push(moduleName);
|
|
104260
|
+
}
|
|
104261
|
+
if (!importRequireStatements) {
|
|
104262
|
+
var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104263
|
+
var importStatement = factory.createImportDeclaration(
|
|
104264
|
+
/*decorators*/ undefined,
|
|
104265
|
+
/*modifiers*/ undefined, factory.createImportClause(
|
|
104266
|
+
/*isTypeOnly*/ false,
|
|
104267
|
+
/*name*/ undefined, factory.createNamedImports([
|
|
104268
|
+
factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName)
|
|
104269
|
+
])), factory.createStringLiteral("module"));
|
|
104270
|
+
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104271
|
+
var requireStatement = factory.createVariableStatement(
|
|
104272
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104273
|
+
factory.createVariableDeclaration(requireHelperName,
|
|
104274
|
+
/*exclamationToken*/ undefined,
|
|
104275
|
+
/*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
|
|
104276
|
+
factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
|
|
104277
|
+
]))
|
|
104278
|
+
],
|
|
104279
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */));
|
|
104280
|
+
importRequireStatements = [importStatement, requireStatement];
|
|
104281
|
+
}
|
|
104282
|
+
var name = importRequireStatements[1].declarationList.declarations[0].name;
|
|
104283
|
+
ts.Debug.assertNode(name, ts.isIdentifier);
|
|
104284
|
+
return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args);
|
|
104285
|
+
}
|
|
104286
|
+
/**
|
|
104287
|
+
* Visits an ImportEqualsDeclaration node.
|
|
104288
|
+
*
|
|
104289
|
+
* @param node The node to visit.
|
|
104290
|
+
*/
|
|
104291
|
+
function visitImportEqualsDeclaration(node) {
|
|
104292
|
+
ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
|
|
104293
|
+
var statements;
|
|
104294
|
+
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(
|
|
104295
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104296
|
+
factory.createVariableDeclaration(factory.cloneNode(node.name),
|
|
104297
|
+
/*exclamationToken*/ undefined,
|
|
104298
|
+
/*type*/ undefined, createRequireCall(node))
|
|
104299
|
+
],
|
|
104300
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
|
|
104301
|
+
statements = appendExportsOfImportEqualsDeclaration(statements, node);
|
|
104302
|
+
return ts.singleOrMany(statements);
|
|
104303
|
+
}
|
|
104304
|
+
function appendExportsOfImportEqualsDeclaration(statements, node) {
|
|
104305
|
+
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
104306
|
+
statements = ts.append(statements, factory.createExportDeclaration(
|
|
104307
|
+
/*decorators*/ undefined,
|
|
104308
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104309
|
+
}
|
|
104310
|
+
return statements;
|
|
104311
|
+
}
|
|
103443
104312
|
function visitExportAssignment(node) {
|
|
103444
104313
|
// Elide `export=` as it is not legal with --module ES6
|
|
103445
104314
|
return node.isExportEquals ? undefined : node;
|
|
@@ -103464,7 +104333,7 @@ var ts;
|
|
|
103464
104333
|
var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(
|
|
103465
104334
|
/*decorators*/ undefined,
|
|
103466
104335
|
/*modifiers*/ undefined,
|
|
103467
|
-
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
|
|
104336
|
+
/*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, synthName, oldIdentifier)]));
|
|
103468
104337
|
ts.setOriginalNode(exportDecl, node);
|
|
103469
104338
|
return [importDecl, exportDecl];
|
|
103470
104339
|
}
|
|
@@ -103517,6 +104386,78 @@ var ts;
|
|
|
103517
104386
|
}
|
|
103518
104387
|
ts.transformECMAScriptModule = transformECMAScriptModule;
|
|
103519
104388
|
})(ts || (ts = {}));
|
|
104389
|
+
/*@internal*/
|
|
104390
|
+
var ts;
|
|
104391
|
+
(function (ts) {
|
|
104392
|
+
function transformNodeModule(context) {
|
|
104393
|
+
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
104394
|
+
var previousOnEmitNode = context.onEmitNode;
|
|
104395
|
+
var esmTransform = ts.transformECMAScriptModule(context);
|
|
104396
|
+
var esmOnSubstituteNode = context.onSubstituteNode;
|
|
104397
|
+
var esmOnEmitNode = context.onEmitNode;
|
|
104398
|
+
context.onSubstituteNode = previousOnSubstituteNode;
|
|
104399
|
+
context.onEmitNode = previousOnEmitNode;
|
|
104400
|
+
var cjsTransform = ts.transformModule(context);
|
|
104401
|
+
var cjsOnSubstituteNode = context.onSubstituteNode;
|
|
104402
|
+
var cjsOnEmitNode = context.onEmitNode;
|
|
104403
|
+
context.onSubstituteNode = onSubstituteNode;
|
|
104404
|
+
context.onEmitNode = onEmitNode;
|
|
104405
|
+
context.enableSubstitution(303 /* SourceFile */);
|
|
104406
|
+
context.enableEmitNotification(303 /* SourceFile */);
|
|
104407
|
+
var currentSourceFile;
|
|
104408
|
+
return transformSourceFileOrBundle;
|
|
104409
|
+
function onSubstituteNode(hint, node) {
|
|
104410
|
+
if (ts.isSourceFile(node)) {
|
|
104411
|
+
currentSourceFile = node;
|
|
104412
|
+
// Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on
|
|
104413
|
+
// the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute
|
|
104414
|
+
// functions on source files safely, as that context only gets setup in a later pipeline phase!)
|
|
104415
|
+
return previousOnSubstituteNode(hint, node);
|
|
104416
|
+
}
|
|
104417
|
+
else {
|
|
104418
|
+
if (!currentSourceFile) {
|
|
104419
|
+
return previousOnSubstituteNode(hint, node);
|
|
104420
|
+
}
|
|
104421
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104422
|
+
return esmOnSubstituteNode(hint, node);
|
|
104423
|
+
}
|
|
104424
|
+
return cjsOnSubstituteNode(hint, node);
|
|
104425
|
+
}
|
|
104426
|
+
}
|
|
104427
|
+
function onEmitNode(hint, node, emitCallback) {
|
|
104428
|
+
if (ts.isSourceFile(node)) {
|
|
104429
|
+
currentSourceFile = node;
|
|
104430
|
+
}
|
|
104431
|
+
if (!currentSourceFile) {
|
|
104432
|
+
return previousOnEmitNode(hint, node, emitCallback);
|
|
104433
|
+
}
|
|
104434
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104435
|
+
return esmOnEmitNode(hint, node, emitCallback);
|
|
104436
|
+
}
|
|
104437
|
+
return cjsOnEmitNode(hint, node, emitCallback);
|
|
104438
|
+
}
|
|
104439
|
+
function getModuleTransformForFile(file) {
|
|
104440
|
+
return file.impliedNodeFormat === ts.ModuleKind.ESNext ? esmTransform : cjsTransform;
|
|
104441
|
+
}
|
|
104442
|
+
function transformSourceFile(node) {
|
|
104443
|
+
if (node.isDeclarationFile) {
|
|
104444
|
+
return node;
|
|
104445
|
+
}
|
|
104446
|
+
currentSourceFile = node;
|
|
104447
|
+
var result = getModuleTransformForFile(node)(node);
|
|
104448
|
+
currentSourceFile = undefined;
|
|
104449
|
+
ts.Debug.assert(ts.isSourceFile(result));
|
|
104450
|
+
return result;
|
|
104451
|
+
}
|
|
104452
|
+
function transformSourceFileOrBundle(node) {
|
|
104453
|
+
return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
|
|
104454
|
+
}
|
|
104455
|
+
function transformBundle(node) {
|
|
104456
|
+
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
|
|
104457
|
+
}
|
|
104458
|
+
}
|
|
104459
|
+
ts.transformNodeModule = transformNodeModule;
|
|
104460
|
+
})(ts || (ts = {}));
|
|
103520
104461
|
/* @internal */
|
|
103521
104462
|
var ts;
|
|
103522
104463
|
(function (ts) {
|
|
@@ -104959,7 +105900,7 @@ var ts;
|
|
|
104959
105900
|
/*modifiers*/ undefined,
|
|
104960
105901
|
/*isTypeOnly*/ false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
|
|
104961
105902
|
var gen = _a[0], exp = _a[1];
|
|
104962
|
-
return factory.createExportSpecifier(gen, exp);
|
|
105903
|
+
return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp);
|
|
104963
105904
|
}))));
|
|
104964
105905
|
}
|
|
104965
105906
|
var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */);
|
|
@@ -105338,6 +106279,9 @@ var ts;
|
|
|
105338
106279
|
return ts.transformECMAScriptModule;
|
|
105339
106280
|
case ts.ModuleKind.System:
|
|
105340
106281
|
return ts.transformSystemModule;
|
|
106282
|
+
case ts.ModuleKind.Node12:
|
|
106283
|
+
case ts.ModuleKind.NodeNext:
|
|
106284
|
+
return ts.transformNodeModule;
|
|
105341
106285
|
default:
|
|
105342
106286
|
return ts.transformModule;
|
|
105343
106287
|
}
|
|
@@ -105948,7 +106892,7 @@ var ts;
|
|
|
105948
106892
|
return getOutputPathsForBundle(options, forceDtsPaths);
|
|
105949
106893
|
}
|
|
105950
106894
|
else {
|
|
105951
|
-
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
|
|
106895
|
+
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options));
|
|
105952
106896
|
var isJsonFile = ts.isJsonSourceFile(sourceFile);
|
|
105953
106897
|
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
|
|
105954
106898
|
var isJsonEmittedToSameLocation = isJsonFile &&
|
|
@@ -105964,26 +106908,13 @@ var ts;
|
|
|
105964
106908
|
function getSourceMapFilePath(jsFilePath, options) {
|
|
105965
106909
|
return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
|
|
105966
106910
|
}
|
|
105967
|
-
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
|
|
105968
|
-
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
|
|
105969
|
-
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
|
|
105970
106911
|
/* @internal */
|
|
105971
|
-
function getOutputExtension(
|
|
105972
|
-
|
|
105973
|
-
|
|
105974
|
-
|
|
105975
|
-
|
|
105976
|
-
|
|
105977
|
-
if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) {
|
|
105978
|
-
return ".jsx" /* Jsx */;
|
|
105979
|
-
}
|
|
105980
|
-
}
|
|
105981
|
-
else if (sourceFile.languageVariant === 1 /* JSX */) {
|
|
105982
|
-
// TypeScript source file preserving JSX syntax
|
|
105983
|
-
return ".jsx" /* Jsx */;
|
|
105984
|
-
}
|
|
105985
|
-
}
|
|
105986
|
-
return ".js" /* Js */;
|
|
106912
|
+
function getOutputExtension(fileName, options) {
|
|
106913
|
+
return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ :
|
|
106914
|
+
options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ :
|
|
106915
|
+
ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ :
|
|
106916
|
+
ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ :
|
|
106917
|
+
".js" /* Js */;
|
|
105987
106918
|
}
|
|
105988
106919
|
ts.getOutputExtension = getOutputExtension;
|
|
105989
106920
|
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
|
|
@@ -105993,19 +106924,14 @@ var ts;
|
|
|
105993
106924
|
}
|
|
105994
106925
|
/* @internal */
|
|
105995
106926
|
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
105996
|
-
ts.
|
|
105997
|
-
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts" /* Dts */);
|
|
106927
|
+
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ts.getDeclarationEmitExtensionForPath(inputFileName));
|
|
105998
106928
|
}
|
|
105999
106929
|
ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
|
|
106000
106930
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
106001
106931
|
if (configFile.options.emitDeclarationOnly)
|
|
106002
106932
|
return undefined;
|
|
106003
106933
|
var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
106004
|
-
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory),
|
|
106005
|
-
".json" /* Json */ :
|
|
106006
|
-
configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ?
|
|
106007
|
-
".jsx" /* Jsx */ :
|
|
106008
|
-
".js" /* Js */);
|
|
106934
|
+
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options));
|
|
106009
106935
|
return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
|
|
106010
106936
|
outputFileName :
|
|
106011
106937
|
undefined;
|
|
@@ -106076,7 +107002,7 @@ var ts;
|
|
|
106076
107002
|
/*@internal*/
|
|
106077
107003
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
106078
107004
|
var options = _a.options, fileNames = _a.fileNames;
|
|
106079
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.
|
|
107005
|
+
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));
|
|
106080
107006
|
}
|
|
106081
107007
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
106082
107008
|
/*@internal*/
|
|
@@ -107353,6 +108279,8 @@ var ts;
|
|
|
107353
108279
|
// Identifiers
|
|
107354
108280
|
case 79 /* Identifier */:
|
|
107355
108281
|
return emitIdentifier(node);
|
|
108282
|
+
case 80 /* PrivateIdentifier */:
|
|
108283
|
+
return emitPrivateIdentifier(node);
|
|
107356
108284
|
// Expressions
|
|
107357
108285
|
case 203 /* ArrayLiteralExpression */:
|
|
107358
108286
|
return emitArrayLiteralExpression(node);
|
|
@@ -108911,6 +109839,10 @@ var ts;
|
|
|
108911
109839
|
writePunctuation("}");
|
|
108912
109840
|
}
|
|
108913
109841
|
function emitImportOrExportSpecifier(node) {
|
|
109842
|
+
if (node.isTypeOnly) {
|
|
109843
|
+
writeKeyword("type");
|
|
109844
|
+
writeSpace();
|
|
109845
|
+
}
|
|
108914
109846
|
if (node.propertyName) {
|
|
108915
109847
|
emit(node.propertyName);
|
|
108916
109848
|
writeSpace();
|
|
@@ -111339,7 +112271,7 @@ var ts;
|
|
|
111339
112271
|
if (options.declarationDir)
|
|
111340
112272
|
return false;
|
|
111341
112273
|
}
|
|
111342
|
-
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.
|
|
112274
|
+
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensionsFlat)) {
|
|
111343
112275
|
return false;
|
|
111344
112276
|
}
|
|
111345
112277
|
// just check if sourceFile with the name exists
|
|
@@ -111951,6 +112883,56 @@ var ts;
|
|
|
111951
112883
|
return resolutions;
|
|
111952
112884
|
}
|
|
111953
112885
|
ts.loadWithLocalCache = loadWithLocalCache;
|
|
112886
|
+
;
|
|
112887
|
+
/* @internal */
|
|
112888
|
+
function getModeForResolutionAtIndex(file, index) {
|
|
112889
|
+
if (file.impliedNodeFormat === undefined)
|
|
112890
|
+
return undefined;
|
|
112891
|
+
// we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
|
|
112892
|
+
// so it's safe to use them even pre-bind
|
|
112893
|
+
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
|
112894
|
+
}
|
|
112895
|
+
ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex;
|
|
112896
|
+
/* @internal */
|
|
112897
|
+
function getModeForUsageLocation(file, usage) {
|
|
112898
|
+
var _a;
|
|
112899
|
+
if (file.impliedNodeFormat === undefined)
|
|
112900
|
+
return undefined;
|
|
112901
|
+
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
112902
|
+
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
|
112903
|
+
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112904
|
+
}
|
|
112905
|
+
// in esm files, import=require statements are cjs format, otherwise everything is esm
|
|
112906
|
+
// imports are only parent'd up to their containing declaration/expression, so access farther parents with care
|
|
112907
|
+
var exprParentParent = (_a = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _a === void 0 ? void 0 : _a.parent;
|
|
112908
|
+
return exprParentParent && ts.isImportEqualsDeclaration(exprParentParent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
|
|
112909
|
+
}
|
|
112910
|
+
ts.getModeForUsageLocation = getModeForUsageLocation;
|
|
112911
|
+
/* @internal */
|
|
112912
|
+
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
|
|
112913
|
+
if (names.length === 0) {
|
|
112914
|
+
return [];
|
|
112915
|
+
}
|
|
112916
|
+
var resolutions = [];
|
|
112917
|
+
var cache = new ts.Map();
|
|
112918
|
+
var i = 0;
|
|
112919
|
+
for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
|
|
112920
|
+
var name = names_3[_i];
|
|
112921
|
+
var result = void 0;
|
|
112922
|
+
var mode = getModeForResolutionAtIndex(containingFile, i);
|
|
112923
|
+
i++;
|
|
112924
|
+
var cacheKey = mode !== undefined ? mode + "|" + name : name;
|
|
112925
|
+
if (cache.has(cacheKey)) {
|
|
112926
|
+
result = cache.get(cacheKey);
|
|
112927
|
+
}
|
|
112928
|
+
else {
|
|
112929
|
+
cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
|
|
112930
|
+
}
|
|
112931
|
+
resolutions.push(result);
|
|
112932
|
+
}
|
|
112933
|
+
return resolutions;
|
|
112934
|
+
}
|
|
112935
|
+
ts.loadWithModeAwareCache = loadWithModeAwareCache;
|
|
111954
112936
|
/* @internal */
|
|
111955
112937
|
function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
|
|
111956
112938
|
return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
|
|
@@ -112009,7 +112991,7 @@ var ts;
|
|
|
112009
112991
|
switch (kind) {
|
|
112010
112992
|
case ts.FileIncludeKind.Import:
|
|
112011
112993
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
112012
|
-
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
112994
|
+
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;
|
|
112013
112995
|
if (importLiteral.pos === -1)
|
|
112014
112996
|
return { file: file, packageId: packageId, text: importLiteral.text };
|
|
112015
112997
|
pos = ts.skipTrivia(file.text, importLiteral.pos);
|
|
@@ -112020,7 +113002,7 @@ var ts;
|
|
|
112020
113002
|
break;
|
|
112021
113003
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
112022
113004
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
112023
|
-
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;
|
|
113005
|
+
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;
|
|
112024
113006
|
break;
|
|
112025
113007
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
112026
113008
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -112107,6 +113089,33 @@ var ts;
|
|
|
112107
113089
|
configFileParseResult.errors;
|
|
112108
113090
|
}
|
|
112109
113091
|
ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
|
|
113092
|
+
/**
|
|
113093
|
+
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
|
113094
|
+
* `options` parameter.
|
|
113095
|
+
*
|
|
113096
|
+
* @param fileName The normalized absolute path to check the format of (it need not exist on disk)
|
|
113097
|
+
* @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
|
|
113098
|
+
* @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
|
|
113099
|
+
* @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
|
|
113100
|
+
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
113101
|
+
*/
|
|
113102
|
+
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
113103
|
+
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
113104
|
+
case ts.ModuleResolutionKind.Node12:
|
|
113105
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
113106
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext :
|
|
113107
|
+
ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS :
|
|
113108
|
+
ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() :
|
|
113109
|
+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
|
113110
|
+
default:
|
|
113111
|
+
return undefined;
|
|
113112
|
+
}
|
|
113113
|
+
function lookupFromPackageJson() {
|
|
113114
|
+
var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
|
|
113115
|
+
return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
113116
|
+
}
|
|
113117
|
+
}
|
|
113118
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
112110
113119
|
/**
|
|
112111
113120
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
112112
113121
|
*/
|
|
@@ -112127,7 +113136,7 @@ var ts;
|
|
|
112127
113136
|
};
|
|
112128
113137
|
}
|
|
112129
113138
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
112130
|
-
var _a, _b, _c;
|
|
113139
|
+
var _a, _b, _c, _d;
|
|
112131
113140
|
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
|
112132
113141
|
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
|
|
112133
113142
|
var oldProgram = createProgramOptions.oldProgram;
|
|
@@ -112169,7 +113178,7 @@ var ts;
|
|
|
112169
113178
|
var programDiagnostics = ts.createDiagnosticCollection();
|
|
112170
113179
|
var currentDirectory = host.getCurrentDirectory();
|
|
112171
113180
|
var supportedExtensions = ts.getSupportedExtensions(options);
|
|
112172
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
113181
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
112173
113182
|
// Map storing if there is emit blocking diagnostics for given input
|
|
112174
113183
|
var hasEmitBlockingDiagnostics = new ts.Map();
|
|
112175
113184
|
var _compilerOptionsObjectLiteralSyntax;
|
|
@@ -112178,7 +113187,7 @@ var ts;
|
|
|
112178
113187
|
var actualResolveModuleNamesWorker;
|
|
112179
113188
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
112180
113189
|
if (host.resolveModuleNames) {
|
|
112181
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames),
|
|
113190
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
|
|
112182
113191
|
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
|
112183
113192
|
if (!resolved || resolved.extension !== undefined) {
|
|
112184
113193
|
return resolved;
|
|
@@ -112187,11 +113196,12 @@ var ts;
|
|
|
112187
113196
|
withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
|
|
112188
113197
|
return withExtension;
|
|
112189
113198
|
}); };
|
|
113199
|
+
moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
112190
113200
|
}
|
|
112191
113201
|
else {
|
|
112192
113202
|
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
112193
|
-
var loader_1 = function (moduleName,
|
|
112194
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return
|
|
113203
|
+
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
|
|
113204
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
|
|
112195
113205
|
}
|
|
112196
113206
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
112197
113207
|
if (host.resolveTypeReferenceDirectives) {
|
|
@@ -112227,9 +113237,9 @@ var ts;
|
|
|
112227
113237
|
var projectReferenceRedirects;
|
|
112228
113238
|
var mapFromFileToProjectReferenceRedirects;
|
|
112229
113239
|
var mapFromToProjectReferenceRedirectSource;
|
|
112230
|
-
var useSourceOfProjectReferenceRedirect = !!((
|
|
113240
|
+
var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
|
|
112231
113241
|
!options.disableSourceOfProjectReferenceRedirect;
|
|
112232
|
-
var
|
|
113242
|
+
var _e = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
112233
113243
|
compilerHost: host,
|
|
112234
113244
|
getSymlinkCache: getSymlinkCache,
|
|
112235
113245
|
useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
|
|
@@ -112237,7 +113247,8 @@ var ts;
|
|
|
112237
113247
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
112238
113248
|
getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
|
|
112239
113249
|
forEachResolvedProjectReference: forEachResolvedProjectReference
|
|
112240
|
-
}), onProgramCreateComplete =
|
|
113250
|
+
}), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
|
|
113251
|
+
var readFile = host.readFile.bind(host);
|
|
112241
113252
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
112242
113253
|
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
112243
113254
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112296,7 +113307,7 @@ var ts;
|
|
|
112296
113307
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
112297
113308
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
112298
113309
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
112299
|
-
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (
|
|
113310
|
+
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
112300
113311
|
}
|
|
112301
113312
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
112302
113313
|
}
|
|
@@ -112412,9 +113423,10 @@ var ts;
|
|
|
112412
113423
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
112413
113424
|
emitBuildInfo: emitBuildInfo,
|
|
112414
113425
|
fileExists: fileExists,
|
|
113426
|
+
readFile: readFile,
|
|
112415
113427
|
directoryExists: directoryExists,
|
|
112416
113428
|
getSymlinkCache: getSymlinkCache,
|
|
112417
|
-
realpath: (
|
|
113429
|
+
realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
|
|
112418
113430
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
112419
113431
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
112420
113432
|
structureIsReused: structureIsReused,
|
|
@@ -112444,7 +113456,7 @@ var ts;
|
|
|
112444
113456
|
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
112445
113457
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
|
|
112446
113458
|
ts.performance.mark("beforeResolveModule");
|
|
112447
|
-
var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
|
|
113459
|
+
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
|
|
112448
113460
|
ts.performance.mark("afterResolveModule");
|
|
112449
113461
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
112450
113462
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112465,7 +113477,7 @@ var ts;
|
|
|
112465
113477
|
}
|
|
112466
113478
|
function getRedirectReferenceForResolution(file) {
|
|
112467
113479
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
112468
|
-
if (redirect || !ts.
|
|
113480
|
+
if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
|
|
112469
113481
|
return redirect;
|
|
112470
113482
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
112471
113483
|
// 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
|
|
@@ -112510,8 +113522,8 @@ var ts;
|
|
|
112510
113522
|
}
|
|
112511
113523
|
return ts.libs.length + 2;
|
|
112512
113524
|
}
|
|
112513
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
112514
|
-
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
|
|
113525
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
113526
|
+
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
112515
113527
|
}
|
|
112516
113528
|
function toPath(fileName) {
|
|
112517
113529
|
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
@@ -112553,9 +113565,11 @@ var ts;
|
|
|
112553
113565
|
// Since we assume the filesystem does not change during program creation,
|
|
112554
113566
|
// it is safe to reuse resolutions from the earlier call.
|
|
112555
113567
|
var result_14 = [];
|
|
113568
|
+
var i = 0;
|
|
112556
113569
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
112557
113570
|
var moduleName = moduleNames_1[_i];
|
|
112558
|
-
var resolvedModule = file.resolvedModules.get(moduleName);
|
|
113571
|
+
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113572
|
+
i++;
|
|
112559
113573
|
result_14.push(resolvedModule);
|
|
112560
113574
|
}
|
|
112561
113575
|
return result_14;
|
|
@@ -112583,7 +113597,7 @@ var ts;
|
|
|
112583
113597
|
var moduleName = moduleNames[i];
|
|
112584
113598
|
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
112585
113599
|
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
112586
|
-
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
|
|
113600
|
+
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
|
|
112587
113601
|
if (oldResolvedModule) {
|
|
112588
113602
|
if (ts.isTraceEnabled(options, host)) {
|
|
112589
113603
|
ts.trace(host, oldResolvedModule.packageId ?
|
|
@@ -112607,7 +113621,7 @@ var ts;
|
|
|
112607
113621
|
}
|
|
112608
113622
|
}
|
|
112609
113623
|
else {
|
|
112610
|
-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
|
|
113624
|
+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
|
|
112611
113625
|
}
|
|
112612
113626
|
if (resolvesToAmbientModuleInNonModifiedFile) {
|
|
112613
113627
|
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
|
@@ -112644,8 +113658,10 @@ var ts;
|
|
|
112644
113658
|
return result;
|
|
112645
113659
|
// If we change our policy of rechecking failed lookups on each program create,
|
|
112646
113660
|
// we should adjust the value returned here.
|
|
112647
|
-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
112648
|
-
|
|
113661
|
+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, index) {
|
|
113662
|
+
if (index >= ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.imports) + ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.moduleAugmentations))
|
|
113663
|
+
return false; // mode index out of bounds, don't reuse resolution
|
|
113664
|
+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index));
|
|
112649
113665
|
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
112650
113666
|
if (resolutionToFile && resolvedFile) {
|
|
112651
113667
|
// In the old program, we resolved to an ambient module that was in the same
|
|
@@ -112728,8 +113744,8 @@ var ts;
|
|
|
112728
113744
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
112729
113745
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
112730
113746
|
var newSourceFile = host.getSourceFileByPath
|
|
112731
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options
|
|
112732
|
-
: host.getSourceFile(oldSourceFile.fileName, options
|
|
113747
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
|
|
113748
|
+
: host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
|
|
112733
113749
|
if (!newSourceFile) {
|
|
112734
113750
|
return 0 /* Not */;
|
|
112735
113751
|
}
|
|
@@ -112836,10 +113852,10 @@ var ts;
|
|
|
112836
113852
|
var moduleNames = getModuleNames(newSourceFile);
|
|
112837
113853
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
112838
113854
|
// ensure that module resolution results are still correct
|
|
112839
|
-
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
|
|
113855
|
+
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
|
|
112840
113856
|
if (resolutionsChanged) {
|
|
112841
113857
|
structureIsReused = 1 /* SafeModules */;
|
|
112842
|
-
newSourceFile.resolvedModules = ts.
|
|
113858
|
+
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
112843
113859
|
}
|
|
112844
113860
|
else {
|
|
112845
113861
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
@@ -112848,10 +113864,10 @@ var ts;
|
|
|
112848
113864
|
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
112849
113865
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
112850
113866
|
// ensure that types resolutions are still correct
|
|
112851
|
-
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
|
|
113867
|
+
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
112852
113868
|
if (typeReferenceEesolutionsChanged) {
|
|
112853
113869
|
structureIsReused = 1 /* SafeModules */;
|
|
112854
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.
|
|
113870
|
+
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
112855
113871
|
}
|
|
112856
113872
|
else {
|
|
112857
113873
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
@@ -113482,6 +114498,7 @@ var ts;
|
|
|
113482
114498
|
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
|
|
113483
114499
|
// only through top - level external module names. Relative external module names are not permitted.
|
|
113484
114500
|
if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
|
|
114501
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113485
114502
|
imports = ts.append(imports, moduleNameExpr);
|
|
113486
114503
|
if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) {
|
|
113487
114504
|
usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:");
|
|
@@ -113490,6 +114507,7 @@ var ts;
|
|
|
113490
114507
|
}
|
|
113491
114508
|
else if (ts.isModuleDeclaration(node)) {
|
|
113492
114509
|
if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) {
|
|
114510
|
+
node.name.parent = node;
|
|
113493
114511
|
var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
|
|
113494
114512
|
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
|
113495
114513
|
// This will happen in two cases:
|
|
@@ -113525,13 +114543,16 @@ var ts;
|
|
|
113525
114543
|
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
|
113526
114544
|
var node = getNodeAtPosition(file, r.lastIndex);
|
|
113527
114545
|
if (isJavaScriptFile && ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
|
114546
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113528
114547
|
imports = ts.append(imports, node.arguments[0]);
|
|
113529
114548
|
}
|
|
113530
114549
|
// 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.
|
|
113531
114550
|
else if (ts.isImportCall(node) && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) {
|
|
114551
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113532
114552
|
imports = ts.append(imports, node.arguments[0]);
|
|
113533
114553
|
}
|
|
113534
114554
|
else if (ts.isLiteralImportTypeNode(node)) {
|
|
114555
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113535
114556
|
imports = ts.append(imports, node.argument.literal);
|
|
113536
114557
|
}
|
|
113537
114558
|
}
|
|
@@ -113567,13 +114588,13 @@ var ts;
|
|
|
113567
114588
|
function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) {
|
|
113568
114589
|
if (ts.hasExtension(fileName)) {
|
|
113569
114590
|
var canonicalFileName_1 = host.getCanonicalFileName(fileName);
|
|
113570
|
-
if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
114591
|
+
if (!options.allowNonTsExtensions && !ts.forEach(ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
113571
114592
|
if (fail) {
|
|
113572
114593
|
if (ts.hasJSFileExtension(canonicalFileName_1)) {
|
|
113573
114594
|
fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
|
|
113574
114595
|
}
|
|
113575
114596
|
else {
|
|
113576
|
-
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114597
|
+
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113577
114598
|
}
|
|
113578
114599
|
}
|
|
113579
114600
|
return undefined;
|
|
@@ -113603,9 +114624,10 @@ var ts;
|
|
|
113603
114624
|
fail(ts.Diagnostics.File_0_not_found, fileName);
|
|
113604
114625
|
return undefined;
|
|
113605
114626
|
}
|
|
113606
|
-
|
|
114627
|
+
// Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts)
|
|
114628
|
+
var sourceFileWithAddedExtension = ts.forEach(supportedExtensions[0], function (extension) { return getSourceFile(fileName + extension); });
|
|
113607
114629
|
if (fail && !sourceFileWithAddedExtension)
|
|
113608
|
-
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114630
|
+
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113609
114631
|
return sourceFileWithAddedExtension;
|
|
113610
114632
|
}
|
|
113611
114633
|
}
|
|
@@ -113750,7 +114772,7 @@ var ts;
|
|
|
113750
114772
|
}
|
|
113751
114773
|
}
|
|
113752
114774
|
// We haven't looked for this file, do so now and cache result
|
|
113753
|
-
var file = host.getSourceFile(fileName, options
|
|
114775
|
+
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);
|
|
113754
114776
|
if (packageId) {
|
|
113755
114777
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
113756
114778
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
@@ -113778,6 +114800,10 @@ var ts;
|
|
|
113778
114800
|
file.path = path;
|
|
113779
114801
|
file.resolvedPath = toPath(fileName);
|
|
113780
114802
|
file.originalFileName = originalFileName;
|
|
114803
|
+
// 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
|
|
114804
|
+
// 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
|
|
114805
|
+
// 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.
|
|
114806
|
+
file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
113781
114807
|
addFileIncludeReason(file, reason);
|
|
113782
114808
|
if (host.useCaseSensitiveFileNames()) {
|
|
113783
114809
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -113969,9 +114995,9 @@ var ts;
|
|
|
113969
114995
|
}
|
|
113970
114996
|
}
|
|
113971
114997
|
function pathForLibFile(libFileName) {
|
|
113972
|
-
// Support resolving to lib.dom.d.ts -> @typescript/dom, and
|
|
113973
|
-
// lib.dom.iterable.d.ts -> @typescript/dom/iterable
|
|
113974
|
-
// lib.es2015.symbol.wellknown.d.ts -> @typescript/es2015/symbol-wellknown
|
|
114998
|
+
// Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
|
|
114999
|
+
// lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
|
|
115000
|
+
// lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
|
|
113975
115001
|
var components = libFileName.split(".");
|
|
113976
115002
|
var path = components[1];
|
|
113977
115003
|
var i = 2;
|
|
@@ -113980,7 +115006,7 @@ var ts;
|
|
|
113980
115006
|
i++;
|
|
113981
115007
|
}
|
|
113982
115008
|
var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts");
|
|
113983
|
-
var localOverrideModuleResult = ts.resolveModuleName("@typescript/" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
115009
|
+
var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
113984
115010
|
if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) {
|
|
113985
115011
|
return localOverrideModuleResult.resolvedModule.resolvedFileName;
|
|
113986
115012
|
}
|
|
@@ -114021,7 +115047,7 @@ var ts;
|
|
|
114021
115047
|
var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options;
|
|
114022
115048
|
for (var index = 0; index < moduleNames.length; index++) {
|
|
114023
115049
|
var resolution = resolutions[index];
|
|
114024
|
-
ts.setResolvedModule(file, moduleNames[index], resolution);
|
|
115050
|
+
ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
|
|
114025
115051
|
if (!resolution) {
|
|
114026
115052
|
continue;
|
|
114027
115053
|
}
|
|
@@ -114244,7 +115270,7 @@ var ts;
|
|
|
114244
115270
|
if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
|
|
114245
115271
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
|
|
114246
115272
|
}
|
|
114247
|
-
var languageVersion = options
|
|
115273
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
114248
115274
|
var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
|
|
114249
115275
|
if (options.isolatedModules) {
|
|
114250
115276
|
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
|
|
@@ -114505,7 +115531,7 @@ var ts;
|
|
|
114505
115531
|
message = ts.Diagnostics.File_is_library_specified_here;
|
|
114506
115532
|
break;
|
|
114507
115533
|
}
|
|
114508
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
115534
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
114509
115535
|
configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
|
|
114510
115536
|
message = ts.Diagnostics.File_is_default_library_for_target_specified_here;
|
|
114511
115537
|
break;
|
|
@@ -114673,7 +115699,7 @@ var ts;
|
|
|
114673
115699
|
if (options.outDir) {
|
|
114674
115700
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
114675
115701
|
}
|
|
114676
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.
|
|
115702
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
|
|
114677
115703
|
// Otherwise just check if sourceFile with the name exists
|
|
114678
115704
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
114679
115705
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -115205,7 +116231,7 @@ var ts;
|
|
|
115205
116231
|
}
|
|
115206
116232
|
}
|
|
115207
116233
|
}
|
|
115208
|
-
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
|
|
116234
|
+
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
|
|
115209
116235
|
}
|
|
115210
116236
|
return {
|
|
115211
116237
|
fileInfos: fileInfos,
|
|
@@ -115299,7 +116325,7 @@ var ts;
|
|
|
115299
116325
|
/*forceDtsEmit*/ true);
|
|
115300
116326
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
115301
116327
|
if (firstDts_1) {
|
|
115302
|
-
ts.Debug.assert(ts.
|
|
116328
|
+
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; })); });
|
|
115303
116329
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
115304
116330
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
115305
116331
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -115623,6 +116649,14 @@ var ts;
|
|
|
115623
116649
|
ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
|
|
115624
116650
|
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
|
|
115625
116651
|
}
|
|
116652
|
+
if (useOldState) {
|
|
116653
|
+
// Any time the interpretation of a source file changes, mark it as changed
|
|
116654
|
+
ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
|
|
116655
|
+
if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
|
|
116656
|
+
state.changedFilesSet.add(sourceFilePath);
|
|
116657
|
+
}
|
|
116658
|
+
});
|
|
116659
|
+
}
|
|
115626
116660
|
state.buildInfoEmitPending = !!state.changedFilesSet.size;
|
|
115627
116661
|
return state;
|
|
115628
116662
|
}
|
|
@@ -116019,13 +117053,13 @@ var ts;
|
|
|
116019
117053
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
116020
117054
|
return value.version === actualSignature ?
|
|
116021
117055
|
value.affectsGlobalScope ?
|
|
116022
|
-
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
|
|
117056
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
|
|
116023
117057
|
value.version :
|
|
116024
117058
|
actualSignature !== undefined ?
|
|
116025
117059
|
signature === undefined ?
|
|
116026
117060
|
value :
|
|
116027
|
-
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } :
|
|
116028
|
-
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
|
|
117061
|
+
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
117062
|
+
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
116029
117063
|
});
|
|
116030
117064
|
var referencedMap;
|
|
116031
117065
|
if (state.referencedMap) {
|
|
@@ -116445,10 +117479,10 @@ var ts;
|
|
|
116445
117479
|
}
|
|
116446
117480
|
function toBuilderStateFileInfo(fileInfo) {
|
|
116447
117481
|
return ts.isString(fileInfo) ?
|
|
116448
|
-
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
|
|
117482
|
+
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
|
|
116449
117483
|
ts.isString(fileInfo.signature) ?
|
|
116450
117484
|
fileInfo :
|
|
116451
|
-
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
|
|
117485
|
+
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
116452
117486
|
}
|
|
116453
117487
|
ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
|
|
116454
117488
|
function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
|
|
@@ -116786,14 +117820,14 @@ var ts;
|
|
|
116786
117820
|
}
|
|
116787
117821
|
function resolveNamesWithLocalCache(_a) {
|
|
116788
117822
|
var _b, _c, _d;
|
|
116789
|
-
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;
|
|
117823
|
+
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;
|
|
116790
117824
|
var path = resolutionHost.toPath(containingFile);
|
|
116791
|
-
var resolutionsInFile = cache.get(path) || cache.set(path,
|
|
117825
|
+
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
116792
117826
|
var dirPath = ts.getDirectoryPath(path);
|
|
116793
117827
|
var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
116794
117828
|
var perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
116795
117829
|
if (!perDirectoryResolution) {
|
|
116796
|
-
perDirectoryResolution =
|
|
117830
|
+
perDirectoryResolution = ts.createModeAwareCache();
|
|
116797
117831
|
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
116798
117832
|
}
|
|
116799
117833
|
var resolvedModules = [];
|
|
@@ -116805,17 +117839,20 @@ var ts;
|
|
|
116805
117839
|
var unmatchedRedirects = oldRedirect ?
|
|
116806
117840
|
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
|
116807
117841
|
!!redirectedReference;
|
|
116808
|
-
var seenNamesInFile =
|
|
116809
|
-
|
|
116810
|
-
|
|
116811
|
-
var
|
|
117842
|
+
var seenNamesInFile = ts.createModeAwareCache();
|
|
117843
|
+
var i = 0;
|
|
117844
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
117845
|
+
var name = names_4[_i];
|
|
117846
|
+
var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
117847
|
+
i++;
|
|
117848
|
+
var resolution = resolutionsInFile.get(name, mode);
|
|
116812
117849
|
// Resolution is valid if it is present and not invalidated
|
|
116813
|
-
if (!seenNamesInFile.has(name) &&
|
|
117850
|
+
if (!seenNamesInFile.has(name, mode) &&
|
|
116814
117851
|
unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
116815
117852
|
// If the name is unresolved import that was invalidated, recalculate
|
|
116816
117853
|
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
116817
117854
|
var existingResolution = resolution;
|
|
116818
|
-
var resolutionInDirectory = perDirectoryResolution.get(name);
|
|
117855
|
+
var resolutionInDirectory = perDirectoryResolution.get(name, mode);
|
|
116819
117856
|
if (resolutionInDirectory) {
|
|
116820
117857
|
resolution = resolutionInDirectory;
|
|
116821
117858
|
var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
@@ -116835,10 +117872,10 @@ var ts;
|
|
|
116835
117872
|
}
|
|
116836
117873
|
}
|
|
116837
117874
|
else {
|
|
116838
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference);
|
|
116839
|
-
perDirectoryResolution.set(name, resolution);
|
|
117875
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
117876
|
+
perDirectoryResolution.set(name, mode, resolution);
|
|
116840
117877
|
}
|
|
116841
|
-
resolutionsInFile.set(name, resolution);
|
|
117878
|
+
resolutionsInFile.set(name, mode, resolution);
|
|
116842
117879
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
116843
117880
|
if (existingResolution) {
|
|
116844
117881
|
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
|
@@ -116851,7 +117888,7 @@ var ts;
|
|
|
116851
117888
|
}
|
|
116852
117889
|
else {
|
|
116853
117890
|
var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost;
|
|
116854
|
-
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) {
|
|
117891
|
+
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
116855
117892
|
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
116856
117893
|
ts.trace(host, loader === resolveModuleName ?
|
|
116857
117894
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
@@ -116867,14 +117904,14 @@ var ts;
|
|
|
116867
117904
|
}
|
|
116868
117905
|
}
|
|
116869
117906
|
ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
|
|
116870
|
-
seenNamesInFile.set(name, true);
|
|
117907
|
+
seenNamesInFile.set(name, mode, true);
|
|
116871
117908
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
116872
117909
|
}
|
|
116873
117910
|
// Stop watching and remove the unused name
|
|
116874
|
-
resolutionsInFile.forEach(function (resolution, name) {
|
|
116875
|
-
if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
|
|
117911
|
+
resolutionsInFile.forEach(function (resolution, name, mode) {
|
|
117912
|
+
if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
|
|
116876
117913
|
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
116877
|
-
resolutionsInFile.delete(name);
|
|
117914
|
+
resolutionsInFile.delete(name, mode);
|
|
116878
117915
|
}
|
|
116879
117916
|
});
|
|
116880
117917
|
return resolvedModules;
|
|
@@ -116908,7 +117945,7 @@ var ts;
|
|
|
116908
117945
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
116909
117946
|
});
|
|
116910
117947
|
}
|
|
116911
|
-
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
117948
|
+
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
116912
117949
|
return resolveNamesWithLocalCache({
|
|
116913
117950
|
names: moduleNames,
|
|
116914
117951
|
containingFile: containingFile,
|
|
@@ -116920,11 +117957,14 @@ var ts;
|
|
|
116920
117957
|
shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
|
|
116921
117958
|
reusedNames: reusedNames,
|
|
116922
117959
|
logChanges: logChangesWhenResolvingModule,
|
|
117960
|
+
containingSourceFile: containingSourceFile,
|
|
116923
117961
|
});
|
|
116924
117962
|
}
|
|
116925
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
117963
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
|
|
116926
117964
|
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
|
|
116927
|
-
|
|
117965
|
+
if (!cache)
|
|
117966
|
+
return undefined;
|
|
117967
|
+
return cache.get(moduleName, resolutionMode);
|
|
116928
117968
|
}
|
|
116929
117969
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
116930
117970
|
return ts.endsWith(dirPath, "/node_modules/@types");
|
|
@@ -117323,7 +118363,7 @@ var ts;
|
|
|
117323
118363
|
Ending[Ending["Index"] = 1] = "Index";
|
|
117324
118364
|
Ending[Ending["JsExtension"] = 2] = "JsExtension";
|
|
117325
118365
|
})(Ending || (Ending = {}));
|
|
117326
|
-
function getPreferences(_a, compilerOptions, importingSourceFile) {
|
|
118366
|
+
function getPreferences(host, _a, compilerOptions, importingSourceFile) {
|
|
117327
118367
|
var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
|
|
117328
118368
|
return {
|
|
117329
118369
|
relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ :
|
|
@@ -117337,21 +118377,39 @@ var ts;
|
|
|
117337
118377
|
case "minimal": return 0 /* Minimal */;
|
|
117338
118378
|
case "index": return 1 /* Index */;
|
|
117339
118379
|
case "js": return 2 /* JsExtension */;
|
|
117340
|
-
default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */
|
|
118380
|
+
default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */
|
|
117341
118381
|
: ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */;
|
|
117342
118382
|
}
|
|
117343
118383
|
}
|
|
117344
118384
|
}
|
|
117345
|
-
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
|
|
118385
|
+
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) {
|
|
117346
118386
|
return {
|
|
117347
118387
|
relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */,
|
|
117348
|
-
ending: ts.hasJSFileExtension(oldImportSpecifier) ?
|
|
118388
|
+
ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ?
|
|
117349
118389
|
2 /* JsExtension */ :
|
|
117350
118390
|
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */,
|
|
117351
118391
|
};
|
|
117352
118392
|
}
|
|
118393
|
+
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
118394
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
|
|
118395
|
+
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118396
|
+
return false;
|
|
118397
|
+
}
|
|
118398
|
+
return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
|
|
118399
|
+
}
|
|
118400
|
+
function getModuleResolutionHost(host) {
|
|
118401
|
+
var _a;
|
|
118402
|
+
return {
|
|
118403
|
+
fileExists: host.fileExists,
|
|
118404
|
+
readFile: ts.Debug.checkDefined(host.readFile),
|
|
118405
|
+
directoryExists: host.directoryExists,
|
|
118406
|
+
getCurrentDirectory: host.getCurrentDirectory,
|
|
118407
|
+
realpath: host.realpath,
|
|
118408
|
+
useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
|
|
118409
|
+
};
|
|
118410
|
+
}
|
|
117353
118411
|
function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
|
|
117354
|
-
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier), {});
|
|
118412
|
+
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
|
|
117355
118413
|
if (res === oldImportSpecifier)
|
|
117356
118414
|
return undefined;
|
|
117357
118415
|
return res;
|
|
@@ -117359,7 +118417,7 @@ var ts;
|
|
|
117359
118417
|
moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
|
|
117360
118418
|
// Note: importingSourceFile is just for usesJsExtensionOnImports
|
|
117361
118419
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
|
|
117362
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {});
|
|
118420
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
117363
118421
|
}
|
|
117364
118422
|
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
|
|
117365
118423
|
function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
|
|
@@ -117413,7 +118471,7 @@ var ts;
|
|
|
117413
118471
|
moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo;
|
|
117414
118472
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) {
|
|
117415
118473
|
var info = getInfo(importingSourceFile.path, host);
|
|
117416
|
-
var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
118474
|
+
var preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile);
|
|
117417
118475
|
var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) {
|
|
117418
118476
|
if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path)
|
|
117419
118477
|
return undefined;
|
|
@@ -117849,7 +118907,7 @@ var ts;
|
|
|
117849
118907
|
if (!host.fileExists)
|
|
117850
118908
|
return;
|
|
117851
118909
|
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
|
|
117852
|
-
var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]);
|
|
118910
|
+
var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]));
|
|
117853
118911
|
for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
|
|
117854
118912
|
var e = extensions_3[_i];
|
|
117855
118913
|
var fullPath = path + e;
|
|
@@ -117917,9 +118975,11 @@ var ts;
|
|
|
117917
118975
|
});
|
|
117918
118976
|
}
|
|
117919
118977
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
117920
|
-
if (ts.
|
|
118978
|
+
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
117921
118979
|
return fileName;
|
|
117922
118980
|
var noExtension = ts.removeFileExtension(fileName);
|
|
118981
|
+
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
118982
|
+
return noExtension + getJSExtensionForFile(fileName, options);
|
|
117923
118983
|
switch (ending) {
|
|
117924
118984
|
case 0 /* Minimal */:
|
|
117925
118985
|
return ts.removeSuffix(noExtension, "/index");
|
|
@@ -117947,6 +119007,14 @@ var ts;
|
|
|
117947
119007
|
case ".jsx" /* Jsx */:
|
|
117948
119008
|
case ".json" /* Json */:
|
|
117949
119009
|
return ext;
|
|
119010
|
+
case ".d.mts" /* Dmts */:
|
|
119011
|
+
case ".mts" /* Mts */:
|
|
119012
|
+
case ".mjs" /* Mjs */:
|
|
119013
|
+
return ".mjs" /* Mjs */;
|
|
119014
|
+
case ".d.cts" /* Dcts */:
|
|
119015
|
+
case ".cts" /* Cts */:
|
|
119016
|
+
case ".cjs" /* Cjs */:
|
|
119017
|
+
return ".cjs" /* Cjs */;
|
|
117950
119018
|
default:
|
|
117951
119019
|
return undefined;
|
|
117952
119020
|
}
|
|
@@ -118221,7 +119289,7 @@ var ts;
|
|
|
118221
119289
|
case ts.FileIncludeKind.LibFile:
|
|
118222
119290
|
if (reason.index !== undefined)
|
|
118223
119291
|
return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]);
|
|
118224
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
119292
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
118225
119293
|
return ts.chainDiagnosticMessages(
|
|
118226
119294
|
/*details*/ undefined, target ?
|
|
118227
119295
|
ts.Diagnostics.Default_library_for_target_0 :
|
|
@@ -118644,7 +119712,7 @@ var ts;
|
|
|
118644
119712
|
}
|
|
118645
119713
|
return host.resolveModuleNames.apply(host, args);
|
|
118646
119714
|
}) :
|
|
118647
|
-
(function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
|
|
119715
|
+
(function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
|
|
118648
119716
|
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
|
118649
119717
|
(function () {
|
|
118650
119718
|
var args = [];
|
|
@@ -119372,10 +120440,11 @@ var ts;
|
|
|
119372
120440
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
119373
120441
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
119374
120442
|
if (!compilerHost.resolveModuleNames) {
|
|
119375
|
-
var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
|
|
119376
|
-
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
|
|
119377
|
-
return ts.
|
|
120443
|
+
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
|
|
120444
|
+
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
120445
|
+
return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
|
|
119378
120446
|
};
|
|
120447
|
+
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
119379
120448
|
}
|
|
119380
120449
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
119381
120450
|
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|