@typescript-deploys/pr-build 4.5.0-pr-45771-10 → 4.5.0-pr-45884-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +991 -313
- package/lib/tsserver.js +1143 -381
- package/lib/tsserverlibrary.d.ts +65 -14
- package/lib/tsserverlibrary.js +1143 -381
- package/lib/typescript.d.ts +63 -12
- package/lib/typescript.js +1138 -375
- package/lib/typescriptServices.d.ts +63 -12
- package/lib/typescriptServices.js +1138 -375
- package/lib/typingsInstaller.js +1094 -347
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20210915";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -5108,6 +5108,12 @@ var ts;
|
|
|
5108
5108
|
(function (ModuleResolutionKind) {
|
|
5109
5109
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
5110
5110
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
|
|
5111
|
+
// Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
|
|
5112
|
+
// to better support ecmascript modules and their use within node - more features are still being added, so
|
|
5113
|
+
// we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
|
|
5114
|
+
// version-anchored resolution target
|
|
5115
|
+
ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
|
|
5116
|
+
ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
|
|
5111
5117
|
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
|
|
5112
5118
|
var WatchFileKind;
|
|
5113
5119
|
(function (WatchFileKind) {
|
|
@@ -5145,6 +5151,9 @@ var ts;
|
|
|
5145
5151
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5146
5152
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5147
5153
|
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
|
|
5154
|
+
// Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
|
|
5155
|
+
ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
|
|
5156
|
+
ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext";
|
|
5148
5157
|
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
|
|
5149
5158
|
var JsxEmit;
|
|
5150
5159
|
(function (JsxEmit) {
|
|
@@ -5344,6 +5353,12 @@ var ts;
|
|
|
5344
5353
|
Extension["Jsx"] = ".jsx";
|
|
5345
5354
|
Extension["Json"] = ".json";
|
|
5346
5355
|
Extension["TsBuildInfo"] = ".tsbuildinfo";
|
|
5356
|
+
Extension["Mjs"] = ".mjs";
|
|
5357
|
+
Extension["Mts"] = ".mts";
|
|
5358
|
+
Extension["Dmts"] = ".d.mts";
|
|
5359
|
+
Extension["Cjs"] = ".cjs";
|
|
5360
|
+
Extension["Cts"] = ".cts";
|
|
5361
|
+
Extension["Dcts"] = ".d.cts";
|
|
5347
5362
|
})(Extension = ts.Extension || (ts.Extension = {}));
|
|
5348
5363
|
/* @internal */
|
|
5349
5364
|
var TransformFlags;
|
|
@@ -8050,7 +8065,7 @@ var ts;
|
|
|
8050
8065
|
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."),
|
|
8051
8066
|
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."),
|
|
8052
8067
|
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."),
|
|
8053
|
-
|
|
8068
|
+
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'."),
|
|
8054
8069
|
Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."),
|
|
8055
8070
|
Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."),
|
|
8056
8071
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
@@ -8068,7 +8083,7 @@ var ts;
|
|
|
8068
8083
|
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."),
|
|
8069
8084
|
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}')'?"),
|
|
8070
8085
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
8071
|
-
|
|
8086
|
+
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'."),
|
|
8072
8087
|
A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
|
|
8073
8088
|
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."),
|
|
8074
8089
|
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."),
|
|
@@ -8099,7 +8114,7 @@ var ts;
|
|
|
8099
8114
|
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."),
|
|
8100
8115
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8101
8116
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8102
|
-
|
|
8117
|
+
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."),
|
|
8103
8118
|
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'."),
|
|
8104
8119
|
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'."),
|
|
8105
8120
|
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 `}`?"),
|
|
@@ -8151,7 +8166,7 @@ var ts;
|
|
|
8151
8166
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8152
8167
|
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:"),
|
|
8153
8168
|
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."),
|
|
8154
|
-
|
|
8169
|
+
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."),
|
|
8155
8170
|
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."),
|
|
8156
8171
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8157
8172
|
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}'?"),
|
|
@@ -8167,6 +8182,8 @@ var ts;
|
|
|
8167
8182
|
_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled: diag(1446, ts.DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveVa_1446", "'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled."),
|
|
8168
8183
|
_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."),
|
|
8169
8184
|
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."),
|
|
8185
|
+
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."),
|
|
8186
|
+
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."),
|
|
8170
8187
|
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."),
|
|
8171
8188
|
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."),
|
|
8172
8189
|
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),
|
|
@@ -9029,6 +9046,13 @@ var ts;
|
|
|
9029
9046
|
Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"),
|
|
9030
9047
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9031
9048
|
_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"),
|
|
9049
|
+
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."),
|
|
9050
|
+
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}'."),
|
|
9051
|
+
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."),
|
|
9052
|
+
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."),
|
|
9053
|
+
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."),
|
|
9054
|
+
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}'"),
|
|
9055
|
+
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}'."),
|
|
9032
9056
|
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
|
|
9033
9057
|
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."),
|
|
9034
9058
|
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}'."),
|
|
@@ -9288,6 +9312,8 @@ var ts;
|
|
|
9288
9312
|
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."),
|
|
9289
9313
|
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."),
|
|
9290
9314
|
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}';`"),
|
|
9315
|
+
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."),
|
|
9316
|
+
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."),
|
|
9291
9317
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9292
9318
|
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."),
|
|
9293
9319
|
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."),
|
|
@@ -11893,7 +11919,7 @@ var ts;
|
|
|
11893
11919
|
}
|
|
11894
11920
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
|
|
11895
11921
|
function getDefaultLibFileName(options) {
|
|
11896
|
-
switch (options
|
|
11922
|
+
switch (ts.getEmitScriptTarget(options)) {
|
|
11897
11923
|
case 99 /* ESNext */:
|
|
11898
11924
|
return "lib.esnext.full.d.ts";
|
|
11899
11925
|
case 8 /* ES2021 */:
|
|
@@ -13952,22 +13978,22 @@ var ts;
|
|
|
13952
13978
|
return node.end - node.pos;
|
|
13953
13979
|
}
|
|
13954
13980
|
ts.getFullWidth = getFullWidth;
|
|
13955
|
-
function getResolvedModule(sourceFile, moduleNameText) {
|
|
13956
|
-
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
|
|
13981
|
+
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
13982
|
+
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
|
|
13957
13983
|
}
|
|
13958
13984
|
ts.getResolvedModule = getResolvedModule;
|
|
13959
|
-
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
|
|
13985
|
+
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
13960
13986
|
if (!sourceFile.resolvedModules) {
|
|
13961
|
-
sourceFile.resolvedModules =
|
|
13987
|
+
sourceFile.resolvedModules = ts.createModeAwareCache();
|
|
13962
13988
|
}
|
|
13963
|
-
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
|
13989
|
+
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
13964
13990
|
}
|
|
13965
13991
|
ts.setResolvedModule = setResolvedModule;
|
|
13966
13992
|
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
13967
13993
|
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
13968
|
-
sourceFile.resolvedTypeReferenceDirectiveNames =
|
|
13994
|
+
sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
|
|
13969
13995
|
}
|
|
13970
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
|
13996
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
|
|
13971
13997
|
}
|
|
13972
13998
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
13973
13999
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
@@ -13999,11 +14025,11 @@ var ts;
|
|
|
13999
14025
|
&& oldResolution.originalPath === newResolution.originalPath;
|
|
14000
14026
|
}
|
|
14001
14027
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
14002
|
-
function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
|
|
14028
|
+
function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
|
|
14003
14029
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14004
14030
|
for (var i = 0; i < names.length; i++) {
|
|
14005
14031
|
var newResolution = newResolutions[i];
|
|
14006
|
-
var oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
|
14032
|
+
var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
|
|
14007
14033
|
var changed = oldResolution
|
|
14008
14034
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14009
14035
|
: newResolution;
|
|
@@ -14538,8 +14564,11 @@ var ts;
|
|
|
14538
14564
|
return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
|
|
14539
14565
|
}
|
|
14540
14566
|
ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
|
|
14567
|
+
function isCommonJSContainingModuleKind(kind) {
|
|
14568
|
+
return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext;
|
|
14569
|
+
}
|
|
14541
14570
|
function isEffectiveExternalModule(node, compilerOptions) {
|
|
14542
|
-
return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions)
|
|
14571
|
+
return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
|
14543
14572
|
}
|
|
14544
14573
|
ts.isEffectiveExternalModule = isEffectiveExternalModule;
|
|
14545
14574
|
/**
|
|
@@ -17829,9 +17858,17 @@ var ts;
|
|
|
17829
17858
|
var path = outputDir
|
|
17830
17859
|
? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
|
|
17831
17860
|
: fileName;
|
|
17832
|
-
|
|
17861
|
+
var declarationExtension = getDeclarationEmitExtensionForPath(path);
|
|
17862
|
+
return removeFileExtension(path) + declarationExtension;
|
|
17833
17863
|
}
|
|
17834
17864
|
ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
|
|
17865
|
+
function getDeclarationEmitExtensionForPath(path) {
|
|
17866
|
+
return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ :
|
|
17867
|
+
ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ :
|
|
17868
|
+
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
|
|
17869
|
+
".d.ts" /* Dts */;
|
|
17870
|
+
}
|
|
17871
|
+
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
17835
17872
|
function outFile(options) {
|
|
17836
17873
|
return options.outFile || options.out;
|
|
17837
17874
|
}
|
|
@@ -18571,7 +18608,7 @@ var ts;
|
|
|
18571
18608
|
}
|
|
18572
18609
|
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
|
18573
18610
|
function tryExtractTSExtension(fileName) {
|
|
18574
|
-
return ts.find(
|
|
18611
|
+
return ts.find(supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
18575
18612
|
}
|
|
18576
18613
|
ts.tryExtractTSExtension = tryExtractTSExtension;
|
|
18577
18614
|
/**
|
|
@@ -19523,7 +19560,10 @@ var ts;
|
|
|
19523
19560
|
}
|
|
19524
19561
|
ts.getLanguageVariant = getLanguageVariant;
|
|
19525
19562
|
function getEmitScriptTarget(compilerOptions) {
|
|
19526
|
-
return compilerOptions.target ||
|
|
19563
|
+
return compilerOptions.target ||
|
|
19564
|
+
(compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
|
|
19565
|
+
(compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) ||
|
|
19566
|
+
0 /* ES3 */;
|
|
19527
19567
|
}
|
|
19528
19568
|
ts.getEmitScriptTarget = getEmitScriptTarget;
|
|
19529
19569
|
function getEmitModuleKind(compilerOptions) {
|
|
@@ -19535,7 +19575,20 @@ var ts;
|
|
|
19535
19575
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
19536
19576
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
19537
19577
|
if (moduleResolution === undefined) {
|
|
19538
|
-
|
|
19578
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19579
|
+
case ts.ModuleKind.CommonJS:
|
|
19580
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
19581
|
+
break;
|
|
19582
|
+
case ts.ModuleKind.Node12:
|
|
19583
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
19584
|
+
break;
|
|
19585
|
+
case ts.ModuleKind.NodeNext:
|
|
19586
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
19587
|
+
break;
|
|
19588
|
+
default:
|
|
19589
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
19590
|
+
break;
|
|
19591
|
+
}
|
|
19539
19592
|
}
|
|
19540
19593
|
return moduleResolution;
|
|
19541
19594
|
}
|
|
@@ -19565,11 +19618,23 @@ var ts;
|
|
|
19565
19618
|
return !!(getEmitDeclarations(options) && options.declarationMap);
|
|
19566
19619
|
}
|
|
19567
19620
|
ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
|
|
19621
|
+
function getESModuleInterop(compilerOptions) {
|
|
19622
|
+
if (compilerOptions.esModuleInterop !== undefined) {
|
|
19623
|
+
return compilerOptions.esModuleInterop;
|
|
19624
|
+
}
|
|
19625
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19626
|
+
case ts.ModuleKind.Node12:
|
|
19627
|
+
case ts.ModuleKind.NodeNext:
|
|
19628
|
+
return true;
|
|
19629
|
+
}
|
|
19630
|
+
return undefined;
|
|
19631
|
+
}
|
|
19632
|
+
ts.getESModuleInterop = getESModuleInterop;
|
|
19568
19633
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
19569
19634
|
var moduleKind = getEmitModuleKind(compilerOptions);
|
|
19570
19635
|
return compilerOptions.allowSyntheticDefaultImports !== undefined
|
|
19571
19636
|
? compilerOptions.allowSyntheticDefaultImports
|
|
19572
|
-
: compilerOptions
|
|
19637
|
+
: getESModuleInterop(compilerOptions) ||
|
|
19573
19638
|
moduleKind === ts.ModuleKind.System;
|
|
19574
19639
|
}
|
|
19575
19640
|
ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
|
|
@@ -19594,7 +19659,7 @@ var ts;
|
|
|
19594
19659
|
}
|
|
19595
19660
|
ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
|
|
19596
19661
|
function getUseDefineForClassFields(compilerOptions) {
|
|
19597
|
-
return compilerOptions.useDefineForClassFields === undefined ? compilerOptions
|
|
19662
|
+
return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ : compilerOptions.useDefineForClassFields;
|
|
19598
19663
|
}
|
|
19599
19664
|
ts.getUseDefineForClassFields = getUseDefineForClassFields;
|
|
19600
19665
|
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
|
|
@@ -20034,51 +20099,54 @@ var ts;
|
|
|
20034
20099
|
}
|
|
20035
20100
|
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
20036
20101
|
/**
|
|
20037
|
-
*
|
|
20102
|
+
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
|
|
20038
20103
|
*/
|
|
20039
|
-
ts.supportedTSExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */];
|
|
20040
|
-
ts.
|
|
20104
|
+
ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
|
|
20105
|
+
ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions);
|
|
20106
|
+
var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false);
|
|
20041
20107
|
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
|
20042
|
-
|
|
20043
|
-
ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */];
|
|
20044
|
-
ts.
|
|
20045
|
-
var allSupportedExtensions =
|
|
20046
|
-
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(
|
|
20108
|
+
var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */];
|
|
20109
|
+
ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
|
|
20110
|
+
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20111
|
+
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 */]];
|
|
20112
|
+
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20047
20113
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20048
20114
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20049
20115
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
20050
20116
|
return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20051
20117
|
}
|
|
20052
|
-
var
|
|
20053
|
-
|
|
20118
|
+
var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20119
|
+
var flatBuiltins = ts.flatten(builtins);
|
|
20120
|
+
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);
|
|
20121
|
+
return extensions;
|
|
20054
20122
|
}
|
|
20055
20123
|
ts.getSupportedExtensions = getSupportedExtensions;
|
|
20056
|
-
function
|
|
20124
|
+
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
|
|
20057
20125
|
if (!options || !options.resolveJsonModule)
|
|
20058
20126
|
return supportedExtensions;
|
|
20059
20127
|
if (supportedExtensions === allSupportedExtensions)
|
|
20060
20128
|
return allSupportedExtensionsWithJson;
|
|
20061
20129
|
if (supportedExtensions === ts.supportedTSExtensions)
|
|
20062
|
-
return
|
|
20063
|
-
return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false);
|
|
20130
|
+
return supportedTSExtensionsWithJson;
|
|
20131
|
+
return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false);
|
|
20064
20132
|
}
|
|
20065
|
-
ts.
|
|
20133
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule;
|
|
20066
20134
|
function isJSLike(scriptKind) {
|
|
20067
20135
|
return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
|
|
20068
20136
|
}
|
|
20069
20137
|
function hasJSFileExtension(fileName) {
|
|
20070
|
-
return ts.some(ts.
|
|
20138
|
+
return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20071
20139
|
}
|
|
20072
20140
|
ts.hasJSFileExtension = hasJSFileExtension;
|
|
20073
20141
|
function hasTSFileExtension(fileName) {
|
|
20074
|
-
return ts.some(ts.
|
|
20142
|
+
return ts.some(ts.supportedTSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20075
20143
|
}
|
|
20076
20144
|
ts.hasTSFileExtension = hasTSFileExtension;
|
|
20077
20145
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
20078
20146
|
if (!fileName)
|
|
20079
20147
|
return false;
|
|
20080
20148
|
var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
|
|
20081
|
-
for (var _i = 0, _a =
|
|
20149
|
+
for (var _i = 0, _a = ts.flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)); _i < _a.length; _i++) {
|
|
20082
20150
|
var extension = _a[_i];
|
|
20083
20151
|
if (ts.fileExtensionIs(fileName, extension)) {
|
|
20084
20152
|
return true;
|
|
@@ -20095,57 +20163,7 @@ var ts;
|
|
|
20095
20163
|
return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
|
|
20096
20164
|
}
|
|
20097
20165
|
ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
|
|
20098
|
-
|
|
20099
|
-
* Extension boundaries by priority. Lower numbers indicate higher priorities, and are
|
|
20100
|
-
* aligned to the offset of the highest priority extension in the
|
|
20101
|
-
* allSupportedExtensions array.
|
|
20102
|
-
*/
|
|
20103
|
-
var ExtensionPriority;
|
|
20104
|
-
(function (ExtensionPriority) {
|
|
20105
|
-
ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles";
|
|
20106
|
-
ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles";
|
|
20107
|
-
ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest";
|
|
20108
|
-
ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest";
|
|
20109
|
-
})(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {}));
|
|
20110
|
-
function getExtensionPriority(path, supportedExtensions) {
|
|
20111
|
-
for (var i = supportedExtensions.length - 1; i >= 0; i--) {
|
|
20112
|
-
if (ts.fileExtensionIs(path, supportedExtensions[i])) {
|
|
20113
|
-
return adjustExtensionPriority(i, supportedExtensions);
|
|
20114
|
-
}
|
|
20115
|
-
}
|
|
20116
|
-
// If its not in the list of supported extensions, this is likely a
|
|
20117
|
-
// TypeScript file with a non-ts extension
|
|
20118
|
-
return 0 /* Highest */;
|
|
20119
|
-
}
|
|
20120
|
-
ts.getExtensionPriority = getExtensionPriority;
|
|
20121
|
-
/**
|
|
20122
|
-
* Adjusts an extension priority to be the highest priority within the same range.
|
|
20123
|
-
*/
|
|
20124
|
-
function adjustExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20125
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20126
|
-
return 0 /* TypeScriptFiles */;
|
|
20127
|
-
}
|
|
20128
|
-
else if (extensionPriority < supportedExtensions.length) {
|
|
20129
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20130
|
-
}
|
|
20131
|
-
else {
|
|
20132
|
-
return supportedExtensions.length;
|
|
20133
|
-
}
|
|
20134
|
-
}
|
|
20135
|
-
ts.adjustExtensionPriority = adjustExtensionPriority;
|
|
20136
|
-
/**
|
|
20137
|
-
* Gets the next lowest extension priority for a given priority.
|
|
20138
|
-
*/
|
|
20139
|
-
function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20140
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20141
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20142
|
-
}
|
|
20143
|
-
else {
|
|
20144
|
-
return supportedExtensions.length;
|
|
20145
|
-
}
|
|
20146
|
-
}
|
|
20147
|
-
ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
|
|
20148
|
-
var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
20166
|
+
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 */];
|
|
20149
20167
|
function removeFileExtension(path) {
|
|
20150
20168
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
|
|
20151
20169
|
var ext = extensionsToRemove_1[_i];
|
|
@@ -20679,6 +20697,15 @@ var ts;
|
|
|
20679
20697
|
return name === "Infinity" || name === "-Infinity" || name === "NaN";
|
|
20680
20698
|
}
|
|
20681
20699
|
ts.isInfinityOrNaNString = isInfinityOrNaNString;
|
|
20700
|
+
function isCatchClauseVariableDeclaration(node) {
|
|
20701
|
+
return node.kind === 252 /* VariableDeclaration */ && node.parent.kind === 290 /* CatchClause */;
|
|
20702
|
+
}
|
|
20703
|
+
ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration;
|
|
20704
|
+
function isParameterOrCatchClauseVariable(symbol) {
|
|
20705
|
+
var declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
|
|
20706
|
+
return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
|
|
20707
|
+
}
|
|
20708
|
+
ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable;
|
|
20682
20709
|
})(ts || (ts = {}));
|
|
20683
20710
|
/* @internal */
|
|
20684
20711
|
var ts;
|
|
@@ -25312,6 +25339,7 @@ var ts;
|
|
|
25312
25339
|
node.transformFlags =
|
|
25313
25340
|
propagateChildrenFlags(node.statements) |
|
|
25314
25341
|
propagateChildFlags(node.endOfFileToken);
|
|
25342
|
+
node.impliedNodeFormat = source.impliedNodeFormat;
|
|
25315
25343
|
return node;
|
|
25316
25344
|
}
|
|
25317
25345
|
// @api
|
|
@@ -26925,7 +26953,7 @@ var ts;
|
|
|
26925
26953
|
}
|
|
26926
26954
|
// ES2018 Helpers
|
|
26927
26955
|
function createAssignHelper(attributesSegments) {
|
|
26928
|
-
if (context.getCompilerOptions()
|
|
26956
|
+
if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
|
|
26929
26957
|
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
|
|
26930
26958
|
/*typeArguments*/ undefined, attributesSegments);
|
|
26931
26959
|
}
|
|
@@ -28787,7 +28815,7 @@ var ts;
|
|
|
28787
28815
|
if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
28788
28816
|
var namedBindings = void 0;
|
|
28789
28817
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28790
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
|
|
28818
|
+
if ((moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
28791
28819
|
// use named imports
|
|
28792
28820
|
var helpers = ts.getEmitHelpers(sourceFile);
|
|
28793
28821
|
if (helpers) {
|
|
@@ -28838,9 +28866,9 @@ var ts;
|
|
|
28838
28866
|
return externalHelpersModuleName;
|
|
28839
28867
|
}
|
|
28840
28868
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
28841
|
-
var create = (hasExportStarsToExportValues || (compilerOptions
|
|
28869
|
+
var create = (hasExportStarsToExportValues || (ts.getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
|
|
28842
28870
|
&& moduleKind !== ts.ModuleKind.System
|
|
28843
|
-
&& moduleKind < ts.ModuleKind.ES2015;
|
|
28871
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || node.impliedNodeFormat === ts.ModuleKind.CommonJS);
|
|
28844
28872
|
if (!create) {
|
|
28845
28873
|
var helpers = ts.getEmitHelpers(node);
|
|
28846
28874
|
if (helpers) {
|
|
@@ -38110,7 +38138,9 @@ var ts;
|
|
|
38110
38138
|
es6: ts.ModuleKind.ES2015,
|
|
38111
38139
|
es2015: ts.ModuleKind.ES2015,
|
|
38112
38140
|
es2020: ts.ModuleKind.ES2020,
|
|
38113
|
-
esnext: ts.ModuleKind.ESNext
|
|
38141
|
+
esnext: ts.ModuleKind.ESNext,
|
|
38142
|
+
node12: ts.ModuleKind.Node12,
|
|
38143
|
+
nodenext: ts.ModuleKind.NodeNext,
|
|
38114
38144
|
})),
|
|
38115
38145
|
affectsModuleResolution: true,
|
|
38116
38146
|
affectsEmit: true,
|
|
@@ -40536,7 +40566,7 @@ var ts;
|
|
|
40536
40566
|
// Rather than re-query this for each file and filespec, we query the supported extensions
|
|
40537
40567
|
// once and store it on the expansion context.
|
|
40538
40568
|
var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
|
|
40539
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
40569
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
40540
40570
|
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
|
40541
40571
|
// remove a literal file.
|
|
40542
40572
|
if (validatedFilesSpec) {
|
|
@@ -40584,7 +40614,7 @@ var ts;
|
|
|
40584
40614
|
wildcardFileMap.set(key, file);
|
|
40585
40615
|
}
|
|
40586
40616
|
};
|
|
40587
|
-
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40617
|
+
for (var _a = 0, _b = host.readDirectory(basePath, ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40588
40618
|
var file = _b[_a];
|
|
40589
40619
|
_loop_6(file);
|
|
40590
40620
|
}
|
|
@@ -40747,16 +40777,25 @@ var ts;
|
|
|
40747
40777
|
* extension priority.
|
|
40748
40778
|
*
|
|
40749
40779
|
* @param file The path to the file.
|
|
40750
|
-
* @param extensionPriority The priority of the extension.
|
|
40751
|
-
* @param context The expansion context.
|
|
40752
40780
|
*/
|
|
40753
40781
|
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
|
|
40754
|
-
var
|
|
40755
|
-
|
|
40756
|
-
|
|
40757
|
-
|
|
40758
|
-
|
|
40782
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40783
|
+
if (!extensionGroup) {
|
|
40784
|
+
return false;
|
|
40785
|
+
}
|
|
40786
|
+
for (var _i = 0, extensionGroup_1 = extensionGroup; _i < extensionGroup_1.length; _i++) {
|
|
40787
|
+
var ext = extensionGroup_1[_i];
|
|
40788
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
40789
|
+
return false;
|
|
40790
|
+
}
|
|
40791
|
+
var higherPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40759
40792
|
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
|
|
40793
|
+
if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) {
|
|
40794
|
+
// LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
|
|
40795
|
+
// files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
|
|
40796
|
+
// prevent breakage.
|
|
40797
|
+
continue;
|
|
40798
|
+
}
|
|
40760
40799
|
return true;
|
|
40761
40800
|
}
|
|
40762
40801
|
}
|
|
@@ -40767,15 +40806,18 @@ var ts;
|
|
|
40767
40806
|
* already been included.
|
|
40768
40807
|
*
|
|
40769
40808
|
* @param file The path to the file.
|
|
40770
|
-
* @param extensionPriority The priority of the extension.
|
|
40771
|
-
* @param context The expansion context.
|
|
40772
40809
|
*/
|
|
40773
40810
|
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
|
|
40774
|
-
var
|
|
40775
|
-
|
|
40776
|
-
|
|
40777
|
-
|
|
40778
|
-
|
|
40811
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
40812
|
+
if (!extensionGroup) {
|
|
40813
|
+
return;
|
|
40814
|
+
}
|
|
40815
|
+
for (var i = extensionGroup.length - 1; i >= 0; i--) {
|
|
40816
|
+
var ext = extensionGroup[i];
|
|
40817
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
40818
|
+
return;
|
|
40819
|
+
}
|
|
40820
|
+
var lowerPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
40779
40821
|
wildcardFiles.delete(lowerPriorityPath);
|
|
40780
40822
|
}
|
|
40781
40823
|
}
|
|
@@ -41035,7 +41077,7 @@ var ts;
|
|
|
41035
41077
|
}
|
|
41036
41078
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41037
41079
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41038
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName);
|
|
41080
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
|
|
41039
41081
|
if (result) {
|
|
41040
41082
|
if (traceEnabled) {
|
|
41041
41083
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41069,7 +41111,7 @@ var ts;
|
|
|
41069
41111
|
}
|
|
41070
41112
|
}
|
|
41071
41113
|
var failedLookupLocations = [];
|
|
41072
|
-
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
41114
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
|
|
41073
41115
|
var resolved = primaryLookup();
|
|
41074
41116
|
var primary = true;
|
|
41075
41117
|
if (!resolved) {
|
|
@@ -41089,7 +41131,7 @@ var ts;
|
|
|
41089
41131
|
};
|
|
41090
41132
|
}
|
|
41091
41133
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41092
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result);
|
|
41134
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
|
|
41093
41135
|
if (traceEnabled)
|
|
41094
41136
|
traceResult(result);
|
|
41095
41137
|
return result;
|
|
@@ -41302,9 +41344,56 @@ var ts;
|
|
|
41302
41344
|
}
|
|
41303
41345
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
41304
41346
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
41305
|
-
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return
|
|
41347
|
+
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
|
|
41306
41348
|
}
|
|
41307
41349
|
}
|
|
41350
|
+
/* @internal */
|
|
41351
|
+
function createModeAwareCache() {
|
|
41352
|
+
var underlying = new ts.Map();
|
|
41353
|
+
var memoizedReverseKeys = new ts.Map();
|
|
41354
|
+
var cache = {
|
|
41355
|
+
get: function (specifier, mode) {
|
|
41356
|
+
return underlying.get(getUnderlyingCacheKey(specifier, mode));
|
|
41357
|
+
},
|
|
41358
|
+
set: function (specifier, mode, value) {
|
|
41359
|
+
underlying.set(getUnderlyingCacheKey(specifier, mode), value);
|
|
41360
|
+
return cache;
|
|
41361
|
+
},
|
|
41362
|
+
delete: function (specifier, mode) {
|
|
41363
|
+
underlying.delete(getUnderlyingCacheKey(specifier, mode));
|
|
41364
|
+
return cache;
|
|
41365
|
+
},
|
|
41366
|
+
has: function (specifier, mode) {
|
|
41367
|
+
return underlying.has(getUnderlyingCacheKey(specifier, mode));
|
|
41368
|
+
},
|
|
41369
|
+
forEach: function (cb) {
|
|
41370
|
+
return underlying.forEach(function (elem, key) {
|
|
41371
|
+
var _a = memoizedReverseKeys.get(key), specifier = _a[0], mode = _a[1];
|
|
41372
|
+
return cb(elem, specifier, mode);
|
|
41373
|
+
});
|
|
41374
|
+
},
|
|
41375
|
+
size: function () {
|
|
41376
|
+
return underlying.size;
|
|
41377
|
+
}
|
|
41378
|
+
};
|
|
41379
|
+
return cache;
|
|
41380
|
+
function getUnderlyingCacheKey(specifier, mode) {
|
|
41381
|
+
var result = mode === undefined ? specifier : mode + "|" + specifier;
|
|
41382
|
+
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
41383
|
+
return result;
|
|
41384
|
+
}
|
|
41385
|
+
}
|
|
41386
|
+
ts.createModeAwareCache = createModeAwareCache;
|
|
41387
|
+
/* @internal */
|
|
41388
|
+
function zipToModeAwareCache(file, keys, values) {
|
|
41389
|
+
ts.Debug.assert(keys.length === values.length);
|
|
41390
|
+
var map = createModeAwareCache();
|
|
41391
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
41392
|
+
map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
|
|
41393
|
+
}
|
|
41394
|
+
return map;
|
|
41395
|
+
}
|
|
41396
|
+
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
41308
41397
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
41309
41398
|
var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
41310
41399
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
@@ -41318,9 +41407,9 @@ var ts;
|
|
|
41318
41407
|
function update(options) {
|
|
41319
41408
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
41320
41409
|
}
|
|
41321
|
-
function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
|
|
41410
|
+
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
41322
41411
|
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
41323
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
|
|
41412
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
|
|
41324
41413
|
}
|
|
41325
41414
|
function createPerModuleNameCache() {
|
|
41326
41415
|
var directoryPathMap = new ts.Map();
|
|
@@ -41399,13 +41488,15 @@ var ts;
|
|
|
41399
41488
|
}
|
|
41400
41489
|
}
|
|
41401
41490
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
41402
|
-
function resolveModuleNameFromCache(moduleName, containingFile, cache) {
|
|
41491
|
+
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
41403
41492
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41404
41493
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
41405
|
-
|
|
41494
|
+
if (!perFolderCache)
|
|
41495
|
+
return undefined;
|
|
41496
|
+
return perFolderCache.get(moduleName, mode);
|
|
41406
41497
|
}
|
|
41407
41498
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
41408
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
41499
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41409
41500
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41410
41501
|
if (redirectedReference) {
|
|
41411
41502
|
compilerOptions = redirectedReference.commandLine.options;
|
|
@@ -41418,7 +41509,7 @@ var ts;
|
|
|
41418
41509
|
}
|
|
41419
41510
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41420
41511
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
|
|
41421
|
-
var result = perFolderCache && perFolderCache.get(moduleName);
|
|
41512
|
+
var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
41422
41513
|
if (result) {
|
|
41423
41514
|
if (traceEnabled) {
|
|
41424
41515
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -41427,7 +41518,20 @@ var ts;
|
|
|
41427
41518
|
else {
|
|
41428
41519
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
41429
41520
|
if (moduleResolution === undefined) {
|
|
41430
|
-
|
|
41521
|
+
switch (ts.getEmitModuleKind(compilerOptions)) {
|
|
41522
|
+
case ts.ModuleKind.CommonJS:
|
|
41523
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
41524
|
+
break;
|
|
41525
|
+
case ts.ModuleKind.Node12:
|
|
41526
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
41527
|
+
break;
|
|
41528
|
+
case ts.ModuleKind.NodeNext:
|
|
41529
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
41530
|
+
break;
|
|
41531
|
+
default:
|
|
41532
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
41533
|
+
break;
|
|
41534
|
+
}
|
|
41431
41535
|
if (traceEnabled) {
|
|
41432
41536
|
trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
41433
41537
|
}
|
|
@@ -41439,6 +41543,12 @@ var ts;
|
|
|
41439
41543
|
}
|
|
41440
41544
|
ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
|
|
41441
41545
|
switch (moduleResolution) {
|
|
41546
|
+
case ts.ModuleResolutionKind.Node12:
|
|
41547
|
+
result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41548
|
+
break;
|
|
41549
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
41550
|
+
result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41551
|
+
break;
|
|
41442
41552
|
case ts.ModuleResolutionKind.NodeJs:
|
|
41443
41553
|
result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
41444
41554
|
break;
|
|
@@ -41452,10 +41562,10 @@ var ts;
|
|
|
41452
41562
|
ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
|
|
41453
41563
|
ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
41454
41564
|
if (perFolderCache) {
|
|
41455
|
-
perFolderCache.set(moduleName, result);
|
|
41565
|
+
perFolderCache.set(moduleName, resolutionMode, result);
|
|
41456
41566
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41457
41567
|
// put result in per-module name cache
|
|
41458
|
-
cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
|
|
41568
|
+
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
41459
41569
|
}
|
|
41460
41570
|
}
|
|
41461
41571
|
}
|
|
@@ -41662,22 +41772,51 @@ var ts;
|
|
|
41662
41772
|
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
41663
41773
|
}
|
|
41664
41774
|
ts.tryResolveJSModule = tryResolveJSModule;
|
|
41775
|
+
/* @internal */
|
|
41776
|
+
var NodeResolutionFeatures;
|
|
41777
|
+
(function (NodeResolutionFeatures) {
|
|
41778
|
+
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
41779
|
+
// resolving `#local` names in your own package.json
|
|
41780
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Imports"] = 2] = "Imports";
|
|
41781
|
+
// resolving `your-own-name` from your own package.json
|
|
41782
|
+
NodeResolutionFeatures[NodeResolutionFeatures["SelfName"] = 4] = "SelfName";
|
|
41783
|
+
// respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
|
|
41784
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
|
|
41785
|
+
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
|
|
41786
|
+
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
41787
|
+
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
41788
|
+
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
41789
|
+
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
41790
|
+
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
41791
|
+
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41792
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41793
|
+
}
|
|
41794
|
+
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41795
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41796
|
+
}
|
|
41797
|
+
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41798
|
+
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41799
|
+
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
41800
|
+
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
41801
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
|
|
41802
|
+
}
|
|
41665
41803
|
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
41666
41804
|
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
41667
41805
|
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
41668
41806
|
var tsconfigExtensions = [Extensions.TSConfig];
|
|
41669
41807
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
41670
|
-
return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41808
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41671
41809
|
}
|
|
41672
41810
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
41673
|
-
return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41811
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41674
41812
|
}
|
|
41675
41813
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
41676
|
-
function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41814
|
+
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41677
41815
|
var _a, _b;
|
|
41678
41816
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41679
41817
|
var failedLookupLocations = [];
|
|
41680
|
-
|
|
41818
|
+
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list, it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
41819
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] };
|
|
41681
41820
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
41682
41821
|
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);
|
|
41683
41822
|
function tryResolve(extensions) {
|
|
@@ -41687,10 +41826,19 @@ var ts;
|
|
|
41687
41826
|
return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
41688
41827
|
}
|
|
41689
41828
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41690
|
-
|
|
41691
|
-
|
|
41829
|
+
var resolved_1;
|
|
41830
|
+
if (features & NodeResolutionFeatures.Imports && ts.startsWith(moduleName, "#")) {
|
|
41831
|
+
resolved_1 = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41832
|
+
}
|
|
41833
|
+
if (!resolved_1 && features & NodeResolutionFeatures.SelfName) {
|
|
41834
|
+
resolved_1 = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41835
|
+
}
|
|
41836
|
+
if (!resolved_1) {
|
|
41837
|
+
if (traceEnabled) {
|
|
41838
|
+
trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
|
|
41839
|
+
}
|
|
41840
|
+
resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41692
41841
|
}
|
|
41693
|
-
var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
41694
41842
|
if (!resolved_1)
|
|
41695
41843
|
return undefined;
|
|
41696
41844
|
var resolvedValue = resolved_1.value;
|
|
@@ -41799,26 +41947,33 @@ var ts;
|
|
|
41799
41947
|
function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
|
|
41800
41948
|
if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
|
|
41801
41949
|
var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
|
|
41802
|
-
|
|
41950
|
+
var extension = extensionLess ? candidate.substring(extensionLess.length) : "";
|
|
41951
|
+
return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
|
|
41803
41952
|
}
|
|
41804
|
-
//
|
|
41805
|
-
|
|
41806
|
-
|
|
41807
|
-
|
|
41953
|
+
// esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
|
|
41954
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
41955
|
+
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
|
|
41956
|
+
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
|
|
41957
|
+
if (resolvedByAddingExtension) {
|
|
41958
|
+
return resolvedByAddingExtension;
|
|
41959
|
+
}
|
|
41808
41960
|
}
|
|
41961
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
41962
|
+
}
|
|
41963
|
+
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
41809
41964
|
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
|
|
41810
41965
|
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
|
|
41811
|
-
if (ts.hasJSFileExtension(candidate)) {
|
|
41966
|
+
if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) {
|
|
41812
41967
|
var extensionless = ts.removeFileExtension(candidate);
|
|
41968
|
+
var extension = candidate.substring(extensionless.length);
|
|
41813
41969
|
if (state.traceEnabled) {
|
|
41814
|
-
var extension = candidate.substring(extensionless.length);
|
|
41815
41970
|
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
41816
41971
|
}
|
|
41817
|
-
return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
|
|
41972
|
+
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
41818
41973
|
}
|
|
41819
41974
|
}
|
|
41820
41975
|
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
|
|
41821
|
-
function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
|
|
41976
|
+
function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecordFailures, state) {
|
|
41822
41977
|
if (!onlyRecordFailures) {
|
|
41823
41978
|
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
|
41824
41979
|
var directory = ts.getDirectoryPath(candidate);
|
|
@@ -41828,11 +41983,51 @@ var ts;
|
|
|
41828
41983
|
}
|
|
41829
41984
|
switch (extensions) {
|
|
41830
41985
|
case Extensions.DtsOnly:
|
|
41831
|
-
|
|
41986
|
+
switch (originalExtension) {
|
|
41987
|
+
case ".mjs" /* Mjs */:
|
|
41988
|
+
case ".mts" /* Mts */:
|
|
41989
|
+
case ".d.mts" /* Dmts */:
|
|
41990
|
+
return tryExtension(".d.mts" /* Dmts */);
|
|
41991
|
+
case ".cjs" /* Cjs */:
|
|
41992
|
+
case ".cts" /* Cts */:
|
|
41993
|
+
case ".d.cts" /* Dcts */:
|
|
41994
|
+
return tryExtension(".d.cts" /* Dcts */);
|
|
41995
|
+
case ".json" /* Json */:
|
|
41996
|
+
candidate += ".json" /* Json */;
|
|
41997
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
41998
|
+
default: return tryExtension(".d.ts" /* Dts */);
|
|
41999
|
+
}
|
|
41832
42000
|
case Extensions.TypeScript:
|
|
41833
|
-
|
|
42001
|
+
switch (originalExtension) {
|
|
42002
|
+
case ".mjs" /* Mjs */:
|
|
42003
|
+
case ".mts" /* Mts */:
|
|
42004
|
+
case ".d.mts" /* Dmts */:
|
|
42005
|
+
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
42006
|
+
case ".cjs" /* Cjs */:
|
|
42007
|
+
case ".cts" /* Cts */:
|
|
42008
|
+
case ".d.cts" /* Dcts */:
|
|
42009
|
+
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
42010
|
+
case ".json" /* Json */:
|
|
42011
|
+
candidate += ".json" /* Json */;
|
|
42012
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42013
|
+
default:
|
|
42014
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
42015
|
+
}
|
|
41834
42016
|
case Extensions.JavaScript:
|
|
41835
|
-
|
|
42017
|
+
switch (originalExtension) {
|
|
42018
|
+
case ".mjs" /* Mjs */:
|
|
42019
|
+
case ".mts" /* Mts */:
|
|
42020
|
+
case ".d.mts" /* Dmts */:
|
|
42021
|
+
return tryExtension(".mjs" /* Mjs */);
|
|
42022
|
+
case ".cjs" /* Cjs */:
|
|
42023
|
+
case ".cts" /* Cts */:
|
|
42024
|
+
case ".d.cts" /* Dcts */:
|
|
42025
|
+
return tryExtension(".cjs" /* Cjs */);
|
|
42026
|
+
case ".json" /* Json */:
|
|
42027
|
+
return tryExtension(".json" /* Json */);
|
|
42028
|
+
default:
|
|
42029
|
+
return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
|
|
42030
|
+
}
|
|
41836
42031
|
case Extensions.TSConfig:
|
|
41837
42032
|
case Extensions.Json:
|
|
41838
42033
|
return tryExtension(".json" /* Json */);
|
|
@@ -41867,6 +42062,33 @@ var ts;
|
|
|
41867
42062
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
41868
42063
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
41869
42064
|
}
|
|
42065
|
+
/**
|
|
42066
|
+
* A function for locating the package.json scope for a given path
|
|
42067
|
+
*/
|
|
42068
|
+
/*@internal*/
|
|
42069
|
+
function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
|
|
42070
|
+
var state = {
|
|
42071
|
+
host: host,
|
|
42072
|
+
compilerOptions: options,
|
|
42073
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42074
|
+
failedLookupLocations: [],
|
|
42075
|
+
packageJsonInfoCache: packageJsonInfoCache,
|
|
42076
|
+
features: 0,
|
|
42077
|
+
conditions: [],
|
|
42078
|
+
};
|
|
42079
|
+
var parts = ts.getPathComponents(fileName);
|
|
42080
|
+
parts.pop();
|
|
42081
|
+
while (parts.length > 0) {
|
|
42082
|
+
var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
|
42083
|
+
if (pkg) {
|
|
42084
|
+
return pkg;
|
|
42085
|
+
}
|
|
42086
|
+
parts.pop();
|
|
42087
|
+
}
|
|
42088
|
+
return undefined;
|
|
42089
|
+
}
|
|
42090
|
+
ts.getPackageScopeForPath = getPackageScopeForPath;
|
|
42091
|
+
/*@internal*/
|
|
41870
42092
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
41871
42093
|
var _a, _b, _c;
|
|
41872
42094
|
var host = state.host, traceEnabled = state.traceEnabled;
|
|
@@ -41909,6 +42131,7 @@ var ts;
|
|
|
41909
42131
|
state.failedLookupLocations.push(packageJsonPath);
|
|
41910
42132
|
}
|
|
41911
42133
|
}
|
|
42134
|
+
ts.getPackageJsonInfo = getPackageJsonInfo;
|
|
41912
42135
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
41913
42136
|
var packageFile;
|
|
41914
42137
|
if (jsonContent) {
|
|
@@ -41964,7 +42187,10 @@ var ts;
|
|
|
41964
42187
|
var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
|
|
41965
42188
|
if (packageFileResult)
|
|
41966
42189
|
return packageFileResult;
|
|
41967
|
-
|
|
42190
|
+
// esm mode resolutions don't do package `index` lookups
|
|
42191
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42192
|
+
return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
|
|
42193
|
+
}
|
|
41968
42194
|
}
|
|
41969
42195
|
/** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
|
|
41970
42196
|
function resolvedIfExtensionMatches(extensions, path) {
|
|
@@ -41994,6 +42220,216 @@ var ts;
|
|
|
41994
42220
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
41995
42221
|
}
|
|
41996
42222
|
ts.parsePackageName = parsePackageName;
|
|
42223
|
+
function allKeysStartWithDot(obj) {
|
|
42224
|
+
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42225
|
+
}
|
|
42226
|
+
function noKeyStartsWithDot(obj) {
|
|
42227
|
+
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42228
|
+
}
|
|
42229
|
+
function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42230
|
+
var _a, _b;
|
|
42231
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42232
|
+
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));
|
|
42233
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42234
|
+
if (!scope || !scope.packageJsonContent.exports) {
|
|
42235
|
+
return undefined;
|
|
42236
|
+
}
|
|
42237
|
+
var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
|
|
42238
|
+
if (scope.packageJsonContent.name !== parts[1]) {
|
|
42239
|
+
return undefined;
|
|
42240
|
+
}
|
|
42241
|
+
var trailingParts = parts.slice(2);
|
|
42242
|
+
return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference);
|
|
42243
|
+
}
|
|
42244
|
+
function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
|
|
42245
|
+
if (!scope.packageJsonContent.exports) {
|
|
42246
|
+
return undefined;
|
|
42247
|
+
}
|
|
42248
|
+
if (subpath === ".") {
|
|
42249
|
+
var mainExport = void 0;
|
|
42250
|
+
if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports))) {
|
|
42251
|
+
mainExport = scope.packageJsonContent.exports;
|
|
42252
|
+
}
|
|
42253
|
+
else if (ts.hasProperty(scope.packageJsonContent.exports, ".")) {
|
|
42254
|
+
mainExport = scope.packageJsonContent.exports["."];
|
|
42255
|
+
}
|
|
42256
|
+
if (mainExport) {
|
|
42257
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
42258
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
42259
|
+
}
|
|
42260
|
+
}
|
|
42261
|
+
else if (allKeysStartWithDot(scope.packageJsonContent.exports)) {
|
|
42262
|
+
if (typeof scope.packageJsonContent.exports !== "object") {
|
|
42263
|
+
if (state.traceEnabled) {
|
|
42264
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42265
|
+
}
|
|
42266
|
+
return toSearchResult(/*value*/ undefined);
|
|
42267
|
+
}
|
|
42268
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false);
|
|
42269
|
+
if (result) {
|
|
42270
|
+
return result;
|
|
42271
|
+
}
|
|
42272
|
+
}
|
|
42273
|
+
if (state.traceEnabled) {
|
|
42274
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42275
|
+
}
|
|
42276
|
+
return toSearchResult(/*value*/ undefined);
|
|
42277
|
+
}
|
|
42278
|
+
function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42279
|
+
var _a, _b;
|
|
42280
|
+
if (moduleName === "#" || ts.startsWith(moduleName, "#/")) {
|
|
42281
|
+
if (state.traceEnabled) {
|
|
42282
|
+
trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
|
|
42283
|
+
}
|
|
42284
|
+
return toSearchResult(/*value*/ undefined);
|
|
42285
|
+
}
|
|
42286
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42287
|
+
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));
|
|
42288
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42289
|
+
if (!scope) {
|
|
42290
|
+
if (state.traceEnabled) {
|
|
42291
|
+
trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
|
|
42292
|
+
}
|
|
42293
|
+
return toSearchResult(/*value*/ undefined);
|
|
42294
|
+
}
|
|
42295
|
+
if (!scope.packageJsonContent.imports) {
|
|
42296
|
+
if (state.traceEnabled) {
|
|
42297
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
|
|
42298
|
+
}
|
|
42299
|
+
return toSearchResult(/*value*/ undefined);
|
|
42300
|
+
}
|
|
42301
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
|
|
42302
|
+
if (result) {
|
|
42303
|
+
return result;
|
|
42304
|
+
}
|
|
42305
|
+
if (state.traceEnabled) {
|
|
42306
|
+
trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
|
|
42307
|
+
}
|
|
42308
|
+
return toSearchResult(/*value*/ undefined);
|
|
42309
|
+
}
|
|
42310
|
+
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
42311
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
42312
|
+
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
42313
|
+
var target = lookupTable[moduleName];
|
|
42314
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
42315
|
+
}
|
|
42316
|
+
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; });
|
|
42317
|
+
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
42318
|
+
var potentialTarget = expandingKeys_1[_i];
|
|
42319
|
+
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
42320
|
+
var target = lookupTable[potentialTarget];
|
|
42321
|
+
var starPos = potentialTarget.indexOf("*");
|
|
42322
|
+
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
42323
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42324
|
+
}
|
|
42325
|
+
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
42326
|
+
var target = lookupTable[potentialTarget];
|
|
42327
|
+
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
42328
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42329
|
+
}
|
|
42330
|
+
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
42331
|
+
var target = lookupTable[potentialTarget];
|
|
42332
|
+
var subpath = moduleName.substring(potentialTarget.length);
|
|
42333
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
42334
|
+
}
|
|
42335
|
+
}
|
|
42336
|
+
function matchesPatternWithTrailer(target, name) {
|
|
42337
|
+
if (ts.endsWith(target, "*"))
|
|
42338
|
+
return false; // handled by next case in loop
|
|
42339
|
+
var starPos = target.indexOf("*");
|
|
42340
|
+
if (starPos === -1)
|
|
42341
|
+
return false; // handled by last case in loop
|
|
42342
|
+
return ts.startsWith(name, target.substring(0, starPos)) && ts.endsWith(name, target.substring(starPos + 1));
|
|
42343
|
+
}
|
|
42344
|
+
}
|
|
42345
|
+
/**
|
|
42346
|
+
* Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
|
|
42347
|
+
*/
|
|
42348
|
+
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
42349
|
+
return loadModuleFromTargetImportOrExport;
|
|
42350
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
42351
|
+
var _a, _b;
|
|
42352
|
+
if (typeof target === "string") {
|
|
42353
|
+
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
42354
|
+
if (state.traceEnabled) {
|
|
42355
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42356
|
+
}
|
|
42357
|
+
return toSearchResult(/*value*/ undefined);
|
|
42358
|
+
}
|
|
42359
|
+
if (!ts.startsWith(target, "./")) {
|
|
42360
|
+
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
42361
|
+
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
42362
|
+
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
42363
|
+
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
42364
|
+
}
|
|
42365
|
+
if (state.traceEnabled) {
|
|
42366
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42367
|
+
}
|
|
42368
|
+
return toSearchResult(/*value*/ undefined);
|
|
42369
|
+
}
|
|
42370
|
+
var parts = ts.pathIsRelative(target) ? ts.getPathComponents(target).slice(1) : ts.getPathComponents(target);
|
|
42371
|
+
var partsAfterFirst = parts.slice(1);
|
|
42372
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42373
|
+
if (state.traceEnabled) {
|
|
42374
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42375
|
+
}
|
|
42376
|
+
return toSearchResult(/*value*/ undefined);
|
|
42377
|
+
}
|
|
42378
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42379
|
+
// TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
|
|
42380
|
+
// to be in the business of validating everyone's import and export map correctness.
|
|
42381
|
+
var subpathParts = ts.getPathComponents(subpath);
|
|
42382
|
+
if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) {
|
|
42383
|
+
if (state.traceEnabled) {
|
|
42384
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42385
|
+
}
|
|
42386
|
+
return toSearchResult(/*value*/ undefined);
|
|
42387
|
+
}
|
|
42388
|
+
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));
|
|
42389
|
+
return toSearchResult(withPackageId(scope, loadModuleFromFileNoImplicitExtensions(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
42390
|
+
}
|
|
42391
|
+
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
42392
|
+
if (!Array.isArray(target)) {
|
|
42393
|
+
for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
|
|
42394
|
+
var key = _c[_i];
|
|
42395
|
+
if (key === "default" || state.conditions.indexOf(key) >= 0) {
|
|
42396
|
+
var subTarget = target[key];
|
|
42397
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
42398
|
+
if (result) {
|
|
42399
|
+
return result;
|
|
42400
|
+
}
|
|
42401
|
+
}
|
|
42402
|
+
}
|
|
42403
|
+
return undefined;
|
|
42404
|
+
}
|
|
42405
|
+
else {
|
|
42406
|
+
if (!ts.length(target)) {
|
|
42407
|
+
if (state.traceEnabled) {
|
|
42408
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42409
|
+
}
|
|
42410
|
+
return toSearchResult(/*value*/ undefined);
|
|
42411
|
+
}
|
|
42412
|
+
for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
|
|
42413
|
+
var elem = target_1[_d];
|
|
42414
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
42415
|
+
if (result) {
|
|
42416
|
+
return result;
|
|
42417
|
+
}
|
|
42418
|
+
}
|
|
42419
|
+
}
|
|
42420
|
+
}
|
|
42421
|
+
else if (target === null) { // eslint-disable-line no-null/no-null
|
|
42422
|
+
if (state.traceEnabled) {
|
|
42423
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName);
|
|
42424
|
+
}
|
|
42425
|
+
return toSearchResult(/*value*/ undefined);
|
|
42426
|
+
}
|
|
42427
|
+
if (state.traceEnabled) {
|
|
42428
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42429
|
+
}
|
|
42430
|
+
return toSearchResult(/*value*/ undefined);
|
|
42431
|
+
}
|
|
42432
|
+
}
|
|
41997
42433
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
41998
42434
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
41999
42435
|
}
|
|
@@ -42002,24 +42438,24 @@ var ts;
|
|
|
42002
42438
|
return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42003
42439
|
}
|
|
42004
42440
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42005
|
-
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42441
|
+
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
|
|
42006
42442
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
42007
42443
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
42008
42444
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
|
|
42009
42445
|
if (resolutionFromCache) {
|
|
42010
42446
|
return resolutionFromCache;
|
|
42011
42447
|
}
|
|
42012
|
-
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
|
|
42448
|
+
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
|
|
42013
42449
|
}
|
|
42014
42450
|
});
|
|
42015
42451
|
}
|
|
42016
|
-
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
|
|
42452
|
+
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42017
42453
|
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
|
|
42018
42454
|
var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
|
|
42019
42455
|
if (!nodeModulesFolderExists && state.traceEnabled) {
|
|
42020
42456
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
|
|
42021
42457
|
}
|
|
42022
|
-
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
|
|
42458
|
+
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
|
|
42023
42459
|
if (packageResult) {
|
|
42024
42460
|
return packageResult;
|
|
42025
42461
|
}
|
|
@@ -42032,27 +42468,35 @@ var ts;
|
|
|
42032
42468
|
}
|
|
42033
42469
|
nodeModulesAtTypesExists = false;
|
|
42034
42470
|
}
|
|
42035
|
-
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
|
|
42471
|
+
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state, cache, redirectedReference);
|
|
42036
42472
|
}
|
|
42037
42473
|
}
|
|
42038
|
-
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
|
|
42474
|
+
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
|
|
42039
42475
|
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
|
|
42040
42476
|
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
|
|
42041
42477
|
var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
|
|
42042
|
-
if (
|
|
42043
|
-
|
|
42044
|
-
if (
|
|
42045
|
-
|
|
42478
|
+
// But only if we're not respecting export maps (if we are, we might redirect around this location)
|
|
42479
|
+
if (!(state.features & NodeResolutionFeatures.Exports)) {
|
|
42480
|
+
if (packageInfo) {
|
|
42481
|
+
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
|
|
42482
|
+
if (fromFile) {
|
|
42483
|
+
return noPackageId(fromFile);
|
|
42484
|
+
}
|
|
42485
|
+
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42486
|
+
return withPackageId(packageInfo, fromDirectory);
|
|
42046
42487
|
}
|
|
42047
|
-
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42048
|
-
return withPackageId(packageInfo, fromDirectory);
|
|
42049
42488
|
}
|
|
42489
|
+
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42050
42490
|
var loader = function (extensions, candidate, onlyRecordFailures, state) {
|
|
42491
|
+
var _a;
|
|
42492
|
+
// package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
|
|
42493
|
+
if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
|
|
42494
|
+
return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
|
|
42495
|
+
}
|
|
42051
42496
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
42052
42497
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
42053
42498
|
return withPackageId(packageInfo, pathAndExtension);
|
|
42054
42499
|
};
|
|
42055
|
-
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42056
42500
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
42057
42501
|
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
|
|
42058
42502
|
// 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.
|
|
@@ -42154,7 +42598,7 @@ var ts;
|
|
|
42154
42598
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
42155
42599
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
42156
42600
|
var failedLookupLocations = [];
|
|
42157
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
42601
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42158
42602
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
42159
42603
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
42160
42604
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
@@ -42165,7 +42609,7 @@ var ts;
|
|
|
42165
42609
|
return { value: resolvedUsingSettings };
|
|
42166
42610
|
}
|
|
42167
42611
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
42168
|
-
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42612
|
+
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
|
|
42169
42613
|
// Climb up parent directories looking for a module.
|
|
42170
42614
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
42171
42615
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
|
|
@@ -42201,8 +42645,8 @@ var ts;
|
|
|
42201
42645
|
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);
|
|
42202
42646
|
}
|
|
42203
42647
|
var failedLookupLocations = [];
|
|
42204
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache };
|
|
42205
|
-
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false);
|
|
42648
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42649
|
+
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42206
42650
|
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
42207
42651
|
}
|
|
42208
42652
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
@@ -44383,7 +44827,7 @@ var ts;
|
|
|
44383
44827
|
}
|
|
44384
44828
|
function checkStrictModeLabeledStatement(node) {
|
|
44385
44829
|
// Grammar checking for labeledStatement
|
|
44386
|
-
if (inStrictMode && options
|
|
44830
|
+
if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) {
|
|
44387
44831
|
if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
|
|
44388
44832
|
errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
|
|
44389
44833
|
}
|
|
@@ -45899,7 +46343,7 @@ var ts;
|
|
|
45899
46343
|
host.getSourceFiles().forEach(function (sf) {
|
|
45900
46344
|
if (!sf.resolvedModules)
|
|
45901
46345
|
return;
|
|
45902
|
-
|
|
46346
|
+
sf.resolvedModules.forEach(function (r) {
|
|
45903
46347
|
if (r && r.packageId)
|
|
45904
46348
|
map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
|
|
45905
46349
|
});
|
|
@@ -47041,7 +47485,7 @@ var ts;
|
|
|
47041
47485
|
}
|
|
47042
47486
|
else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
47043
47487
|
// foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
|
|
47044
|
-
return !(compilerOptions
|
|
47488
|
+
return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47045
47489
|
&& ts.getContainingClass(declaration) === ts.getContainingClass(usage)
|
|
47046
47490
|
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
47047
47491
|
}
|
|
@@ -47069,7 +47513,7 @@ var ts;
|
|
|
47069
47513
|
return true;
|
|
47070
47514
|
}
|
|
47071
47515
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
47072
|
-
if (compilerOptions
|
|
47516
|
+
if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47073
47517
|
&& ts.getContainingClass(declaration)
|
|
47074
47518
|
&& (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
47075
47519
|
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
|
@@ -47440,7 +47884,7 @@ var ts;
|
|
|
47440
47884
|
case 212 /* ArrowFunction */:
|
|
47441
47885
|
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
|
47442
47886
|
// for lower compile targets the resolved symbol is used to emit an error
|
|
47443
|
-
if (compilerOptions
|
|
47887
|
+
if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
|
|
47444
47888
|
break;
|
|
47445
47889
|
}
|
|
47446
47890
|
// falls through
|
|
@@ -47608,7 +48052,7 @@ var ts;
|
|
|
47608
48052
|
}
|
|
47609
48053
|
// Perform extra checks only if error reporting was requested
|
|
47610
48054
|
if (nameNotFoundMessage) {
|
|
47611
|
-
if (propertyWithInvalidInitializer && !(compilerOptions
|
|
48055
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
47612
48056
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
47613
48057
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
47614
48058
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -48186,7 +48630,7 @@ var ts;
|
|
|
48186
48630
|
if (!ts.isIdentifier(name)) {
|
|
48187
48631
|
return undefined;
|
|
48188
48632
|
}
|
|
48189
|
-
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions
|
|
48633
|
+
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
|
|
48190
48634
|
var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
|
|
48191
48635
|
if (targetSymbol) {
|
|
48192
48636
|
if (name.escapedText) {
|
|
@@ -48264,18 +48708,18 @@ var ts;
|
|
|
48264
48708
|
}
|
|
48265
48709
|
function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
|
|
48266
48710
|
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
48267
|
-
var message = compilerOptions
|
|
48711
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
|
|
48268
48712
|
ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48269
48713
|
error(name, message, declarationName);
|
|
48270
48714
|
}
|
|
48271
48715
|
else {
|
|
48272
48716
|
if (ts.isInJSFile(node)) {
|
|
48273
|
-
var message = compilerOptions
|
|
48717
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
|
|
48274
48718
|
ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48275
48719
|
error(name, message, declarationName);
|
|
48276
48720
|
}
|
|
48277
48721
|
else {
|
|
48278
|
-
var message = compilerOptions
|
|
48722
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
|
|
48279
48723
|
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;
|
|
48280
48724
|
error(name, message, declarationName, declarationName, moduleName);
|
|
48281
48725
|
}
|
|
@@ -48716,6 +49160,7 @@ var ts;
|
|
|
48716
49160
|
: undefined;
|
|
48717
49161
|
}
|
|
48718
49162
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
49163
|
+
var _a, _b, _c, _d;
|
|
48719
49164
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
48720
49165
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
48721
49166
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -48727,7 +49172,13 @@ var ts;
|
|
|
48727
49172
|
return ambientModule;
|
|
48728
49173
|
}
|
|
48729
49174
|
var currentSourceFile = ts.getSourceFileOfNode(location);
|
|
48730
|
-
var
|
|
49175
|
+
var contextSpecifier = ts.isStringLiteralLike(location)
|
|
49176
|
+
? location
|
|
49177
|
+
: ((_a = (ts.isImportCall(location) ? location : ts.findAncestor(location, ts.isImportCall))) === null || _a === void 0 ? void 0 : _a.arguments[0]) ||
|
|
49178
|
+
((_b = (ts.isImportDeclaration(location) ? location : ts.findAncestor(location, ts.isImportDeclaration))) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) ||
|
|
49179
|
+
((_c = (ts.isExternalModuleImportEqualsDeclaration(location) ? location : ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration))) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) ||
|
|
49180
|
+
((_d = (ts.isExportDeclaration(location) ? location : ts.findAncestor(location, ts.isExportDeclaration))) === null || _d === void 0 ? void 0 : _d.moduleSpecifier);
|
|
49181
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
|
|
48731
49182
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
48732
49183
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
48733
49184
|
if (sourceFile) {
|
|
@@ -48735,6 +49186,12 @@ var ts;
|
|
|
48735
49186
|
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
48736
49187
|
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
|
48737
49188
|
}
|
|
49189
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
|
|
49190
|
+
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
|
|
49191
|
+
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49192
|
+
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);
|
|
49193
|
+
}
|
|
49194
|
+
}
|
|
48738
49195
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
48739
49196
|
return getMergedSymbol(sourceFile.symbol);
|
|
48740
49197
|
}
|
|
@@ -48792,15 +49249,14 @@ var ts;
|
|
|
48792
49249
|
* Direct users to import source with .js extension if outputting an ES module.
|
|
48793
49250
|
* @see https://github.com/microsoft/TypeScript/issues/42151
|
|
48794
49251
|
*/
|
|
48795
|
-
|
|
48796
|
-
if (moduleKind_1 >= ts.ModuleKind.ES2015) {
|
|
49252
|
+
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
48797
49253
|
replacedImportSource += ".js";
|
|
48798
49254
|
}
|
|
48799
49255
|
error(errorNode, diag, tsExtension, replacedImportSource);
|
|
48800
49256
|
}
|
|
48801
49257
|
else if (!compilerOptions.resolveJsonModule &&
|
|
48802
49258
|
ts.fileExtensionIs(moduleReference, ".json" /* Json */) &&
|
|
48803
|
-
ts.getEmitModuleResolutionKind(compilerOptions)
|
|
49259
|
+
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic &&
|
|
48804
49260
|
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
48805
49261
|
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
48806
49262
|
}
|
|
@@ -48873,7 +49329,7 @@ var ts;
|
|
|
48873
49329
|
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);
|
|
48874
49330
|
return symbol;
|
|
48875
49331
|
}
|
|
48876
|
-
if (compilerOptions
|
|
49332
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
48877
49333
|
var referenceParent = referencingLocation.parent;
|
|
48878
49334
|
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
48879
49335
|
ts.isImportCall(referenceParent)) {
|
|
@@ -50999,7 +51455,7 @@ var ts;
|
|
|
50999
51455
|
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
|
|
51000
51456
|
var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
|
|
51001
51457
|
var specifier = getSpecifierForModuleSymbol(chain[0], context);
|
|
51002
|
-
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions)
|
|
51458
|
+
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
|
|
51003
51459
|
// If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
|
|
51004
51460
|
// since declaration files with these kinds of references are liable to fail when published :(
|
|
51005
51461
|
context.encounteredError = true;
|
|
@@ -51222,7 +51678,7 @@ var ts;
|
|
|
51222
51678
|
if (nameType) {
|
|
51223
51679
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
51224
51680
|
var name = "" + nameType.value;
|
|
51225
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
51681
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
51226
51682
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51227
51683
|
}
|
|
51228
51684
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -51236,7 +51692,7 @@ var ts;
|
|
|
51236
51692
|
}
|
|
51237
51693
|
}
|
|
51238
51694
|
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
51239
|
-
return ts.isIdentifierText(name, compilerOptions
|
|
51695
|
+
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
51240
51696
|
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
51241
51697
|
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51242
51698
|
}
|
|
@@ -52170,6 +52626,27 @@ var ts;
|
|
|
52170
52626
|
/*decorators*/ undefined,
|
|
52171
52627
|
/*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);
|
|
52172
52628
|
}
|
|
52629
|
+
function getSomeTargetNameFromDeclarations(declarations) {
|
|
52630
|
+
return ts.firstDefined(declarations, function (d) {
|
|
52631
|
+
if (ts.isImportSpecifier(d) || ts.isExportSpecifier(d)) {
|
|
52632
|
+
return ts.idText(d.propertyName || d.name);
|
|
52633
|
+
}
|
|
52634
|
+
if (ts.isBinaryExpression(d) || ts.isExportAssignment(d)) {
|
|
52635
|
+
var expression = ts.isExportAssignment(d) ? d.expression : d.right;
|
|
52636
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
52637
|
+
return ts.idText(expression.name);
|
|
52638
|
+
}
|
|
52639
|
+
}
|
|
52640
|
+
if (isAliasSymbolDeclaration(d)) {
|
|
52641
|
+
// This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module.
|
|
52642
|
+
var name = ts.getNameOfDeclaration(d);
|
|
52643
|
+
if (name && ts.isIdentifier(name)) {
|
|
52644
|
+
return ts.idText(name);
|
|
52645
|
+
}
|
|
52646
|
+
}
|
|
52647
|
+
return undefined;
|
|
52648
|
+
});
|
|
52649
|
+
}
|
|
52173
52650
|
function serializeAsAlias(symbol, localName, modifierFlags) {
|
|
52174
52651
|
var _a, _b, _c, _d, _e;
|
|
52175
52652
|
// synthesize an alias, eg `export { symbolName as Name }`
|
|
@@ -52182,8 +52659,10 @@ var ts;
|
|
|
52182
52659
|
if (!target) {
|
|
52183
52660
|
return;
|
|
52184
52661
|
}
|
|
52185
|
-
|
|
52186
|
-
|
|
52662
|
+
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
|
|
52663
|
+
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
|
|
52664
|
+
var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName);
|
|
52665
|
+
if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
|
|
52187
52666
|
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
|
|
52188
52667
|
verbatimTargetName = "default" /* Default */;
|
|
52189
52668
|
}
|
|
@@ -52726,7 +53205,7 @@ var ts;
|
|
|
52726
53205
|
if (nameType) {
|
|
52727
53206
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52728
53207
|
var name = "" + nameType.value;
|
|
52729
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
53208
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52730
53209
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
52731
53210
|
}
|
|
52732
53211
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -61814,7 +62293,7 @@ var ts;
|
|
|
61814
62293
|
path = "" + str;
|
|
61815
62294
|
}
|
|
61816
62295
|
// Otherwise write a dotted name if possible
|
|
61817
|
-
else if (ts.isIdentifierText(str, compilerOptions
|
|
62296
|
+
else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) {
|
|
61818
62297
|
path = path + "." + str;
|
|
61819
62298
|
}
|
|
61820
62299
|
// Failing that, check if the name is already a computed name
|
|
@@ -67106,9 +67585,10 @@ var ts;
|
|
|
67106
67585
|
}
|
|
67107
67586
|
function isConstantReference(node) {
|
|
67108
67587
|
switch (node.kind) {
|
|
67109
|
-
case 79 /* Identifier */:
|
|
67588
|
+
case 79 /* Identifier */: {
|
|
67110
67589
|
var symbol = getResolvedSymbol(node);
|
|
67111
|
-
return isConstVariable(symbol) ||
|
|
67590
|
+
return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol);
|
|
67591
|
+
}
|
|
67112
67592
|
case 204 /* PropertyAccessExpression */:
|
|
67113
67593
|
case 205 /* ElementAccessExpression */:
|
|
67114
67594
|
// The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here.
|
|
@@ -68190,35 +68670,37 @@ var ts;
|
|
|
68190
68670
|
node.kind === 165 /* PropertyDeclaration */;
|
|
68191
68671
|
});
|
|
68192
68672
|
}
|
|
68193
|
-
// Check if a parameter is assigned anywhere
|
|
68194
|
-
function
|
|
68673
|
+
// Check if a parameter or catch variable is assigned anywhere
|
|
68674
|
+
function isSymbolAssigned(symbol) {
|
|
68195
68675
|
if (!symbol.valueDeclaration) {
|
|
68196
68676
|
return false;
|
|
68197
68677
|
}
|
|
68198
|
-
var
|
|
68199
|
-
var links = getNodeLinks(
|
|
68678
|
+
var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent;
|
|
68679
|
+
var links = getNodeLinks(parent);
|
|
68200
68680
|
if (!(links.flags & 8388608 /* AssignmentsMarked */)) {
|
|
68201
68681
|
links.flags |= 8388608 /* AssignmentsMarked */;
|
|
68202
|
-
if (!hasParentWithAssignmentsMarked(
|
|
68203
|
-
|
|
68682
|
+
if (!hasParentWithAssignmentsMarked(parent)) {
|
|
68683
|
+
markNodeAssignments(parent);
|
|
68204
68684
|
}
|
|
68205
68685
|
}
|
|
68206
68686
|
return symbol.isAssigned || false;
|
|
68207
68687
|
}
|
|
68208
68688
|
function hasParentWithAssignmentsMarked(node) {
|
|
68209
|
-
return !!ts.findAncestor(node.parent, function (node) {
|
|
68689
|
+
return !!ts.findAncestor(node.parent, function (node) {
|
|
68690
|
+
return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */);
|
|
68691
|
+
});
|
|
68210
68692
|
}
|
|
68211
|
-
function
|
|
68693
|
+
function markNodeAssignments(node) {
|
|
68212
68694
|
if (node.kind === 79 /* Identifier */) {
|
|
68213
68695
|
if (ts.isAssignmentTarget(node)) {
|
|
68214
68696
|
var symbol = getResolvedSymbol(node);
|
|
68215
|
-
if (
|
|
68697
|
+
if (ts.isParameterOrCatchClauseVariable(symbol)) {
|
|
68216
68698
|
symbol.isAssigned = true;
|
|
68217
68699
|
}
|
|
68218
68700
|
}
|
|
68219
68701
|
}
|
|
68220
68702
|
else {
|
|
68221
|
-
ts.forEachChild(node,
|
|
68703
|
+
ts.forEachChild(node, markNodeAssignments);
|
|
68222
68704
|
}
|
|
68223
68705
|
}
|
|
68224
68706
|
function isConstVariable(symbol) {
|
|
@@ -68427,7 +68909,7 @@ var ts;
|
|
|
68427
68909
|
// analysis to include the immediately enclosing function.
|
|
68428
68910
|
while (flowContainer !== declarationContainer && (flowContainer.kind === 211 /* FunctionExpression */ ||
|
|
68429
68911
|
flowContainer.kind === 212 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) &&
|
|
68430
|
-
(isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !
|
|
68912
|
+
(isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) {
|
|
68431
68913
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
68432
68914
|
}
|
|
68433
68915
|
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
|
|
@@ -71246,7 +71728,7 @@ var ts;
|
|
|
71246
71728
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
71247
71729
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
71248
71730
|
}
|
|
71249
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions
|
|
71731
|
+
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
71250
71732
|
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
71251
71733
|
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
71252
71734
|
if (n === lexicalClass_1)
|
|
@@ -73847,6 +74329,12 @@ var ts;
|
|
|
73847
74329
|
return getReturnTypeOfSignature(signature);
|
|
73848
74330
|
}
|
|
73849
74331
|
function checkAssertion(node) {
|
|
74332
|
+
if (node.kind === 209 /* TypeAssertionExpression */) {
|
|
74333
|
+
var file = ts.getSourceFileOfNode(node);
|
|
74334
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
74335
|
+
grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
74336
|
+
}
|
|
74337
|
+
}
|
|
73850
74338
|
return checkAssertionWorker(node, node.type, node.expression);
|
|
73851
74339
|
}
|
|
73852
74340
|
function isValidConstAssertionArgument(node) {
|
|
@@ -73947,7 +74435,14 @@ var ts;
|
|
|
73947
74435
|
}
|
|
73948
74436
|
function checkImportMetaProperty(node) {
|
|
73949
74437
|
if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
|
|
73950
|
-
|
|
74438
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74439
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74440
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74441
|
+
}
|
|
74442
|
+
}
|
|
74443
|
+
else {
|
|
74444
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74445
|
+
}
|
|
73951
74446
|
}
|
|
73952
74447
|
var file = ts.getSourceFileOfNode(node);
|
|
73953
74448
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
@@ -74889,9 +75384,9 @@ var ts;
|
|
|
74889
75384
|
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);
|
|
74890
75385
|
diagnostics.add(diagnostic);
|
|
74891
75386
|
}
|
|
74892
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
75387
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
74893
75388
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
74894
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75389
|
+
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);
|
|
74895
75390
|
diagnostics.add(diagnostic);
|
|
74896
75391
|
}
|
|
74897
75392
|
}
|
|
@@ -76929,7 +77424,7 @@ var ts;
|
|
|
76929
77424
|
// - The containing class is a derived class.
|
|
76930
77425
|
// - The constructor declares parameter properties
|
|
76931
77426
|
// or the containing class declares instance member variables with initializers.
|
|
76932
|
-
var superCallShouldBeFirst = (compilerOptions
|
|
77427
|
+
var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
76933
77428
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
76934
77429
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
76935
77430
|
// Skip past any prologue directives to find the first statement
|
|
@@ -78661,7 +79156,7 @@ var ts;
|
|
|
78661
79156
|
}
|
|
78662
79157
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
78663
79158
|
// No need to check for require or exports for ES6 modules and later
|
|
78664
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
79159
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
78665
79160
|
return;
|
|
78666
79161
|
}
|
|
78667
79162
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -80222,8 +80717,8 @@ var ts;
|
|
|
80222
80717
|
* The name cannot be used as 'Object' of user defined types with special target.
|
|
80223
80718
|
*/
|
|
80224
80719
|
function checkClassNameCollisionWithObject(name) {
|
|
80225
|
-
if (languageVersion
|
|
80226
|
-
&& moduleKind < ts.ModuleKind.ES2015) {
|
|
80720
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object"
|
|
80721
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
80227
80722
|
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
|
|
80228
80723
|
}
|
|
80229
80724
|
}
|
|
@@ -81382,8 +81877,8 @@ var ts;
|
|
|
81382
81877
|
checkAliasSymbol(node);
|
|
81383
81878
|
if (node.kind === 268 /* ImportSpecifier */ &&
|
|
81384
81879
|
ts.idText(node.propertyName || node.name) === "default" &&
|
|
81385
|
-
compilerOptions
|
|
81386
|
-
moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
81880
|
+
ts.getESModuleInterop(compilerOptions) &&
|
|
81881
|
+
moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81387
81882
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81388
81883
|
}
|
|
81389
81884
|
}
|
|
@@ -81404,7 +81899,7 @@ var ts;
|
|
|
81404
81899
|
if (importClause.namedBindings) {
|
|
81405
81900
|
if (importClause.namedBindings.kind === 266 /* NamespaceImport */) {
|
|
81406
81901
|
checkImportBinding(importClause.namedBindings);
|
|
81407
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions
|
|
81902
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
|
|
81408
81903
|
// import * as ns from "foo";
|
|
81409
81904
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81410
81905
|
}
|
|
@@ -81449,7 +81944,7 @@ var ts;
|
|
|
81449
81944
|
}
|
|
81450
81945
|
}
|
|
81451
81946
|
else {
|
|
81452
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
81947
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
81453
81948
|
// Import equals declaration is deprecated in es6 or above
|
|
81454
81949
|
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);
|
|
81455
81950
|
}
|
|
@@ -81490,12 +81985,12 @@ var ts;
|
|
|
81490
81985
|
else if (node.exportClause) {
|
|
81491
81986
|
checkAliasSymbol(node.exportClause);
|
|
81492
81987
|
}
|
|
81493
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
81988
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81494
81989
|
if (node.exportClause) {
|
|
81495
81990
|
// export * as ns from "foo";
|
|
81496
81991
|
// 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.
|
|
81497
81992
|
// We only use the helper here when in esModuleInterop
|
|
81498
|
-
if (compilerOptions
|
|
81993
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
81499
81994
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81500
81995
|
}
|
|
81501
81996
|
}
|
|
@@ -81578,9 +82073,9 @@ var ts;
|
|
|
81578
82073
|
}
|
|
81579
82074
|
}
|
|
81580
82075
|
else {
|
|
81581
|
-
if (compilerOptions
|
|
82076
|
+
if (ts.getESModuleInterop(compilerOptions) &&
|
|
81582
82077
|
moduleKind !== ts.ModuleKind.System &&
|
|
81583
|
-
moduleKind < ts.ModuleKind.ES2015 &&
|
|
82078
|
+
(moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) &&
|
|
81584
82079
|
ts.idText(node.propertyName || node.name) === "default") {
|
|
81585
82080
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81586
82081
|
}
|
|
@@ -81639,7 +82134,7 @@ var ts;
|
|
|
81639
82134
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
81640
82135
|
}
|
|
81641
82136
|
if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
|
|
81642
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
82137
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
81643
82138
|
// export assignment is not supported in es6 modules
|
|
81644
82139
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
81645
82140
|
}
|
|
@@ -84176,6 +84671,11 @@ var ts;
|
|
|
84176
84671
|
if (!ts.isArrowFunction(node)) {
|
|
84177
84672
|
return false;
|
|
84178
84673
|
}
|
|
84674
|
+
if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
|
|
84675
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) {
|
|
84676
|
+
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);
|
|
84677
|
+
}
|
|
84678
|
+
}
|
|
84179
84679
|
var equalsGreaterThanToken = node.equalsGreaterThanToken;
|
|
84180
84680
|
var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
|
|
84181
84681
|
var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
|
|
@@ -84508,8 +85008,8 @@ var ts;
|
|
|
84508
85008
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
84509
85009
|
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));
|
|
84510
85010
|
}
|
|
84511
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
84512
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85011
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85012
|
+
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));
|
|
84513
85013
|
}
|
|
84514
85014
|
}
|
|
84515
85015
|
}
|
|
@@ -84850,8 +85350,7 @@ var ts;
|
|
|
84850
85350
|
: ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
|
84851
85351
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
84852
85352
|
}
|
|
84853
|
-
|
|
84854
|
-
if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
|
|
85353
|
+
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
84855
85354
|
!(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
84856
85355
|
checkESModuleMarker(node.name);
|
|
84857
85356
|
}
|
|
@@ -85186,7 +85685,7 @@ var ts;
|
|
|
85186
85685
|
}
|
|
85187
85686
|
function checkGrammarImportCallExpression(node) {
|
|
85188
85687
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
85189
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
85688
|
+
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);
|
|
85190
85689
|
}
|
|
85191
85690
|
if (node.typeArguments) {
|
|
85192
85691
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -90331,7 +90830,7 @@ var ts;
|
|
|
90331
90830
|
function transformSourceFile(node) {
|
|
90332
90831
|
var options = context.getCompilerOptions();
|
|
90333
90832
|
if (node.isDeclarationFile
|
|
90334
|
-
|| useDefineForClassFields && options
|
|
90833
|
+
|| useDefineForClassFields && ts.getEmitScriptTarget(options) === 99 /* ESNext */) {
|
|
90335
90834
|
return node;
|
|
90336
90835
|
}
|
|
90337
90836
|
var visited = ts.visitEachChild(node, visitor, context);
|
|
@@ -93707,7 +94206,7 @@ var ts;
|
|
|
93707
94206
|
// When there are no attributes, React wants "null"
|
|
93708
94207
|
}
|
|
93709
94208
|
else {
|
|
93710
|
-
var target = compilerOptions
|
|
94209
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
93711
94210
|
if (target && target >= 5 /* ES2018 */) {
|
|
93712
94211
|
objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
93713
94212
|
return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
|
|
@@ -100542,7 +101041,7 @@ var ts;
|
|
|
100542
101041
|
case 345 /* PartiallyEmittedExpression */:
|
|
100543
101042
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
100544
101043
|
case 206 /* CallExpression */:
|
|
100545
|
-
if (ts.isImportCall(node)) {
|
|
101044
|
+
if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
|
|
100546
101045
|
return visitImportCallExpression(node);
|
|
100547
101046
|
}
|
|
100548
101047
|
break;
|
|
@@ -100765,7 +101264,7 @@ var ts;
|
|
|
100765
101264
|
}
|
|
100766
101265
|
}
|
|
100767
101266
|
var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
|
100768
|
-
if (compilerOptions
|
|
101267
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
100769
101268
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
|
|
100770
101269
|
}
|
|
100771
101270
|
return promise;
|
|
@@ -100778,7 +101277,7 @@ var ts;
|
|
|
100778
101277
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
100779
101278
|
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
|
100780
101279
|
var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
|
100781
|
-
if (compilerOptions
|
|
101280
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
100782
101281
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
100783
101282
|
}
|
|
100784
101283
|
var func;
|
|
@@ -100808,7 +101307,7 @@ var ts;
|
|
|
100808
101307
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
100809
101308
|
}
|
|
100810
101309
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
100811
|
-
if (!compilerOptions
|
|
101310
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
100812
101311
|
return innerExpr;
|
|
100813
101312
|
}
|
|
100814
101313
|
if (ts.getExportNeedsImportStarHelper(node)) {
|
|
@@ -100817,7 +101316,7 @@ var ts;
|
|
|
100817
101316
|
return innerExpr;
|
|
100818
101317
|
}
|
|
100819
101318
|
function getHelperExpressionForImport(node, innerExpr) {
|
|
100820
|
-
if (!compilerOptions
|
|
101319
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
100821
101320
|
return innerExpr;
|
|
100822
101321
|
}
|
|
100823
101322
|
if (ts.getImportNeedsImportStarHelper(node)) {
|
|
@@ -100971,7 +101470,7 @@ var ts;
|
|
|
100971
101470
|
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));
|
|
100972
101471
|
}
|
|
100973
101472
|
else {
|
|
100974
|
-
var exportNeedsImportDefault = !!compilerOptions
|
|
101473
|
+
var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) &&
|
|
100975
101474
|
!(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) &&
|
|
100976
101475
|
ts.idText(specifier.propertyName || specifier.name) === "default";
|
|
100977
101476
|
var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
|
|
@@ -103140,7 +103639,10 @@ var ts;
|
|
|
103140
103639
|
(function (ts) {
|
|
103141
103640
|
function transformECMAScriptModule(context) {
|
|
103142
103641
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
|
|
103642
|
+
var host = context.getEmitHost();
|
|
103643
|
+
var resolver = context.getEmitResolver();
|
|
103143
103644
|
var compilerOptions = context.getCompilerOptions();
|
|
103645
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
103144
103646
|
var previousOnEmitNode = context.onEmitNode;
|
|
103145
103647
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
103146
103648
|
context.onEmitNode = onEmitNode;
|
|
@@ -103148,13 +103650,21 @@ var ts;
|
|
|
103148
103650
|
context.enableEmitNotification(300 /* SourceFile */);
|
|
103149
103651
|
context.enableSubstitution(79 /* Identifier */);
|
|
103150
103652
|
var helperNameSubstitutions;
|
|
103653
|
+
var currentSourceFile;
|
|
103654
|
+
var importRequireStatements;
|
|
103151
103655
|
return ts.chainBundle(context, transformSourceFile);
|
|
103152
103656
|
function transformSourceFile(node) {
|
|
103153
103657
|
if (node.isDeclarationFile) {
|
|
103154
103658
|
return node;
|
|
103155
103659
|
}
|
|
103156
103660
|
if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
|
|
103661
|
+
currentSourceFile = node;
|
|
103662
|
+
importRequireStatements = undefined;
|
|
103157
103663
|
var result = updateExternalModule(node);
|
|
103664
|
+
currentSourceFile = undefined;
|
|
103665
|
+
if (importRequireStatements) {
|
|
103666
|
+
result = factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(ts.insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements));
|
|
103667
|
+
}
|
|
103158
103668
|
if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
|
|
103159
103669
|
return result;
|
|
103160
103670
|
}
|
|
@@ -103178,8 +103688,10 @@ var ts;
|
|
|
103178
103688
|
function visitor(node) {
|
|
103179
103689
|
switch (node.kind) {
|
|
103180
103690
|
case 263 /* ImportEqualsDeclaration */:
|
|
103181
|
-
//
|
|
103182
|
-
|
|
103691
|
+
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
103692
|
+
// 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`
|
|
103693
|
+
// is available, just because the output is reasonable for a node-like runtime.
|
|
103694
|
+
return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
|
|
103183
103695
|
case 269 /* ExportAssignment */:
|
|
103184
103696
|
return visitExportAssignment(node);
|
|
103185
103697
|
case 270 /* ExportDeclaration */:
|
|
@@ -103188,6 +103700,68 @@ var ts;
|
|
|
103188
103700
|
}
|
|
103189
103701
|
return node;
|
|
103190
103702
|
}
|
|
103703
|
+
/**
|
|
103704
|
+
* Creates a `require()` call to import an external module.
|
|
103705
|
+
*
|
|
103706
|
+
* @param importNode The declaration to import.
|
|
103707
|
+
*/
|
|
103708
|
+
function createRequireCall(importNode) {
|
|
103709
|
+
var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, ts.Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
|
|
103710
|
+
var args = [];
|
|
103711
|
+
if (moduleName) {
|
|
103712
|
+
args.push(moduleName);
|
|
103713
|
+
}
|
|
103714
|
+
if (!importRequireStatements) {
|
|
103715
|
+
var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
103716
|
+
var importStatement = factory.createImportDeclaration(
|
|
103717
|
+
/*decorators*/ undefined,
|
|
103718
|
+
/*modifiers*/ undefined, factory.createImportClause(
|
|
103719
|
+
/*isTypeOnly*/ false,
|
|
103720
|
+
/*name*/ undefined, factory.createNamedImports([
|
|
103721
|
+
factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
|
|
103722
|
+
])), factory.createStringLiteral("module"));
|
|
103723
|
+
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
103724
|
+
var requireStatement = factory.createVariableStatement(
|
|
103725
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
103726
|
+
factory.createVariableDeclaration(requireHelperName,
|
|
103727
|
+
/*exclamationToken*/ undefined,
|
|
103728
|
+
/*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
|
|
103729
|
+
factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
|
|
103730
|
+
]))
|
|
103731
|
+
],
|
|
103732
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */));
|
|
103733
|
+
importRequireStatements = [importStatement, requireStatement];
|
|
103734
|
+
}
|
|
103735
|
+
var name = importRequireStatements[1].declarationList.declarations[0].name;
|
|
103736
|
+
ts.Debug.assertNode(name, ts.isIdentifier);
|
|
103737
|
+
return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args);
|
|
103738
|
+
}
|
|
103739
|
+
/**
|
|
103740
|
+
* Visits an ImportEqualsDeclaration node.
|
|
103741
|
+
*
|
|
103742
|
+
* @param node The node to visit.
|
|
103743
|
+
*/
|
|
103744
|
+
function visitImportEqualsDeclaration(node) {
|
|
103745
|
+
ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
|
|
103746
|
+
var statements;
|
|
103747
|
+
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(
|
|
103748
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
103749
|
+
factory.createVariableDeclaration(factory.cloneNode(node.name),
|
|
103750
|
+
/*exclamationToken*/ undefined,
|
|
103751
|
+
/*type*/ undefined, createRequireCall(node))
|
|
103752
|
+
],
|
|
103753
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
|
|
103754
|
+
statements = appendExportsOfImportEqualsDeclaration(statements, node);
|
|
103755
|
+
return ts.singleOrMany(statements);
|
|
103756
|
+
}
|
|
103757
|
+
function appendExportsOfImportEqualsDeclaration(statements, node) {
|
|
103758
|
+
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
103759
|
+
statements = ts.append(statements, factory.createExportDeclaration(
|
|
103760
|
+
/*decorators*/ undefined,
|
|
103761
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, ts.idText(node.name))])));
|
|
103762
|
+
}
|
|
103763
|
+
return statements;
|
|
103764
|
+
}
|
|
103191
103765
|
function visitExportAssignment(node) {
|
|
103192
103766
|
// Elide `export=` as it is not legal with --module ES6
|
|
103193
103767
|
return node.isExportEquals ? undefined : node;
|
|
@@ -103265,6 +103839,78 @@ var ts;
|
|
|
103265
103839
|
}
|
|
103266
103840
|
ts.transformECMAScriptModule = transformECMAScriptModule;
|
|
103267
103841
|
})(ts || (ts = {}));
|
|
103842
|
+
/*@internal*/
|
|
103843
|
+
var ts;
|
|
103844
|
+
(function (ts) {
|
|
103845
|
+
function transformNodeModule(context) {
|
|
103846
|
+
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
103847
|
+
var previousOnEmitNode = context.onEmitNode;
|
|
103848
|
+
var esmTransform = ts.transformECMAScriptModule(context);
|
|
103849
|
+
var esmOnSubstituteNode = context.onSubstituteNode;
|
|
103850
|
+
var esmOnEmitNode = context.onEmitNode;
|
|
103851
|
+
context.onSubstituteNode = previousOnSubstituteNode;
|
|
103852
|
+
context.onEmitNode = previousOnEmitNode;
|
|
103853
|
+
var cjsTransform = ts.transformModule(context);
|
|
103854
|
+
var cjsOnSubstituteNode = context.onSubstituteNode;
|
|
103855
|
+
var cjsOnEmitNode = context.onEmitNode;
|
|
103856
|
+
context.onSubstituteNode = onSubstituteNode;
|
|
103857
|
+
context.onEmitNode = onEmitNode;
|
|
103858
|
+
context.enableSubstitution(300 /* SourceFile */);
|
|
103859
|
+
context.enableEmitNotification(300 /* SourceFile */);
|
|
103860
|
+
var currentSourceFile;
|
|
103861
|
+
return transformSourceFileOrBundle;
|
|
103862
|
+
function onSubstituteNode(hint, node) {
|
|
103863
|
+
if (ts.isSourceFile(node)) {
|
|
103864
|
+
currentSourceFile = node;
|
|
103865
|
+
// Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on
|
|
103866
|
+
// the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute
|
|
103867
|
+
// functions on source files safely, as that context only gets setup in a later pipeline phase!)
|
|
103868
|
+
return previousOnSubstituteNode(hint, node);
|
|
103869
|
+
}
|
|
103870
|
+
else {
|
|
103871
|
+
if (!currentSourceFile) {
|
|
103872
|
+
return previousOnSubstituteNode(hint, node);
|
|
103873
|
+
}
|
|
103874
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
103875
|
+
return esmOnSubstituteNode(hint, node);
|
|
103876
|
+
}
|
|
103877
|
+
return cjsOnSubstituteNode(hint, node);
|
|
103878
|
+
}
|
|
103879
|
+
}
|
|
103880
|
+
function onEmitNode(hint, node, emitCallback) {
|
|
103881
|
+
if (ts.isSourceFile(node)) {
|
|
103882
|
+
currentSourceFile = node;
|
|
103883
|
+
}
|
|
103884
|
+
if (!currentSourceFile) {
|
|
103885
|
+
return previousOnEmitNode(hint, node, emitCallback);
|
|
103886
|
+
}
|
|
103887
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
103888
|
+
return esmOnEmitNode(hint, node, emitCallback);
|
|
103889
|
+
}
|
|
103890
|
+
return cjsOnEmitNode(hint, node, emitCallback);
|
|
103891
|
+
}
|
|
103892
|
+
function getModuleTransformForFile(file) {
|
|
103893
|
+
return file.impliedNodeFormat === ts.ModuleKind.ESNext ? esmTransform : cjsTransform;
|
|
103894
|
+
}
|
|
103895
|
+
function transformSourceFile(node) {
|
|
103896
|
+
if (node.isDeclarationFile) {
|
|
103897
|
+
return node;
|
|
103898
|
+
}
|
|
103899
|
+
currentSourceFile = node;
|
|
103900
|
+
var result = getModuleTransformForFile(node)(node);
|
|
103901
|
+
currentSourceFile = undefined;
|
|
103902
|
+
ts.Debug.assert(ts.isSourceFile(result));
|
|
103903
|
+
return result;
|
|
103904
|
+
}
|
|
103905
|
+
function transformSourceFileOrBundle(node) {
|
|
103906
|
+
return node.kind === 300 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
|
|
103907
|
+
}
|
|
103908
|
+
function transformBundle(node) {
|
|
103909
|
+
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
|
|
103910
|
+
}
|
|
103911
|
+
}
|
|
103912
|
+
ts.transformNodeModule = transformNodeModule;
|
|
103913
|
+
})(ts || (ts = {}));
|
|
103268
103914
|
/* @internal */
|
|
103269
103915
|
var ts;
|
|
103270
103916
|
(function (ts) {
|
|
@@ -105082,6 +105728,9 @@ var ts;
|
|
|
105082
105728
|
return ts.transformECMAScriptModule;
|
|
105083
105729
|
case ts.ModuleKind.System:
|
|
105084
105730
|
return ts.transformSystemModule;
|
|
105731
|
+
case ts.ModuleKind.Node12:
|
|
105732
|
+
case ts.ModuleKind.NodeNext:
|
|
105733
|
+
return ts.transformNodeModule;
|
|
105085
105734
|
default:
|
|
105086
105735
|
return ts.transformModule;
|
|
105087
105736
|
}
|
|
@@ -105692,7 +106341,7 @@ var ts;
|
|
|
105692
106341
|
return getOutputPathsForBundle(options, forceDtsPaths);
|
|
105693
106342
|
}
|
|
105694
106343
|
else {
|
|
105695
|
-
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
|
|
106344
|
+
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options));
|
|
105696
106345
|
var isJsonFile = ts.isJsonSourceFile(sourceFile);
|
|
105697
106346
|
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
|
|
105698
106347
|
var isJsonEmittedToSameLocation = isJsonFile &&
|
|
@@ -105708,26 +106357,13 @@ var ts;
|
|
|
105708
106357
|
function getSourceMapFilePath(jsFilePath, options) {
|
|
105709
106358
|
return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
|
|
105710
106359
|
}
|
|
105711
|
-
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
|
|
105712
|
-
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
|
|
105713
|
-
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
|
|
105714
106360
|
/* @internal */
|
|
105715
|
-
function getOutputExtension(
|
|
105716
|
-
|
|
105717
|
-
|
|
105718
|
-
|
|
105719
|
-
|
|
105720
|
-
|
|
105721
|
-
if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) {
|
|
105722
|
-
return ".jsx" /* Jsx */;
|
|
105723
|
-
}
|
|
105724
|
-
}
|
|
105725
|
-
else if (sourceFile.languageVariant === 1 /* JSX */) {
|
|
105726
|
-
// TypeScript source file preserving JSX syntax
|
|
105727
|
-
return ".jsx" /* Jsx */;
|
|
105728
|
-
}
|
|
105729
|
-
}
|
|
105730
|
-
return ".js" /* Js */;
|
|
106361
|
+
function getOutputExtension(fileName, options) {
|
|
106362
|
+
return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ :
|
|
106363
|
+
options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ :
|
|
106364
|
+
ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ :
|
|
106365
|
+
ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ :
|
|
106366
|
+
".js" /* Js */;
|
|
105731
106367
|
}
|
|
105732
106368
|
ts.getOutputExtension = getOutputExtension;
|
|
105733
106369
|
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
|
|
@@ -105737,19 +106373,14 @@ var ts;
|
|
|
105737
106373
|
}
|
|
105738
106374
|
/* @internal */
|
|
105739
106375
|
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
105740
|
-
ts.
|
|
105741
|
-
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts" /* Dts */);
|
|
106376
|
+
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ts.getDeclarationEmitExtensionForPath(inputFileName));
|
|
105742
106377
|
}
|
|
105743
106378
|
ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
|
|
105744
106379
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
105745
106380
|
if (configFile.options.emitDeclarationOnly)
|
|
105746
106381
|
return undefined;
|
|
105747
106382
|
var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
105748
|
-
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory),
|
|
105749
|
-
".json" /* Json */ :
|
|
105750
|
-
configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ?
|
|
105751
|
-
".jsx" /* Jsx */ :
|
|
105752
|
-
".js" /* Js */);
|
|
106383
|
+
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options));
|
|
105753
106384
|
return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
|
|
105754
106385
|
outputFileName :
|
|
105755
106386
|
undefined;
|
|
@@ -105820,7 +106451,7 @@ var ts;
|
|
|
105820
106451
|
/*@internal*/
|
|
105821
106452
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
105822
106453
|
var options = _a.options, fileNames = _a.fileNames;
|
|
105823
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.
|
|
106454
|
+
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));
|
|
105824
106455
|
}
|
|
105825
106456
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
105826
106457
|
/*@internal*/
|
|
@@ -111055,7 +111686,7 @@ var ts;
|
|
|
111055
111686
|
if (options.declarationDir)
|
|
111056
111687
|
return false;
|
|
111057
111688
|
}
|
|
111058
|
-
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.
|
|
111689
|
+
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensionsFlat)) {
|
|
111059
111690
|
return false;
|
|
111060
111691
|
}
|
|
111061
111692
|
// just check if sourceFile with the name exists
|
|
@@ -111668,6 +112299,82 @@ var ts;
|
|
|
111668
112299
|
}
|
|
111669
112300
|
ts.loadWithLocalCache = loadWithLocalCache;
|
|
111670
112301
|
/* @internal */
|
|
112302
|
+
/**
|
|
112303
|
+
* Are you sure you want to use this? If you have a bound and parent pointer'd sourcefile, as in the checker, getModeForUsageLocation is much more ergonomic
|
|
112304
|
+
*/
|
|
112305
|
+
function getModeForResolutionAtIndex(file, index) {
|
|
112306
|
+
if (file.impliedNodeFormat === undefined)
|
|
112307
|
+
return undefined;
|
|
112308
|
+
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
112309
|
+
var usage_1 = getModuleNameStringLiteralAt(file, index);
|
|
112310
|
+
if (usage_1.parent) {
|
|
112311
|
+
// parent pointers are set - do the fast thing and just check if the parent is an import call expression
|
|
112312
|
+
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage_1.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112313
|
+
}
|
|
112314
|
+
// We can't rely on parent pointers being set - so instead we search for the usage in the top-level statements in the file,
|
|
112315
|
+
// since that's the only place (module) import declarations and module augmentations (or definitions) are allowed.
|
|
112316
|
+
// If the usage is anywhere else, by process of elimination, it must be an import call usage.
|
|
112317
|
+
if (ts.some(file.statements, function (s) {
|
|
112318
|
+
return (ts.isImportDeclaration(s) && s.moduleSpecifier === usage_1) ||
|
|
112319
|
+
(ts.isImportEqualsDeclaration(s) && ts.isExternalModuleReference(s.moduleReference) && ts.skipParentheses(s.moduleReference.expression) === usage_1) ||
|
|
112320
|
+
(ts.isModuleDeclaration(s) && s.name === usage_1) ||
|
|
112321
|
+
(ts.isExportDeclaration(s) && s.moduleSpecifier === usage_1);
|
|
112322
|
+
})) {
|
|
112323
|
+
return ts.ModuleKind.CommonJS;
|
|
112324
|
+
}
|
|
112325
|
+
return ts.ModuleKind.ESNext;
|
|
112326
|
+
}
|
|
112327
|
+
// in an esnext format file, import require statements desugar to `require` calls, so should follow cjs resolution rules
|
|
112328
|
+
var usage = getModuleNameStringLiteralAt(file, index);
|
|
112329
|
+
if (usage.parent) {
|
|
112330
|
+
// parent pointers are set - do the fast thing and just check if the parent is an import require statement
|
|
112331
|
+
return ts.isImportEqualsDeclaration(ts.walkUpParenthesizedExpressions(usage.parent).parent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
|
|
112332
|
+
}
|
|
112333
|
+
// parent pointers are unset - check to see if the usage is refered to in any of the top-level import require statements, as that's the only place they should be valid
|
|
112334
|
+
if (ts.some(file.statements, function (s) { return ts.isImportEqualsDeclaration(s) && ts.isExternalModuleReference(s.moduleReference) && ts.skipParentheses(s.moduleReference.expression) === usage; })) {
|
|
112335
|
+
return ts.ModuleKind.CommonJS;
|
|
112336
|
+
}
|
|
112337
|
+
return ts.ModuleKind.ESNext;
|
|
112338
|
+
}
|
|
112339
|
+
ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex;
|
|
112340
|
+
/* @internal */
|
|
112341
|
+
function getModeForUsageLocation(file, usage) {
|
|
112342
|
+
if (file.impliedNodeFormat === undefined)
|
|
112343
|
+
return undefined;
|
|
112344
|
+
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
112345
|
+
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
|
112346
|
+
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112347
|
+
}
|
|
112348
|
+
// in esm files, import=require statements are cjs format, otherwise everything is esm
|
|
112349
|
+
return ts.isImportEqualsDeclaration(ts.walkUpParenthesizedExpressions(usage.parent).parent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
|
|
112350
|
+
}
|
|
112351
|
+
ts.getModeForUsageLocation = getModeForUsageLocation;
|
|
112352
|
+
/* @internal */
|
|
112353
|
+
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
|
|
112354
|
+
if (names.length === 0) {
|
|
112355
|
+
return [];
|
|
112356
|
+
}
|
|
112357
|
+
var resolutions = [];
|
|
112358
|
+
var cache = new ts.Map();
|
|
112359
|
+
var i = 0;
|
|
112360
|
+
for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
|
|
112361
|
+
var name = names_3[_i];
|
|
112362
|
+
var result = void 0;
|
|
112363
|
+
var mode = getModeForResolutionAtIndex(containingFile, i);
|
|
112364
|
+
i++;
|
|
112365
|
+
var cacheKey = mode !== undefined ? mode + "|" + name : name;
|
|
112366
|
+
if (cache.has(cacheKey)) {
|
|
112367
|
+
result = cache.get(cacheKey);
|
|
112368
|
+
}
|
|
112369
|
+
else {
|
|
112370
|
+
cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
|
|
112371
|
+
}
|
|
112372
|
+
resolutions.push(result);
|
|
112373
|
+
}
|
|
112374
|
+
return resolutions;
|
|
112375
|
+
}
|
|
112376
|
+
ts.loadWithModeAwareCache = loadWithModeAwareCache;
|
|
112377
|
+
/* @internal */
|
|
111671
112378
|
function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
|
|
111672
112379
|
return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
|
|
111673
112380
|
}
|
|
@@ -111725,7 +112432,7 @@ var ts;
|
|
|
111725
112432
|
switch (kind) {
|
|
111726
112433
|
case ts.FileIncludeKind.Import:
|
|
111727
112434
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
111728
|
-
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
112435
|
+
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;
|
|
111729
112436
|
if (importLiteral.pos === -1)
|
|
111730
112437
|
return { file: file, packageId: packageId, text: importLiteral.text };
|
|
111731
112438
|
pos = ts.skipTrivia(file.text, importLiteral.pos);
|
|
@@ -111736,7 +112443,7 @@ var ts;
|
|
|
111736
112443
|
break;
|
|
111737
112444
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
111738
112445
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
111739
|
-
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;
|
|
112446
|
+
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;
|
|
111740
112447
|
break;
|
|
111741
112448
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
111742
112449
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -111823,6 +112530,33 @@ var ts;
|
|
|
111823
112530
|
configFileParseResult.errors;
|
|
111824
112531
|
}
|
|
111825
112532
|
ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
|
|
112533
|
+
/**
|
|
112534
|
+
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
|
112535
|
+
* `options` parameter.
|
|
112536
|
+
*
|
|
112537
|
+
* @param fileName The normalized absolute path to check the format of (it need not exist on disk)
|
|
112538
|
+
* @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
|
|
112539
|
+
* @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
|
|
112540
|
+
* @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
|
|
112541
|
+
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
112542
|
+
*/
|
|
112543
|
+
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
112544
|
+
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
112545
|
+
case ts.ModuleResolutionKind.Node12:
|
|
112546
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
112547
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext :
|
|
112548
|
+
ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS :
|
|
112549
|
+
ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() :
|
|
112550
|
+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
|
112551
|
+
default:
|
|
112552
|
+
return undefined;
|
|
112553
|
+
}
|
|
112554
|
+
function lookupFromPackageJson() {
|
|
112555
|
+
var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
|
|
112556
|
+
return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112557
|
+
}
|
|
112558
|
+
}
|
|
112559
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
111826
112560
|
/**
|
|
111827
112561
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
111828
112562
|
*/
|
|
@@ -111843,7 +112577,7 @@ var ts;
|
|
|
111843
112577
|
};
|
|
111844
112578
|
}
|
|
111845
112579
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
111846
|
-
var _a, _b, _c;
|
|
112580
|
+
var _a, _b, _c, _d;
|
|
111847
112581
|
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
|
111848
112582
|
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
|
|
111849
112583
|
var oldProgram = createProgramOptions.oldProgram;
|
|
@@ -111885,7 +112619,7 @@ var ts;
|
|
|
111885
112619
|
var programDiagnostics = ts.createDiagnosticCollection();
|
|
111886
112620
|
var currentDirectory = host.getCurrentDirectory();
|
|
111887
112621
|
var supportedExtensions = ts.getSupportedExtensions(options);
|
|
111888
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
112622
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
111889
112623
|
// Map storing if there is emit blocking diagnostics for given input
|
|
111890
112624
|
var hasEmitBlockingDiagnostics = new ts.Map();
|
|
111891
112625
|
var _compilerOptionsObjectLiteralSyntax;
|
|
@@ -111894,7 +112628,7 @@ var ts;
|
|
|
111894
112628
|
var actualResolveModuleNamesWorker;
|
|
111895
112629
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
111896
112630
|
if (host.resolveModuleNames) {
|
|
111897
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames),
|
|
112631
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
|
|
111898
112632
|
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
|
111899
112633
|
if (!resolved || resolved.extension !== undefined) {
|
|
111900
112634
|
return resolved;
|
|
@@ -111903,11 +112637,12 @@ var ts;
|
|
|
111903
112637
|
withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
|
|
111904
112638
|
return withExtension;
|
|
111905
112639
|
}); };
|
|
112640
|
+
moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
111906
112641
|
}
|
|
111907
112642
|
else {
|
|
111908
112643
|
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
111909
|
-
var loader_1 = function (moduleName,
|
|
111910
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return
|
|
112644
|
+
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
|
|
112645
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
|
|
111911
112646
|
}
|
|
111912
112647
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
111913
112648
|
if (host.resolveTypeReferenceDirectives) {
|
|
@@ -111943,9 +112678,9 @@ var ts;
|
|
|
111943
112678
|
var projectReferenceRedirects;
|
|
111944
112679
|
var mapFromFileToProjectReferenceRedirects;
|
|
111945
112680
|
var mapFromToProjectReferenceRedirectSource;
|
|
111946
|
-
var useSourceOfProjectReferenceRedirect = !!((
|
|
112681
|
+
var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
|
|
111947
112682
|
!options.disableSourceOfProjectReferenceRedirect;
|
|
111948
|
-
var
|
|
112683
|
+
var _e = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
111949
112684
|
compilerHost: host,
|
|
111950
112685
|
getSymlinkCache: getSymlinkCache,
|
|
111951
112686
|
useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
|
|
@@ -111953,7 +112688,7 @@ var ts;
|
|
|
111953
112688
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
111954
112689
|
getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
|
|
111955
112690
|
forEachResolvedProjectReference: forEachResolvedProjectReference
|
|
111956
|
-
}), onProgramCreateComplete =
|
|
112691
|
+
}), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
|
|
111957
112692
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
111958
112693
|
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
111959
112694
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112012,7 +112747,7 @@ var ts;
|
|
|
112012
112747
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
112013
112748
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
112014
112749
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
112015
|
-
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (
|
|
112750
|
+
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
112016
112751
|
}
|
|
112017
112752
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
112018
112753
|
}
|
|
@@ -112029,7 +112764,7 @@ var ts;
|
|
|
112029
112764
|
}
|
|
112030
112765
|
else {
|
|
112031
112766
|
ts.forEach(options.lib, function (libFileName, index) {
|
|
112032
|
-
processRootFile(
|
|
112767
|
+
processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.LibFile, index: index });
|
|
112033
112768
|
});
|
|
112034
112769
|
}
|
|
112035
112770
|
}
|
|
@@ -112130,7 +112865,7 @@ var ts;
|
|
|
112130
112865
|
fileExists: fileExists,
|
|
112131
112866
|
directoryExists: directoryExists,
|
|
112132
112867
|
getSymlinkCache: getSymlinkCache,
|
|
112133
|
-
realpath: (
|
|
112868
|
+
realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
|
|
112134
112869
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
112135
112870
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
112136
112871
|
structureIsReused: structureIsReused,
|
|
@@ -112160,7 +112895,7 @@ var ts;
|
|
|
112160
112895
|
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
112161
112896
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
|
|
112162
112897
|
ts.performance.mark("beforeResolveModule");
|
|
112163
|
-
var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
|
|
112898
|
+
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
|
|
112164
112899
|
ts.performance.mark("afterResolveModule");
|
|
112165
112900
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
112166
112901
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112226,8 +112961,8 @@ var ts;
|
|
|
112226
112961
|
}
|
|
112227
112962
|
return ts.libs.length + 2;
|
|
112228
112963
|
}
|
|
112229
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
112230
|
-
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
|
|
112964
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
112965
|
+
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
112231
112966
|
}
|
|
112232
112967
|
function toPath(fileName) {
|
|
112233
112968
|
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
@@ -112269,9 +113004,11 @@ var ts;
|
|
|
112269
113004
|
// Since we assume the filesystem does not change during program creation,
|
|
112270
113005
|
// it is safe to reuse resolutions from the earlier call.
|
|
112271
113006
|
var result_14 = [];
|
|
113007
|
+
var i = 0;
|
|
112272
113008
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
112273
113009
|
var moduleName = moduleNames_1[_i];
|
|
112274
|
-
var resolvedModule = file.resolvedModules.get(moduleName);
|
|
113010
|
+
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113011
|
+
i++;
|
|
112275
113012
|
result_14.push(resolvedModule);
|
|
112276
113013
|
}
|
|
112277
113014
|
return result_14;
|
|
@@ -112299,7 +113036,7 @@ var ts;
|
|
|
112299
113036
|
var moduleName = moduleNames[i];
|
|
112300
113037
|
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
112301
113038
|
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
112302
|
-
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
|
|
113039
|
+
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
|
|
112303
113040
|
if (oldResolvedModule) {
|
|
112304
113041
|
if (ts.isTraceEnabled(options, host)) {
|
|
112305
113042
|
ts.trace(host, oldResolvedModule.packageId ?
|
|
@@ -112323,7 +113060,7 @@ var ts;
|
|
|
112323
113060
|
}
|
|
112324
113061
|
}
|
|
112325
113062
|
else {
|
|
112326
|
-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
|
|
113063
|
+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
|
|
112327
113064
|
}
|
|
112328
113065
|
if (resolvesToAmbientModuleInNonModifiedFile) {
|
|
112329
113066
|
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
|
@@ -112360,8 +113097,8 @@ var ts;
|
|
|
112360
113097
|
return result;
|
|
112361
113098
|
// If we change our policy of rechecking failed lookups on each program create,
|
|
112362
113099
|
// we should adjust the value returned here.
|
|
112363
|
-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
112364
|
-
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
|
|
113100
|
+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, index) {
|
|
113101
|
+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index));
|
|
112365
113102
|
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
112366
113103
|
if (resolutionToFile && resolvedFile) {
|
|
112367
113104
|
// In the old program, we resolved to an ambient module that was in the same
|
|
@@ -112444,8 +113181,8 @@ var ts;
|
|
|
112444
113181
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
112445
113182
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
112446
113183
|
var newSourceFile = host.getSourceFileByPath
|
|
112447
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options
|
|
112448
|
-
: host.getSourceFile(oldSourceFile.fileName, options
|
|
113184
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
|
|
113185
|
+
: host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
|
|
112449
113186
|
if (!newSourceFile) {
|
|
112450
113187
|
return 0 /* Not */;
|
|
112451
113188
|
}
|
|
@@ -112552,10 +113289,10 @@ var ts;
|
|
|
112552
113289
|
var moduleNames = getModuleNames(newSourceFile);
|
|
112553
113290
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
112554
113291
|
// ensure that module resolution results are still correct
|
|
112555
|
-
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
|
|
113292
|
+
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
|
|
112556
113293
|
if (resolutionsChanged) {
|
|
112557
113294
|
structureIsReused = 1 /* SafeModules */;
|
|
112558
|
-
newSourceFile.resolvedModules = ts.
|
|
113295
|
+
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
112559
113296
|
}
|
|
112560
113297
|
else {
|
|
112561
113298
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
@@ -112564,10 +113301,10 @@ var ts;
|
|
|
112564
113301
|
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
112565
113302
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
112566
113303
|
// ensure that types resolutions are still correct
|
|
112567
|
-
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
|
|
113304
|
+
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
112568
113305
|
if (typeReferenceEesolutionsChanged) {
|
|
112569
113306
|
structureIsReused = 1 /* SafeModules */;
|
|
112570
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.
|
|
113307
|
+
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
112571
113308
|
}
|
|
112572
113309
|
else {
|
|
112573
113310
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
@@ -112691,7 +113428,7 @@ var ts;
|
|
|
112691
113428
|
return equalityComparer(file.fileName, getDefaultLibraryFileName());
|
|
112692
113429
|
}
|
|
112693
113430
|
else {
|
|
112694
|
-
return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName,
|
|
113431
|
+
return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
|
|
112695
113432
|
}
|
|
112696
113433
|
}
|
|
112697
113434
|
function getDiagnosticsProducingTypeChecker() {
|
|
@@ -113273,7 +114010,7 @@ var ts;
|
|
|
113273
114010
|
var libName = ts.toFileNameLowerCase(ref.fileName);
|
|
113274
114011
|
var libFileName = ts.libMap.get(libName);
|
|
113275
114012
|
if (libFileName) {
|
|
113276
|
-
return getSourceFile(
|
|
114013
|
+
return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
|
|
113277
114014
|
}
|
|
113278
114015
|
}
|
|
113279
114016
|
/** This should have similar behavior to 'processSourceFile' without diagnostics or mutation. */
|
|
@@ -113283,13 +114020,13 @@ var ts;
|
|
|
113283
114020
|
function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) {
|
|
113284
114021
|
if (ts.hasExtension(fileName)) {
|
|
113285
114022
|
var canonicalFileName_1 = host.getCanonicalFileName(fileName);
|
|
113286
|
-
if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
114023
|
+
if (!options.allowNonTsExtensions && !ts.forEach(ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
113287
114024
|
if (fail) {
|
|
113288
114025
|
if (ts.hasJSFileExtension(canonicalFileName_1)) {
|
|
113289
114026
|
fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
|
|
113290
114027
|
}
|
|
113291
114028
|
else {
|
|
113292
|
-
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114029
|
+
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113293
114030
|
}
|
|
113294
114031
|
}
|
|
113295
114032
|
return undefined;
|
|
@@ -113319,9 +114056,10 @@ var ts;
|
|
|
113319
114056
|
fail(ts.Diagnostics.File_0_not_found, fileName);
|
|
113320
114057
|
return undefined;
|
|
113321
114058
|
}
|
|
113322
|
-
|
|
114059
|
+
// Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts)
|
|
114060
|
+
var sourceFileWithAddedExtension = ts.forEach(supportedExtensions[0], function (extension) { return getSourceFile(fileName + extension); });
|
|
113323
114061
|
if (fail && !sourceFileWithAddedExtension)
|
|
113324
|
-
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114062
|
+
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113325
114063
|
return sourceFileWithAddedExtension;
|
|
113326
114064
|
}
|
|
113327
114065
|
}
|
|
@@ -113466,7 +114204,7 @@ var ts;
|
|
|
113466
114204
|
}
|
|
113467
114205
|
}
|
|
113468
114206
|
// We haven't looked for this file, do so now and cache result
|
|
113469
|
-
var file = host.getSourceFile(fileName, options
|
|
114207
|
+
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);
|
|
113470
114208
|
if (packageId) {
|
|
113471
114209
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
113472
114210
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
@@ -113494,6 +114232,10 @@ var ts;
|
|
|
113494
114232
|
file.path = path;
|
|
113495
114233
|
file.resolvedPath = toPath(fileName);
|
|
113496
114234
|
file.originalFileName = originalFileName;
|
|
114235
|
+
// 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
|
|
114236
|
+
// 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
|
|
114237
|
+
// 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.
|
|
114238
|
+
file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
113497
114239
|
addFileIncludeReason(file, reason);
|
|
113498
114240
|
if (host.useCaseSensitiveFileNames()) {
|
|
113499
114241
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -113684,31 +114426,13 @@ var ts;
|
|
|
113684
114426
|
resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
|
|
113685
114427
|
}
|
|
113686
114428
|
}
|
|
113687
|
-
function pathForLibFile(libFileName) {
|
|
113688
|
-
// Support resolving to lib.dom.d.ts -> @typescript/dom, and
|
|
113689
|
-
// lib.dom.iterable.d.ts -> @typescript/dom/iterable
|
|
113690
|
-
// lib.es2015.symbol.wellknown.d.ts -> @typescript/es2015/symbol-wellknown
|
|
113691
|
-
var components = libFileName.split(".");
|
|
113692
|
-
var path = components[1];
|
|
113693
|
-
var i = 2;
|
|
113694
|
-
while (components[i] && components[i] !== "d") {
|
|
113695
|
-
path += (i === 2 ? "/" : "-") + components[i];
|
|
113696
|
-
i++;
|
|
113697
|
-
}
|
|
113698
|
-
// The strange "/fake.file" is to ensure we first resolve in node_modules for the current directory.
|
|
113699
|
-
var localOverride = ts.resolveModuleName("@typescript/" + path, currentDirectory + "/fake.file", { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host);
|
|
113700
|
-
if (localOverride === null || localOverride === void 0 ? void 0 : localOverride.resolvedModule) {
|
|
113701
|
-
return localOverride.resolvedModule.resolvedFileName;
|
|
113702
|
-
}
|
|
113703
|
-
return ts.combinePaths(defaultLibraryPath, libFileName);
|
|
113704
|
-
}
|
|
113705
114429
|
function processLibReferenceDirectives(file) {
|
|
113706
114430
|
ts.forEach(file.libReferenceDirectives, function (libReference, index) {
|
|
113707
114431
|
var libName = ts.toFileNameLowerCase(libReference.fileName);
|
|
113708
114432
|
var libFileName = ts.libMap.get(libName);
|
|
113709
114433
|
if (libFileName) {
|
|
113710
114434
|
// we ignore any 'no-default-lib' reference set on this file.
|
|
113711
|
-
processRootFile(
|
|
114435
|
+
processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ true, { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, });
|
|
113712
114436
|
}
|
|
113713
114437
|
else {
|
|
113714
114438
|
var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
|
|
@@ -113737,7 +114461,7 @@ var ts;
|
|
|
113737
114461
|
var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options;
|
|
113738
114462
|
for (var index = 0; index < moduleNames.length; index++) {
|
|
113739
114463
|
var resolution = resolutions[index];
|
|
113740
|
-
ts.setResolvedModule(file, moduleNames[index], resolution);
|
|
114464
|
+
ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
|
|
113741
114465
|
if (!resolution) {
|
|
113742
114466
|
continue;
|
|
113743
114467
|
}
|
|
@@ -113960,7 +114684,7 @@ var ts;
|
|
|
113960
114684
|
if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
|
|
113961
114685
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
|
|
113962
114686
|
}
|
|
113963
|
-
var languageVersion = options
|
|
114687
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
113964
114688
|
var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
|
|
113965
114689
|
if (options.isolatedModules) {
|
|
113966
114690
|
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
|
|
@@ -114221,7 +114945,7 @@ var ts;
|
|
|
114221
114945
|
message = ts.Diagnostics.File_is_library_specified_here;
|
|
114222
114946
|
break;
|
|
114223
114947
|
}
|
|
114224
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
114948
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
114225
114949
|
configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
|
|
114226
114950
|
message = ts.Diagnostics.File_is_default_library_for_target_specified_here;
|
|
114227
114951
|
break;
|
|
@@ -114389,7 +115113,7 @@ var ts;
|
|
|
114389
115113
|
if (options.outDir) {
|
|
114390
115114
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
114391
115115
|
}
|
|
114392
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.
|
|
115116
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
|
|
114393
115117
|
// Otherwise just check if sourceFile with the name exists
|
|
114394
115118
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
114395
115119
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -114921,7 +115645,7 @@ var ts;
|
|
|
114921
115645
|
}
|
|
114922
115646
|
}
|
|
114923
115647
|
}
|
|
114924
|
-
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
|
|
115648
|
+
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
|
|
114925
115649
|
}
|
|
114926
115650
|
return {
|
|
114927
115651
|
fileInfos: fileInfos,
|
|
@@ -115015,7 +115739,7 @@ var ts;
|
|
|
115015
115739
|
/*forceDtsEmit*/ true);
|
|
115016
115740
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
115017
115741
|
if (firstDts_1) {
|
|
115018
|
-
ts.Debug.assert(ts.
|
|
115742
|
+
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; })); });
|
|
115019
115743
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
115020
115744
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
115021
115745
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -115339,6 +116063,14 @@ var ts;
|
|
|
115339
116063
|
ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
|
|
115340
116064
|
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
|
|
115341
116065
|
}
|
|
116066
|
+
if (useOldState) {
|
|
116067
|
+
// Any time the interpretation of a source file changes, mark it as changed
|
|
116068
|
+
ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
|
|
116069
|
+
if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
|
|
116070
|
+
state.changedFilesSet.add(sourceFilePath);
|
|
116071
|
+
}
|
|
116072
|
+
});
|
|
116073
|
+
}
|
|
115342
116074
|
state.buildInfoEmitPending = !!state.changedFilesSet.size;
|
|
115343
116075
|
return state;
|
|
115344
116076
|
}
|
|
@@ -115735,13 +116467,13 @@ var ts;
|
|
|
115735
116467
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
115736
116468
|
return value.version === actualSignature ?
|
|
115737
116469
|
value.affectsGlobalScope ?
|
|
115738
|
-
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
|
|
116470
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
|
|
115739
116471
|
value.version :
|
|
115740
116472
|
actualSignature !== undefined ?
|
|
115741
116473
|
signature === undefined ?
|
|
115742
116474
|
value :
|
|
115743
|
-
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } :
|
|
115744
|
-
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
|
|
116475
|
+
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
116476
|
+
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
115745
116477
|
});
|
|
115746
116478
|
var referencedMap;
|
|
115747
116479
|
if (state.referencedMap) {
|
|
@@ -116161,10 +116893,10 @@ var ts;
|
|
|
116161
116893
|
}
|
|
116162
116894
|
function toBuilderStateFileInfo(fileInfo) {
|
|
116163
116895
|
return ts.isString(fileInfo) ?
|
|
116164
|
-
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
|
|
116896
|
+
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
|
|
116165
116897
|
ts.isString(fileInfo.signature) ?
|
|
116166
116898
|
fileInfo :
|
|
116167
|
-
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
|
|
116899
|
+
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
116168
116900
|
}
|
|
116169
116901
|
ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
|
|
116170
116902
|
function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
|
|
@@ -116502,14 +117234,14 @@ var ts;
|
|
|
116502
117234
|
}
|
|
116503
117235
|
function resolveNamesWithLocalCache(_a) {
|
|
116504
117236
|
var _b, _c, _d;
|
|
116505
|
-
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;
|
|
117237
|
+
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;
|
|
116506
117238
|
var path = resolutionHost.toPath(containingFile);
|
|
116507
|
-
var resolutionsInFile = cache.get(path) || cache.set(path,
|
|
117239
|
+
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
116508
117240
|
var dirPath = ts.getDirectoryPath(path);
|
|
116509
117241
|
var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
116510
117242
|
var perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
116511
117243
|
if (!perDirectoryResolution) {
|
|
116512
|
-
perDirectoryResolution =
|
|
117244
|
+
perDirectoryResolution = ts.createModeAwareCache();
|
|
116513
117245
|
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
116514
117246
|
}
|
|
116515
117247
|
var resolvedModules = [];
|
|
@@ -116521,17 +117253,20 @@ var ts;
|
|
|
116521
117253
|
var unmatchedRedirects = oldRedirect ?
|
|
116522
117254
|
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
|
116523
117255
|
!!redirectedReference;
|
|
116524
|
-
var seenNamesInFile =
|
|
116525
|
-
|
|
116526
|
-
|
|
116527
|
-
var
|
|
117256
|
+
var seenNamesInFile = ts.createModeAwareCache();
|
|
117257
|
+
var i = 0;
|
|
117258
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
117259
|
+
var name = names_4[_i];
|
|
117260
|
+
var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
117261
|
+
i++;
|
|
117262
|
+
var resolution = resolutionsInFile.get(name, mode);
|
|
116528
117263
|
// Resolution is valid if it is present and not invalidated
|
|
116529
|
-
if (!seenNamesInFile.has(name) &&
|
|
117264
|
+
if (!seenNamesInFile.has(name, mode) &&
|
|
116530
117265
|
unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
116531
117266
|
// If the name is unresolved import that was invalidated, recalculate
|
|
116532
117267
|
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
116533
117268
|
var existingResolution = resolution;
|
|
116534
|
-
var resolutionInDirectory = perDirectoryResolution.get(name);
|
|
117269
|
+
var resolutionInDirectory = perDirectoryResolution.get(name, mode);
|
|
116535
117270
|
if (resolutionInDirectory) {
|
|
116536
117271
|
resolution = resolutionInDirectory;
|
|
116537
117272
|
var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
@@ -116551,10 +117286,10 @@ var ts;
|
|
|
116551
117286
|
}
|
|
116552
117287
|
}
|
|
116553
117288
|
else {
|
|
116554
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference);
|
|
116555
|
-
perDirectoryResolution.set(name, resolution);
|
|
117289
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
117290
|
+
perDirectoryResolution.set(name, mode, resolution);
|
|
116556
117291
|
}
|
|
116557
|
-
resolutionsInFile.set(name, resolution);
|
|
117292
|
+
resolutionsInFile.set(name, mode, resolution);
|
|
116558
117293
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
116559
117294
|
if (existingResolution) {
|
|
116560
117295
|
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
|
@@ -116567,7 +117302,7 @@ var ts;
|
|
|
116567
117302
|
}
|
|
116568
117303
|
else {
|
|
116569
117304
|
var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost;
|
|
116570
|
-
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) {
|
|
117305
|
+
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
116571
117306
|
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
116572
117307
|
ts.trace(host, loader === resolveModuleName ?
|
|
116573
117308
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
@@ -116583,14 +117318,14 @@ var ts;
|
|
|
116583
117318
|
}
|
|
116584
117319
|
}
|
|
116585
117320
|
ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
|
|
116586
|
-
seenNamesInFile.set(name, true);
|
|
117321
|
+
seenNamesInFile.set(name, mode, true);
|
|
116587
117322
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
116588
117323
|
}
|
|
116589
117324
|
// Stop watching and remove the unused name
|
|
116590
|
-
resolutionsInFile.forEach(function (resolution, name) {
|
|
116591
|
-
if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
|
|
117325
|
+
resolutionsInFile.forEach(function (resolution, name, mode) {
|
|
117326
|
+
if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
|
|
116592
117327
|
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
116593
|
-
resolutionsInFile.delete(name);
|
|
117328
|
+
resolutionsInFile.delete(name, mode);
|
|
116594
117329
|
}
|
|
116595
117330
|
});
|
|
116596
117331
|
return resolvedModules;
|
|
@@ -116624,7 +117359,7 @@ var ts;
|
|
|
116624
117359
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
116625
117360
|
});
|
|
116626
117361
|
}
|
|
116627
|
-
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
117362
|
+
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
116628
117363
|
return resolveNamesWithLocalCache({
|
|
116629
117364
|
names: moduleNames,
|
|
116630
117365
|
containingFile: containingFile,
|
|
@@ -116636,11 +117371,14 @@ var ts;
|
|
|
116636
117371
|
shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
|
|
116637
117372
|
reusedNames: reusedNames,
|
|
116638
117373
|
logChanges: logChangesWhenResolvingModule,
|
|
117374
|
+
containingSourceFile: containingSourceFile,
|
|
116639
117375
|
});
|
|
116640
117376
|
}
|
|
116641
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
117377
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
|
|
116642
117378
|
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
|
|
116643
|
-
|
|
117379
|
+
if (!cache)
|
|
117380
|
+
return undefined;
|
|
117381
|
+
return cache.get(moduleName, resolutionMode);
|
|
116644
117382
|
}
|
|
116645
117383
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
116646
117384
|
return ts.endsWith(dirPath, "/node_modules/@types");
|
|
@@ -117565,7 +118303,7 @@ var ts;
|
|
|
117565
118303
|
if (!host.fileExists)
|
|
117566
118304
|
return;
|
|
117567
118305
|
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
|
|
117568
|
-
var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]);
|
|
118306
|
+
var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]));
|
|
117569
118307
|
for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
|
|
117570
118308
|
var e = extensions_3[_i];
|
|
117571
118309
|
var fullPath = path + e;
|
|
@@ -117663,6 +118401,14 @@ var ts;
|
|
|
117663
118401
|
case ".jsx" /* Jsx */:
|
|
117664
118402
|
case ".json" /* Json */:
|
|
117665
118403
|
return ext;
|
|
118404
|
+
case ".d.mts" /* Dmts */:
|
|
118405
|
+
case ".mts" /* Mts */:
|
|
118406
|
+
case ".mjs" /* Mjs */:
|
|
118407
|
+
return ".mjs" /* Mjs */;
|
|
118408
|
+
case ".d.cts" /* Dcts */:
|
|
118409
|
+
case ".cts" /* Cts */:
|
|
118410
|
+
case ".cjs" /* Cjs */:
|
|
118411
|
+
return ".cjs" /* Cjs */;
|
|
117666
118412
|
default:
|
|
117667
118413
|
return undefined;
|
|
117668
118414
|
}
|
|
@@ -117937,7 +118683,7 @@ var ts;
|
|
|
117937
118683
|
case ts.FileIncludeKind.LibFile:
|
|
117938
118684
|
if (reason.index !== undefined)
|
|
117939
118685
|
return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]);
|
|
117940
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
118686
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
117941
118687
|
return ts.chainDiagnosticMessages(
|
|
117942
118688
|
/*details*/ undefined, target ?
|
|
117943
118689
|
ts.Diagnostics.Default_library_for_target_0 :
|
|
@@ -118360,7 +119106,7 @@ var ts;
|
|
|
118360
119106
|
}
|
|
118361
119107
|
return host.resolveModuleNames.apply(host, args);
|
|
118362
119108
|
}) :
|
|
118363
|
-
(function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
|
|
119109
|
+
(function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
|
|
118364
119110
|
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
|
118365
119111
|
(function () {
|
|
118366
119112
|
var args = [];
|
|
@@ -119088,10 +119834,11 @@ var ts;
|
|
|
119088
119834
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
119089
119835
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
119090
119836
|
if (!compilerHost.resolveModuleNames) {
|
|
119091
|
-
var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
|
|
119092
|
-
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
|
|
119093
|
-
return ts.
|
|
119837
|
+
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
|
|
119838
|
+
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
119839
|
+
return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
|
|
119094
119840
|
};
|
|
119841
|
+
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
119095
119842
|
}
|
|
119096
119843
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
119097
119844
|
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
@@ -120780,6 +121527,12 @@ var ts;
|
|
|
120780
121527
|
ScriptElementKindModifier["jsModifier"] = ".js";
|
|
120781
121528
|
ScriptElementKindModifier["jsxModifier"] = ".jsx";
|
|
120782
121529
|
ScriptElementKindModifier["jsonModifier"] = ".json";
|
|
121530
|
+
ScriptElementKindModifier["dmtsModifier"] = ".d.mts";
|
|
121531
|
+
ScriptElementKindModifier["mtsModifier"] = ".mts";
|
|
121532
|
+
ScriptElementKindModifier["mjsModifier"] = ".mjs";
|
|
121533
|
+
ScriptElementKindModifier["dctsModifier"] = ".d.cts";
|
|
121534
|
+
ScriptElementKindModifier["ctsModifier"] = ".cts";
|
|
121535
|
+
ScriptElementKindModifier["cjsModifier"] = ".cjs";
|
|
120783
121536
|
})(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {}));
|
|
120784
121537
|
var ClassificationTypeNames;
|
|
120785
121538
|
(function (ClassificationTypeNames) {
|
|
@@ -122569,7 +123322,7 @@ var ts;
|
|
|
122569
123322
|
}
|
|
122570
123323
|
ts.programContainsEs6Modules = programContainsEs6Modules;
|
|
122571
123324
|
function compilerOptionsIndicateEs6Modules(compilerOptions) {
|
|
122572
|
-
return !!compilerOptions.module || compilerOptions
|
|
123325
|
+
return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
|
|
122573
123326
|
}
|
|
122574
123327
|
ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
|
|
122575
123328
|
function createModuleSpecifierResolutionHost(program, host) {
|
|
@@ -125544,6 +126297,12 @@ var ts;
|
|
|
125544
126297
|
case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */;
|
|
125545
126298
|
case ".ts" /* Ts */: return ".ts" /* tsModifier */;
|
|
125546
126299
|
case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */;
|
|
126300
|
+
case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */;
|
|
126301
|
+
case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */;
|
|
126302
|
+
case ".mts" /* Mts */: return ".mts" /* mtsModifier */;
|
|
126303
|
+
case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */;
|
|
126304
|
+
case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */;
|
|
126305
|
+
case ".cts" /* Cts */: return ".cts" /* ctsModifier */;
|
|
125547
126306
|
case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported.");
|
|
125548
126307
|
case undefined: return "" /* none */;
|
|
125549
126308
|
default:
|
|
@@ -125738,7 +126497,7 @@ var ts;
|
|
|
125738
126497
|
}
|
|
125739
126498
|
function getExtensionOptions(compilerOptions, includeExtensionsOption) {
|
|
125740
126499
|
if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; }
|
|
125741
|
-
return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption: includeExtensionsOption };
|
|
126500
|
+
return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption };
|
|
125742
126501
|
}
|
|
125743
126502
|
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) {
|
|
125744
126503
|
var includeExtensions = preferences.importModuleSpecifierEnding === "js" ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
|
|
@@ -125752,8 +126511,8 @@ var ts;
|
|
|
125752
126511
|
}
|
|
125753
126512
|
function getSupportedExtensionsForModuleResolution(compilerOptions) {
|
|
125754
126513
|
var extensions = ts.getSupportedExtensions(compilerOptions);
|
|
125755
|
-
return
|
|
125756
|
-
|
|
126514
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
|
|
126515
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
|
|
125757
126516
|
extensions;
|
|
125758
126517
|
}
|
|
125759
126518
|
/**
|
|
@@ -126431,15 +127190,15 @@ var ts;
|
|
|
126431
127190
|
var entries = [];
|
|
126432
127191
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
126433
127192
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
126434
|
-
/* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions
|
|
126435
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions
|
|
127193
|
+
/* contextToken */ undefined, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
127194
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
126436
127195
|
}
|
|
126437
127196
|
else {
|
|
126438
127197
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
126439
127198
|
return undefined;
|
|
126440
127199
|
}
|
|
126441
127200
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
126442
|
-
/* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions
|
|
127201
|
+
/* contextToken */ undefined, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
126443
127202
|
}
|
|
126444
127203
|
if (keywordFilters !== 0 /* None */) {
|
|
126445
127204
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -126823,7 +127582,7 @@ var ts;
|
|
|
126823
127582
|
// completion entry.
|
|
126824
127583
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
126825
127584
|
var origin = symbolToOriginInfoMap[index];
|
|
126826
|
-
var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions
|
|
127585
|
+
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
126827
127586
|
return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
|
|
126828
127587
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
126829
127588
|
: undefined;
|
|
@@ -126900,7 +127659,7 @@ var ts;
|
|
|
126900
127659
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
126901
127660
|
var moduleSymbol = origin.moduleSymbol;
|
|
126902
127661
|
var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
126903
|
-
var _b = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions
|
|
127662
|
+
var _b = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions)), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _b.moduleSpecifier, codeAction = _b.codeAction;
|
|
126904
127663
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
126905
127664
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
126906
127665
|
}
|
|
@@ -129453,7 +130212,7 @@ var ts;
|
|
|
129453
130212
|
}
|
|
129454
130213
|
function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
129455
130214
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
129456
|
-
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings
|
|
130215
|
+
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
129457
130216
|
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
|
|
129458
130217
|
var bucketEntry = bucket.get(path);
|
|
129459
130218
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
@@ -130724,7 +131483,7 @@ var ts;
|
|
|
130724
131483
|
if (!options.implementations && ts.isStringLiteralLike(node)) {
|
|
130725
131484
|
if (ts.isModuleSpecifierLike(node)) {
|
|
130726
131485
|
var fileIncludeReasons = program.getFileIncludeReasons();
|
|
130727
|
-
var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
131486
|
+
var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
130728
131487
|
var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
|
|
130729
131488
|
if (referencedFile) {
|
|
130730
131489
|
return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }];
|
|
@@ -132882,9 +133641,10 @@ var ts;
|
|
|
132882
133641
|
return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true };
|
|
132883
133642
|
}
|
|
132884
133643
|
else {
|
|
133644
|
+
var mode = ts.getModeForResolutionAtIndex({ statements: importingSourceFile.statements, imports: [importLiteral], moduleAugmentations: [], impliedNodeFormat: importingSourceFile.impliedNodeFormat }, 0);
|
|
132885
133645
|
var resolved = host.resolveModuleNames
|
|
132886
|
-
? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName)
|
|
132887
|
-
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName);
|
|
133646
|
+
? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode)
|
|
133647
|
+
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
132888
133648
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
132889
133649
|
}
|
|
132890
133650
|
}
|
|
@@ -133109,10 +133869,10 @@ var ts;
|
|
|
133109
133869
|
var file = program.getLibFileFromReference(libReferenceDirective);
|
|
133110
133870
|
return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
133111
133871
|
}
|
|
133112
|
-
if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) {
|
|
133872
|
+
if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
|
|
133113
133873
|
var node = ts.getTokenAtPosition(sourceFile, position);
|
|
133114
|
-
if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) {
|
|
133115
|
-
var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
133874
|
+
if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
|
|
133875
|
+
var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
133116
133876
|
var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
|
|
133117
133877
|
return {
|
|
133118
133878
|
file: program.getSourceFile(fileName),
|
|
@@ -137820,7 +138580,7 @@ var ts;
|
|
|
137820
138580
|
var name = importNameForConvertToDefaultImport(importNode);
|
|
137821
138581
|
if (!name)
|
|
137822
138582
|
continue;
|
|
137823
|
-
var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text);
|
|
138583
|
+
var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
|
|
137824
138584
|
var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
|
|
137825
138585
|
if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
|
137826
138586
|
diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
|
|
@@ -138720,7 +139480,7 @@ var ts;
|
|
|
138720
139480
|
options.allowNonTsExtensions = true;
|
|
138721
139481
|
// if jsx is specified then treat file as .tsx
|
|
138722
139482
|
var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
|
|
138723
|
-
var sourceFile = ts.createSourceFile(inputFileName, input, options
|
|
139483
|
+
var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
|
|
138724
139484
|
if (transpileOptions.moduleName) {
|
|
138725
139485
|
sourceFile.moduleName = transpileOptions.moduleName;
|
|
138726
139486
|
}
|
|
@@ -144292,7 +145052,7 @@ var ts;
|
|
|
144292
145052
|
return propName;
|
|
144293
145053
|
}
|
|
144294
145054
|
if (ts.isStringLiteralLike(propName)) {
|
|
144295
|
-
return ts.isIdentifierText(propName.text, compilerOptions
|
|
145055
|
+
return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text)
|
|
144296
145056
|
: ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */)
|
|
144297
145057
|
: propName;
|
|
144298
145058
|
}
|
|
@@ -145040,7 +145800,7 @@ var ts;
|
|
|
145040
145800
|
getCodeActions: function (context) {
|
|
145041
145801
|
var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
|
|
145042
145802
|
var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
145043
|
-
var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions()
|
|
145803
|
+
var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
|
|
145044
145804
|
if (moduleExportsChangedToDefault) {
|
|
145045
145805
|
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
|
|
145046
145806
|
var importingFile = _a[_i];
|
|
@@ -145055,7 +145815,7 @@ var ts;
|
|
|
145055
145815
|
function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
|
|
145056
145816
|
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
|
145057
145817
|
var moduleSpecifier = _a[_i];
|
|
145058
|
-
var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text);
|
|
145818
|
+
var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text, ts.getModeForUsageLocation(importingFile, moduleSpecifier));
|
|
145059
145819
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
145060
145820
|
continue;
|
|
145061
145821
|
}
|
|
@@ -146006,7 +146766,7 @@ var ts;
|
|
|
146006
146766
|
return;
|
|
146007
146767
|
}
|
|
146008
146768
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
146009
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions
|
|
146769
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
146010
146770
|
result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
146011
146771
|
}
|
|
146012
146772
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
@@ -146301,6 +147061,9 @@ var ts;
|
|
|
146301
147061
|
case ts.ModuleKind.None:
|
|
146302
147062
|
// Fall back to the `import * as ns` style import.
|
|
146303
147063
|
return 2 /* Namespace */;
|
|
147064
|
+
case ts.ModuleKind.Node12:
|
|
147065
|
+
case ts.ModuleKind.NodeNext:
|
|
147066
|
+
return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */;
|
|
146304
147067
|
default:
|
|
146305
147068
|
return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind);
|
|
146306
147069
|
}
|
|
@@ -146355,7 +147118,7 @@ var ts;
|
|
|
146355
147118
|
cancellationToken.throwIfCancellationRequested();
|
|
146356
147119
|
var compilerOptions = program.getCompilerOptions();
|
|
146357
147120
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
146358
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions
|
|
147121
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
146359
147122
|
addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
|
|
146360
147123
|
}
|
|
146361
147124
|
// check exports with the same name
|
|
@@ -146875,14 +147638,14 @@ var ts;
|
|
|
146875
147638
|
if (!info)
|
|
146876
147639
|
return undefined;
|
|
146877
147640
|
var node = info.node, suggestedSymbol = info.suggestedSymbol;
|
|
146878
|
-
var target = context.host.getCompilationSettings()
|
|
147641
|
+
var target = ts.getEmitScriptTarget(context.host.getCompilationSettings());
|
|
146879
147642
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, node, suggestedSymbol, target); });
|
|
146880
147643
|
return [codefix.createCodeFixAction("spelling", changes, [ts.Diagnostics.Change_spelling_to_0, ts.symbolName(suggestedSymbol)], fixId, ts.Diagnostics.Fix_all_detected_spelling_errors)];
|
|
146881
147644
|
},
|
|
146882
147645
|
fixIds: [fixId],
|
|
146883
147646
|
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146884
147647
|
var info = getInfo(diag.file, diag.start, context, diag.code);
|
|
146885
|
-
var target = context.host.getCompilationSettings()
|
|
147648
|
+
var target = ts.getEmitScriptTarget(context.host.getCompilationSettings());
|
|
146886
147649
|
if (info)
|
|
146887
147650
|
doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
146888
147651
|
}); },
|
|
@@ -146975,7 +147738,7 @@ var ts;
|
|
|
146975
147738
|
function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration) {
|
|
146976
147739
|
if (!importDeclaration || !ts.isStringLiteralLike(importDeclaration.moduleSpecifier))
|
|
146977
147740
|
return undefined;
|
|
146978
|
-
var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text);
|
|
147741
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier));
|
|
146979
147742
|
if (!resolvedModule)
|
|
146980
147743
|
return undefined;
|
|
146981
147744
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -148022,8 +148785,8 @@ var ts;
|
|
|
148022
148785
|
(function (codefix) {
|
|
148023
148786
|
codefix.registerCodeFix({
|
|
148024
148787
|
errorCodes: [
|
|
148025
|
-
ts.Diagnostics.
|
|
148026
|
-
ts.Diagnostics.
|
|
148788
|
+
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.code,
|
|
148789
|
+
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.code,
|
|
148027
148790
|
],
|
|
148028
148791
|
getCodeActions: function (context) {
|
|
148029
148792
|
var compilerOptions = context.program.getCompilerOptions();
|
|
@@ -160634,7 +161397,6 @@ var ts;
|
|
|
160634
161397
|
ts.WatchType.MissingSourceMapFile = "Missing source map file";
|
|
160635
161398
|
ts.WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root";
|
|
160636
161399
|
ts.WatchType.MissingGeneratedFile = "Missing generated file";
|
|
160637
|
-
ts.WatchType.PackageJsonFile = "package.json file for import suggestions";
|
|
160638
161400
|
})(ts || (ts = {}));
|
|
160639
161401
|
/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */
|
|
160640
161402
|
/**
|
|
@@ -161902,11 +162664,11 @@ var ts;
|
|
|
161902
162664
|
var path = this.toPath(file);
|
|
161903
162665
|
return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
|
|
161904
162666
|
};
|
|
161905
|
-
Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
161906
|
-
return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference);
|
|
162667
|
+
Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
162668
|
+
return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
|
|
161907
162669
|
};
|
|
161908
|
-
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile) {
|
|
161909
|
-
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile);
|
|
162670
|
+
Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
|
|
162671
|
+
return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
|
|
161910
162672
|
};
|
|
161911
162673
|
Project.prototype.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile, redirectedReference) {
|
|
161912
162674
|
return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference);
|
|
@@ -166926,7 +167688,7 @@ var ts;
|
|
|
166926
167688
|
watchers.get(path).close();
|
|
166927
167689
|
watchers.delete(path);
|
|
166928
167690
|
}
|
|
166929
|
-
}, ts.PollingInterval.Low, this.hostConfiguration.watchOptions, ts.WatchType.
|
|
167691
|
+
}, ts.PollingInterval.Low, this.hostConfiguration.watchOptions, ts.WatchType.PackageJson));
|
|
166930
167692
|
}
|
|
166931
167693
|
};
|
|
166932
167694
|
/*@internal*/
|