typescript 4.5.0-dev.20210923 → 4.5.0-dev.20210927
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +2 -1
- package/lib/es/diagnosticMessages.generated.json +2 -1
- package/lib/fr/diagnosticMessages.generated.json +2 -1
- package/lib/it/diagnosticMessages.generated.json +2 -1
- package/lib/ja/diagnosticMessages.generated.json +2 -1
- package/lib/ko/diagnosticMessages.generated.json +2 -1
- package/lib/lib.es2021.d.ts +1 -0
- package/lib/lib.es2021.intl.d.ts +9 -0
- package/lib/pl/diagnosticMessages.generated.json +2 -1
- package/lib/pt-br/diagnosticMessages.generated.json +2 -1
- package/lib/ru/diagnosticMessages.generated.json +2 -1
- package/lib/tr/diagnosticMessages.generated.json +2 -1
- package/lib/tsc.js +1278 -386
- package/lib/tsserver.js +1487 -477
- package/lib/tsserverlibrary.d.ts +66 -15
- package/lib/tsserverlibrary.js +1487 -477
- package/lib/typescript.d.ts +64 -13
- package/lib/typescript.js +1482 -471
- package/lib/typescriptServices.d.ts +64 -13
- package/lib/typescriptServices.js +1482 -471
- package/lib/typingsInstaller.js +1413 -428
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -1
- package/lib/zh-tw/diagnosticMessages.generated.json +2 -1
- package/package.json +1 -1
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20210927";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -4928,6 +4928,7 @@ var ts;
|
|
|
4928
4928
|
CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType";
|
|
4929
4929
|
CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped";
|
|
4930
4930
|
CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional";
|
|
4931
|
+
CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved";
|
|
4931
4932
|
CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic";
|
|
4932
4933
|
CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant";
|
|
4933
4934
|
CheckFlags[CheckFlags["Partial"] = 48] = "Partial";
|
|
@@ -5059,7 +5060,7 @@ var ts;
|
|
|
5059
5060
|
TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask";
|
|
5060
5061
|
// The following flags are used for different purposes during union and intersection type construction
|
|
5061
5062
|
/* @internal */
|
|
5062
|
-
TypeFlags[TypeFlags["
|
|
5063
|
+
TypeFlags[TypeFlags["IncludesMissingType"] = 262144] = "IncludesMissingType";
|
|
5063
5064
|
/* @internal */
|
|
5064
5065
|
TypeFlags[TypeFlags["IncludesNonWideningType"] = 4194304] = "IncludesNonWideningType";
|
|
5065
5066
|
/* @internal */
|
|
@@ -5305,6 +5306,12 @@ var ts;
|
|
|
5305
5306
|
(function (ModuleResolutionKind) {
|
|
5306
5307
|
ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
|
|
5307
5308
|
ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
|
|
5309
|
+
// Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
|
|
5310
|
+
// to better support ecmascript modules and their use within node - more features are still being added, so
|
|
5311
|
+
// we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
|
|
5312
|
+
// version-anchored resolution target
|
|
5313
|
+
ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
|
|
5314
|
+
ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
|
|
5308
5315
|
})(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
|
|
5309
5316
|
var WatchFileKind;
|
|
5310
5317
|
(function (WatchFileKind) {
|
|
@@ -5342,6 +5349,9 @@ var ts;
|
|
|
5342
5349
|
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
|
|
5343
5350
|
ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
|
|
5344
5351
|
ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
|
|
5352
|
+
// Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext
|
|
5353
|
+
ModuleKind[ModuleKind["Node12"] = 100] = "Node12";
|
|
5354
|
+
ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext";
|
|
5345
5355
|
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
|
|
5346
5356
|
var JsxEmit;
|
|
5347
5357
|
(function (JsxEmit) {
|
|
@@ -5541,6 +5551,12 @@ var ts;
|
|
|
5541
5551
|
Extension["Jsx"] = ".jsx";
|
|
5542
5552
|
Extension["Json"] = ".json";
|
|
5543
5553
|
Extension["TsBuildInfo"] = ".tsbuildinfo";
|
|
5554
|
+
Extension["Mjs"] = ".mjs";
|
|
5555
|
+
Extension["Mts"] = ".mts";
|
|
5556
|
+
Extension["Dmts"] = ".d.mts";
|
|
5557
|
+
Extension["Cjs"] = ".cjs";
|
|
5558
|
+
Extension["Cts"] = ".cts";
|
|
5559
|
+
Extension["Dcts"] = ".d.cts";
|
|
5544
5560
|
})(Extension = ts.Extension || (ts.Extension = {}));
|
|
5545
5561
|
/* @internal */
|
|
5546
5562
|
var TransformFlags;
|
|
@@ -5687,9 +5703,10 @@ var ts;
|
|
|
5687
5703
|
ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 262144] = "MakeTemplateObject";
|
|
5688
5704
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 524288] = "ClassPrivateFieldGet";
|
|
5689
5705
|
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 1048576] = "ClassPrivateFieldSet";
|
|
5690
|
-
ExternalEmitHelpers[ExternalEmitHelpers["
|
|
5706
|
+
ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldIn"] = 2097152] = "ClassPrivateFieldIn";
|
|
5707
|
+
ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 4194304] = "CreateBinding";
|
|
5691
5708
|
ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper";
|
|
5692
|
-
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] =
|
|
5709
|
+
ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 4194304] = "LastEmitHelper";
|
|
5693
5710
|
// Helpers included by ES2015 for..of
|
|
5694
5711
|
ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes";
|
|
5695
5712
|
// Helpers included by ES2017 for..await..of
|
|
@@ -8248,7 +8265,7 @@ var ts;
|
|
|
8248
8265
|
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."),
|
|
8249
8266
|
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."),
|
|
8250
8267
|
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."),
|
|
8251
|
-
|
|
8268
|
+
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'."),
|
|
8252
8269
|
Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."),
|
|
8253
8270
|
Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."),
|
|
8254
8271
|
Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
|
|
@@ -8266,7 +8283,7 @@ var ts;
|
|
|
8266
8283
|
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."),
|
|
8267
8284
|
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}')'?"),
|
|
8268
8285
|
Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
|
|
8269
|
-
|
|
8286
|
+
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'."),
|
|
8270
8287
|
A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
|
|
8271
8288
|
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."),
|
|
8272
8289
|
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."),
|
|
@@ -8297,7 +8314,7 @@ var ts;
|
|
|
8297
8314
|
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."),
|
|
8298
8315
|
_0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
8299
8316
|
_0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
8300
|
-
|
|
8317
|
+
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."),
|
|
8301
8318
|
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'."),
|
|
8302
8319
|
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'."),
|
|
8303
8320
|
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 `}`?"),
|
|
@@ -8349,7 +8366,7 @@ var ts;
|
|
|
8349
8366
|
File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
8350
8367
|
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:"),
|
|
8351
8368
|
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."),
|
|
8352
|
-
|
|
8369
|
+
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."),
|
|
8353
8370
|
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."),
|
|
8354
8371
|
Unexpected_keyword_or_identifier: diag(1434, ts.DiagnosticCategory.Error, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
8355
8372
|
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}'?"),
|
|
@@ -8366,6 +8383,9 @@ var ts;
|
|
|
8366
8383
|
_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."),
|
|
8367
8384
|
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."),
|
|
8368
8385
|
Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"),
|
|
8386
|
+
Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"),
|
|
8387
|
+
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."),
|
|
8388
|
+
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."),
|
|
8369
8389
|
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."),
|
|
8370
8390
|
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."),
|
|
8371
8391
|
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),
|
|
@@ -8430,7 +8450,7 @@ var ts;
|
|
|
8430
8450
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
|
8431
8451
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
|
8432
8452
|
The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."),
|
|
8433
|
-
|
|
8453
|
+
The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."),
|
|
8434
8454
|
The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
|
|
8435
8455
|
The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
8436
8456
|
The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
@@ -9235,6 +9255,13 @@ var ts;
|
|
|
9235
9255
|
Output_Formatting: diag(6256, ts.DiagnosticCategory.Message, "Output_Formatting_6256", "Output Formatting"),
|
|
9236
9256
|
Completeness: diag(6257, ts.DiagnosticCategory.Message, "Completeness_6257", "Completeness"),
|
|
9237
9257
|
_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"),
|
|
9258
|
+
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."),
|
|
9259
|
+
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}'."),
|
|
9260
|
+
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."),
|
|
9261
|
+
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."),
|
|
9262
|
+
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."),
|
|
9263
|
+
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}'"),
|
|
9264
|
+
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}'."),
|
|
9238
9265
|
Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
|
|
9239
9266
|
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."),
|
|
9240
9267
|
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}'."),
|
|
@@ -9494,6 +9521,8 @@ var ts;
|
|
|
9494
9521
|
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."),
|
|
9495
9522
|
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."),
|
|
9496
9523
|
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}';`"),
|
|
9524
|
+
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."),
|
|
9525
|
+
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."),
|
|
9497
9526
|
You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
|
|
9498
9527
|
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."),
|
|
9499
9528
|
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."),
|
|
@@ -12100,7 +12129,7 @@ var ts;
|
|
|
12100
12129
|
}
|
|
12101
12130
|
ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
|
|
12102
12131
|
function getDefaultLibFileName(options) {
|
|
12103
|
-
switch (options
|
|
12132
|
+
switch (ts.getEmitScriptTarget(options)) {
|
|
12104
12133
|
case 99 /* ESNext */:
|
|
12105
12134
|
return "lib.esnext.full.d.ts";
|
|
12106
12135
|
case 8 /* ES2021 */:
|
|
@@ -13521,6 +13550,7 @@ var ts;
|
|
|
13521
13550
|
case 225 /* ClassExpression */:
|
|
13522
13551
|
case 212 /* FunctionExpression */:
|
|
13523
13552
|
case 79 /* Identifier */:
|
|
13553
|
+
case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression
|
|
13524
13554
|
case 13 /* RegularExpressionLiteral */:
|
|
13525
13555
|
case 8 /* NumericLiteral */:
|
|
13526
13556
|
case 9 /* BigIntLiteral */:
|
|
@@ -14163,22 +14193,22 @@ var ts;
|
|
|
14163
14193
|
return node.end - node.pos;
|
|
14164
14194
|
}
|
|
14165
14195
|
ts.getFullWidth = getFullWidth;
|
|
14166
|
-
function getResolvedModule(sourceFile, moduleNameText) {
|
|
14167
|
-
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
|
|
14196
|
+
function getResolvedModule(sourceFile, moduleNameText, mode) {
|
|
14197
|
+
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode);
|
|
14168
14198
|
}
|
|
14169
14199
|
ts.getResolvedModule = getResolvedModule;
|
|
14170
|
-
function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
|
|
14200
|
+
function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) {
|
|
14171
14201
|
if (!sourceFile.resolvedModules) {
|
|
14172
|
-
sourceFile.resolvedModules =
|
|
14202
|
+
sourceFile.resolvedModules = ts.createModeAwareCache();
|
|
14173
14203
|
}
|
|
14174
|
-
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
|
14204
|
+
sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule);
|
|
14175
14205
|
}
|
|
14176
14206
|
ts.setResolvedModule = setResolvedModule;
|
|
14177
14207
|
function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
|
|
14178
14208
|
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
|
14179
|
-
sourceFile.resolvedTypeReferenceDirectiveNames =
|
|
14209
|
+
sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache();
|
|
14180
14210
|
}
|
|
14181
|
-
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
|
14211
|
+
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective);
|
|
14182
14212
|
}
|
|
14183
14213
|
ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
|
|
14184
14214
|
function projectReferenceIsEqualTo(oldRef, newRef) {
|
|
@@ -14210,11 +14240,11 @@ var ts;
|
|
|
14210
14240
|
&& oldResolution.originalPath === newResolution.originalPath;
|
|
14211
14241
|
}
|
|
14212
14242
|
ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
|
|
14213
|
-
function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
|
|
14243
|
+
function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) {
|
|
14214
14244
|
ts.Debug.assert(names.length === newResolutions.length);
|
|
14215
14245
|
for (var i = 0; i < names.length; i++) {
|
|
14216
14246
|
var newResolution = newResolutions[i];
|
|
14217
|
-
var oldResolution = oldResolutions && oldResolutions.get(names[i]);
|
|
14247
|
+
var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i));
|
|
14218
14248
|
var changed = oldResolution
|
|
14219
14249
|
? !newResolution || !comparer(oldResolution, newResolution)
|
|
14220
14250
|
: newResolution;
|
|
@@ -14749,8 +14779,11 @@ var ts;
|
|
|
14749
14779
|
return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
|
|
14750
14780
|
}
|
|
14751
14781
|
ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
|
|
14782
|
+
function isCommonJSContainingModuleKind(kind) {
|
|
14783
|
+
return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext;
|
|
14784
|
+
}
|
|
14752
14785
|
function isEffectiveExternalModule(node, compilerOptions) {
|
|
14753
|
-
return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions)
|
|
14786
|
+
return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
|
14754
14787
|
}
|
|
14755
14788
|
ts.isEffectiveExternalModule = isEffectiveExternalModule;
|
|
14756
14789
|
/**
|
|
@@ -15868,6 +15901,8 @@ var ts;
|
|
|
15868
15901
|
node = node.parent;
|
|
15869
15902
|
}
|
|
15870
15903
|
return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node);
|
|
15904
|
+
case 80 /* PrivateIdentifier */:
|
|
15905
|
+
return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */;
|
|
15871
15906
|
case 79 /* Identifier */:
|
|
15872
15907
|
if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) {
|
|
15873
15908
|
return true;
|
|
@@ -17534,6 +17569,7 @@ var ts;
|
|
|
17534
17569
|
case 108 /* ThisKeyword */:
|
|
17535
17570
|
case 106 /* SuperKeyword */:
|
|
17536
17571
|
case 79 /* Identifier */:
|
|
17572
|
+
case 80 /* PrivateIdentifier */:
|
|
17537
17573
|
case 104 /* NullKeyword */:
|
|
17538
17574
|
case 110 /* TrueKeyword */:
|
|
17539
17575
|
case 95 /* FalseKeyword */:
|
|
@@ -18040,9 +18076,17 @@ var ts;
|
|
|
18040
18076
|
var path = outputDir
|
|
18041
18077
|
? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
|
|
18042
18078
|
: fileName;
|
|
18043
|
-
|
|
18079
|
+
var declarationExtension = getDeclarationEmitExtensionForPath(path);
|
|
18080
|
+
return removeFileExtension(path) + declarationExtension;
|
|
18044
18081
|
}
|
|
18045
18082
|
ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
|
|
18083
|
+
function getDeclarationEmitExtensionForPath(path) {
|
|
18084
|
+
return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ :
|
|
18085
|
+
ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ :
|
|
18086
|
+
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
|
|
18087
|
+
".d.ts" /* Dts */;
|
|
18088
|
+
}
|
|
18089
|
+
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
18046
18090
|
function outFile(options) {
|
|
18047
18091
|
return options.outFile || options.out;
|
|
18048
18092
|
}
|
|
@@ -18782,7 +18826,7 @@ var ts;
|
|
|
18782
18826
|
}
|
|
18783
18827
|
/** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */
|
|
18784
18828
|
function tryExtractTSExtension(fileName) {
|
|
18785
|
-
return ts.find(
|
|
18829
|
+
return ts.find(supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
18786
18830
|
}
|
|
18787
18831
|
ts.tryExtractTSExtension = tryExtractTSExtension;
|
|
18788
18832
|
/**
|
|
@@ -19734,7 +19778,10 @@ var ts;
|
|
|
19734
19778
|
}
|
|
19735
19779
|
ts.getLanguageVariant = getLanguageVariant;
|
|
19736
19780
|
function getEmitScriptTarget(compilerOptions) {
|
|
19737
|
-
return compilerOptions.target ||
|
|
19781
|
+
return compilerOptions.target ||
|
|
19782
|
+
(compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
|
|
19783
|
+
(compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) ||
|
|
19784
|
+
0 /* ES3 */;
|
|
19738
19785
|
}
|
|
19739
19786
|
ts.getEmitScriptTarget = getEmitScriptTarget;
|
|
19740
19787
|
function getEmitModuleKind(compilerOptions) {
|
|
@@ -19746,7 +19793,20 @@ var ts;
|
|
|
19746
19793
|
function getEmitModuleResolutionKind(compilerOptions) {
|
|
19747
19794
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
19748
19795
|
if (moduleResolution === undefined) {
|
|
19749
|
-
|
|
19796
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19797
|
+
case ts.ModuleKind.CommonJS:
|
|
19798
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
19799
|
+
break;
|
|
19800
|
+
case ts.ModuleKind.Node12:
|
|
19801
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
19802
|
+
break;
|
|
19803
|
+
case ts.ModuleKind.NodeNext:
|
|
19804
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
19805
|
+
break;
|
|
19806
|
+
default:
|
|
19807
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
19808
|
+
break;
|
|
19809
|
+
}
|
|
19750
19810
|
}
|
|
19751
19811
|
return moduleResolution;
|
|
19752
19812
|
}
|
|
@@ -19776,11 +19836,23 @@ var ts;
|
|
|
19776
19836
|
return !!(getEmitDeclarations(options) && options.declarationMap);
|
|
19777
19837
|
}
|
|
19778
19838
|
ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
|
|
19839
|
+
function getESModuleInterop(compilerOptions) {
|
|
19840
|
+
if (compilerOptions.esModuleInterop !== undefined) {
|
|
19841
|
+
return compilerOptions.esModuleInterop;
|
|
19842
|
+
}
|
|
19843
|
+
switch (getEmitModuleKind(compilerOptions)) {
|
|
19844
|
+
case ts.ModuleKind.Node12:
|
|
19845
|
+
case ts.ModuleKind.NodeNext:
|
|
19846
|
+
return true;
|
|
19847
|
+
}
|
|
19848
|
+
return undefined;
|
|
19849
|
+
}
|
|
19850
|
+
ts.getESModuleInterop = getESModuleInterop;
|
|
19779
19851
|
function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
19780
19852
|
var moduleKind = getEmitModuleKind(compilerOptions);
|
|
19781
19853
|
return compilerOptions.allowSyntheticDefaultImports !== undefined
|
|
19782
19854
|
? compilerOptions.allowSyntheticDefaultImports
|
|
19783
|
-
: compilerOptions
|
|
19855
|
+
: getESModuleInterop(compilerOptions) ||
|
|
19784
19856
|
moduleKind === ts.ModuleKind.System;
|
|
19785
19857
|
}
|
|
19786
19858
|
ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
|
|
@@ -19805,7 +19877,7 @@ var ts;
|
|
|
19805
19877
|
}
|
|
19806
19878
|
ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
|
|
19807
19879
|
function getUseDefineForClassFields(compilerOptions) {
|
|
19808
|
-
return compilerOptions.useDefineForClassFields === undefined ? compilerOptions
|
|
19880
|
+
return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ : compilerOptions.useDefineForClassFields;
|
|
19809
19881
|
}
|
|
19810
19882
|
ts.getUseDefineForClassFields = getUseDefineForClassFields;
|
|
19811
19883
|
function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
|
|
@@ -20245,51 +20317,54 @@ var ts;
|
|
|
20245
20317
|
}
|
|
20246
20318
|
ts.getScriptKindFromFileName = getScriptKindFromFileName;
|
|
20247
20319
|
/**
|
|
20248
|
-
*
|
|
20320
|
+
* Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS)
|
|
20249
20321
|
*/
|
|
20250
|
-
ts.supportedTSExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */];
|
|
20251
|
-
ts.
|
|
20322
|
+
ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]];
|
|
20323
|
+
ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions);
|
|
20324
|
+
var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false);
|
|
20252
20325
|
/** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */
|
|
20253
|
-
|
|
20254
|
-
ts.supportedJSExtensions = [".js" /* Js */, ".jsx" /* Jsx */];
|
|
20255
|
-
ts.
|
|
20256
|
-
var allSupportedExtensions =
|
|
20257
|
-
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(
|
|
20326
|
+
var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */];
|
|
20327
|
+
ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]];
|
|
20328
|
+
ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions);
|
|
20329
|
+
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 */]];
|
|
20330
|
+
var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false);
|
|
20258
20331
|
function getSupportedExtensions(options, extraFileExtensions) {
|
|
20259
20332
|
var needJsExtensions = options && getAllowJSCompilerOption(options);
|
|
20260
20333
|
if (!extraFileExtensions || extraFileExtensions.length === 0) {
|
|
20261
20334
|
return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20262
20335
|
}
|
|
20263
|
-
var
|
|
20264
|
-
|
|
20336
|
+
var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
|
|
20337
|
+
var flatBuiltins = ts.flatten(builtins);
|
|
20338
|
+
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);
|
|
20339
|
+
return extensions;
|
|
20265
20340
|
}
|
|
20266
20341
|
ts.getSupportedExtensions = getSupportedExtensions;
|
|
20267
|
-
function
|
|
20342
|
+
function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
|
|
20268
20343
|
if (!options || !options.resolveJsonModule)
|
|
20269
20344
|
return supportedExtensions;
|
|
20270
20345
|
if (supportedExtensions === allSupportedExtensions)
|
|
20271
20346
|
return allSupportedExtensionsWithJson;
|
|
20272
20347
|
if (supportedExtensions === ts.supportedTSExtensions)
|
|
20273
|
-
return
|
|
20274
|
-
return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false);
|
|
20348
|
+
return supportedTSExtensionsWithJson;
|
|
20349
|
+
return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false);
|
|
20275
20350
|
}
|
|
20276
|
-
ts.
|
|
20351
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule;
|
|
20277
20352
|
function isJSLike(scriptKind) {
|
|
20278
20353
|
return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */;
|
|
20279
20354
|
}
|
|
20280
20355
|
function hasJSFileExtension(fileName) {
|
|
20281
|
-
return ts.some(ts.
|
|
20356
|
+
return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20282
20357
|
}
|
|
20283
20358
|
ts.hasJSFileExtension = hasJSFileExtension;
|
|
20284
20359
|
function hasTSFileExtension(fileName) {
|
|
20285
|
-
return ts.some(ts.
|
|
20360
|
+
return ts.some(ts.supportedTSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); });
|
|
20286
20361
|
}
|
|
20287
20362
|
ts.hasTSFileExtension = hasTSFileExtension;
|
|
20288
20363
|
function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
|
|
20289
20364
|
if (!fileName)
|
|
20290
20365
|
return false;
|
|
20291
20366
|
var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
|
|
20292
|
-
for (var _i = 0, _a =
|
|
20367
|
+
for (var _i = 0, _a = ts.flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)); _i < _a.length; _i++) {
|
|
20293
20368
|
var extension = _a[_i];
|
|
20294
20369
|
if (ts.fileExtensionIs(fileName, extension)) {
|
|
20295
20370
|
return true;
|
|
@@ -20306,57 +20381,7 @@ var ts;
|
|
|
20306
20381
|
return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
|
|
20307
20382
|
}
|
|
20308
20383
|
ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
|
|
20309
|
-
|
|
20310
|
-
* Extension boundaries by priority. Lower numbers indicate higher priorities, and are
|
|
20311
|
-
* aligned to the offset of the highest priority extension in the
|
|
20312
|
-
* allSupportedExtensions array.
|
|
20313
|
-
*/
|
|
20314
|
-
var ExtensionPriority;
|
|
20315
|
-
(function (ExtensionPriority) {
|
|
20316
|
-
ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles";
|
|
20317
|
-
ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles";
|
|
20318
|
-
ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest";
|
|
20319
|
-
ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest";
|
|
20320
|
-
})(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {}));
|
|
20321
|
-
function getExtensionPriority(path, supportedExtensions) {
|
|
20322
|
-
for (var i = supportedExtensions.length - 1; i >= 0; i--) {
|
|
20323
|
-
if (ts.fileExtensionIs(path, supportedExtensions[i])) {
|
|
20324
|
-
return adjustExtensionPriority(i, supportedExtensions);
|
|
20325
|
-
}
|
|
20326
|
-
}
|
|
20327
|
-
// If its not in the list of supported extensions, this is likely a
|
|
20328
|
-
// TypeScript file with a non-ts extension
|
|
20329
|
-
return 0 /* Highest */;
|
|
20330
|
-
}
|
|
20331
|
-
ts.getExtensionPriority = getExtensionPriority;
|
|
20332
|
-
/**
|
|
20333
|
-
* Adjusts an extension priority to be the highest priority within the same range.
|
|
20334
|
-
*/
|
|
20335
|
-
function adjustExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20336
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20337
|
-
return 0 /* TypeScriptFiles */;
|
|
20338
|
-
}
|
|
20339
|
-
else if (extensionPriority < supportedExtensions.length) {
|
|
20340
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20341
|
-
}
|
|
20342
|
-
else {
|
|
20343
|
-
return supportedExtensions.length;
|
|
20344
|
-
}
|
|
20345
|
-
}
|
|
20346
|
-
ts.adjustExtensionPriority = adjustExtensionPriority;
|
|
20347
|
-
/**
|
|
20348
|
-
* Gets the next lowest extension priority for a given priority.
|
|
20349
|
-
*/
|
|
20350
|
-
function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
|
|
20351
|
-
if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) {
|
|
20352
|
-
return 2 /* DeclarationAndJavaScriptFiles */;
|
|
20353
|
-
}
|
|
20354
|
-
else {
|
|
20355
|
-
return supportedExtensions.length;
|
|
20356
|
-
}
|
|
20357
|
-
}
|
|
20358
|
-
ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
|
|
20359
|
-
var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
20384
|
+
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 */];
|
|
20360
20385
|
function removeFileExtension(path) {
|
|
20361
20386
|
for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
|
|
20362
20387
|
var ext = extensionsToRemove_1[_i];
|
|
@@ -20409,7 +20434,7 @@ var ts;
|
|
|
20409
20434
|
ts.positionIsSynthesized = positionIsSynthesized;
|
|
20410
20435
|
/** True if an extension is one of the supported TypeScript extensions. */
|
|
20411
20436
|
function extensionIsTS(ext) {
|
|
20412
|
-
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */;
|
|
20437
|
+
return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */;
|
|
20413
20438
|
}
|
|
20414
20439
|
ts.extensionIsTS = extensionIsTS;
|
|
20415
20440
|
function resolutionExtensionIsTSOrJson(ext) {
|
|
@@ -25570,6 +25595,7 @@ var ts;
|
|
|
25570
25595
|
node.transformFlags =
|
|
25571
25596
|
propagateChildrenFlags(node.statements) |
|
|
25572
25597
|
propagateChildFlags(node.endOfFileToken);
|
|
25598
|
+
node.impliedNodeFormat = source.impliedNodeFormat;
|
|
25573
25599
|
return node;
|
|
25574
25600
|
}
|
|
25575
25601
|
// @api
|
|
@@ -27143,6 +27169,7 @@ var ts;
|
|
|
27143
27169
|
// Class Fields Helpers
|
|
27144
27170
|
createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
|
|
27145
27171
|
createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
|
|
27172
|
+
createClassPrivateFieldInHelper: createClassPrivateFieldInHelper
|
|
27146
27173
|
};
|
|
27147
27174
|
/**
|
|
27148
27175
|
* Gets an identifier for the name of an *unscoped* emit helper.
|
|
@@ -27183,7 +27210,7 @@ var ts;
|
|
|
27183
27210
|
}
|
|
27184
27211
|
// ES2018 Helpers
|
|
27185
27212
|
function createAssignHelper(attributesSegments) {
|
|
27186
|
-
if (context.getCompilerOptions()
|
|
27213
|
+
if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) {
|
|
27187
27214
|
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"),
|
|
27188
27215
|
/*typeArguments*/ undefined, attributesSegments);
|
|
27189
27216
|
}
|
|
@@ -27353,6 +27380,10 @@ var ts;
|
|
|
27353
27380
|
}
|
|
27354
27381
|
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args);
|
|
27355
27382
|
}
|
|
27383
|
+
function createClassPrivateFieldInHelper(state, receiver) {
|
|
27384
|
+
context.requestEmitHelper(ts.classPrivateFieldInHelper);
|
|
27385
|
+
return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]);
|
|
27386
|
+
}
|
|
27356
27387
|
}
|
|
27357
27388
|
ts.createEmitHelperFactory = createEmitHelperFactory;
|
|
27358
27389
|
/* @internal */
|
|
@@ -27710,6 +27741,24 @@ var ts;
|
|
|
27710
27741
|
scoped: false,
|
|
27711
27742
|
text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };"
|
|
27712
27743
|
};
|
|
27744
|
+
/**
|
|
27745
|
+
* Parameters:
|
|
27746
|
+
* @param state — One of the following:
|
|
27747
|
+
* - A WeakMap when the member is a private instance field.
|
|
27748
|
+
* - A WeakSet when the member is a private instance method or accessor.
|
|
27749
|
+
* - A function value that should be the undecorated class constructor when the member is a private static field, method, or accessor.
|
|
27750
|
+
* @param receiver — The object being checked if it has the private member.
|
|
27751
|
+
*
|
|
27752
|
+
* Usage:
|
|
27753
|
+
* This helper is used to transform `#field in expression` to
|
|
27754
|
+
* `__classPrivateFieldIn(<weakMap/weakSet/constructor>, expression)`
|
|
27755
|
+
*/
|
|
27756
|
+
ts.classPrivateFieldInHelper = {
|
|
27757
|
+
name: "typescript:classPrivateFieldIn",
|
|
27758
|
+
importName: "__classPrivateFieldIn",
|
|
27759
|
+
scoped: false,
|
|
27760
|
+
text: "\n var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n };"
|
|
27761
|
+
};
|
|
27713
27762
|
var allUnscopedEmitHelpers;
|
|
27714
27763
|
function getAllUnscopedEmitHelpers() {
|
|
27715
27764
|
return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
|
|
@@ -27734,6 +27783,7 @@ var ts;
|
|
|
27734
27783
|
ts.exportStarHelper,
|
|
27735
27784
|
ts.classPrivateFieldGetHelper,
|
|
27736
27785
|
ts.classPrivateFieldSetHelper,
|
|
27786
|
+
ts.classPrivateFieldInHelper,
|
|
27737
27787
|
ts.createBindingHelper,
|
|
27738
27788
|
ts.setModuleDefaultHelper
|
|
27739
27789
|
], function (helper) { return helper.name; }));
|
|
@@ -29053,7 +29103,7 @@ var ts;
|
|
|
29053
29103
|
if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
29054
29104
|
var namedBindings = void 0;
|
|
29055
29105
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
29056
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
|
|
29106
|
+
if ((moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
29057
29107
|
// use named imports
|
|
29058
29108
|
var helpers = ts.getEmitHelpers(sourceFile);
|
|
29059
29109
|
if (helpers) {
|
|
@@ -29105,9 +29155,9 @@ var ts;
|
|
|
29105
29155
|
return externalHelpersModuleName;
|
|
29106
29156
|
}
|
|
29107
29157
|
var moduleKind = ts.getEmitModuleKind(compilerOptions);
|
|
29108
|
-
var create = (hasExportStarsToExportValues || (compilerOptions
|
|
29158
|
+
var create = (hasExportStarsToExportValues || (ts.getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault))
|
|
29109
29159
|
&& moduleKind !== ts.ModuleKind.System
|
|
29110
|
-
&& moduleKind < ts.ModuleKind.ES2015;
|
|
29160
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || node.impliedNodeFormat === ts.ModuleKind.CommonJS);
|
|
29111
29161
|
if (!create) {
|
|
29112
29162
|
var helpers = ts.getEmitHelpers(node);
|
|
29113
29163
|
if (helpers) {
|
|
@@ -34659,6 +34709,8 @@ var ts;
|
|
|
34659
34709
|
break;
|
|
34660
34710
|
case 15 /* TemplateHead */:
|
|
34661
34711
|
return parseTemplateExpression(/* isTaggedTemplate */ false);
|
|
34712
|
+
case 80 /* PrivateIdentifier */:
|
|
34713
|
+
return parsePrivateIdentifier();
|
|
34662
34714
|
}
|
|
34663
34715
|
return parseIdentifier(ts.Diagnostics.Expression_expected);
|
|
34664
34716
|
}
|
|
@@ -37360,6 +37412,7 @@ var ts;
|
|
|
37360
37412
|
// are already correct.
|
|
37361
37413
|
var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
|
|
37362
37414
|
result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
|
|
37415
|
+
result.impliedNodeFormat = sourceFile.impliedNodeFormat;
|
|
37363
37416
|
return result;
|
|
37364
37417
|
}
|
|
37365
37418
|
IncrementalParser.updateSourceFile = updateSourceFile;
|
|
@@ -37809,7 +37862,7 @@ var ts;
|
|
|
37809
37862
|
})(IncrementalParser || (IncrementalParser = {}));
|
|
37810
37863
|
/** @internal */
|
|
37811
37864
|
function isDeclarationFileName(fileName) {
|
|
37812
|
-
return ts.
|
|
37865
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]);
|
|
37813
37866
|
}
|
|
37814
37867
|
ts.isDeclarationFileName = isDeclarationFileName;
|
|
37815
37868
|
/*@internal*/
|
|
@@ -38422,7 +38475,9 @@ var ts;
|
|
|
38422
38475
|
es6: ts.ModuleKind.ES2015,
|
|
38423
38476
|
es2015: ts.ModuleKind.ES2015,
|
|
38424
38477
|
es2020: ts.ModuleKind.ES2020,
|
|
38425
|
-
esnext: ts.ModuleKind.ESNext
|
|
38478
|
+
esnext: ts.ModuleKind.ESNext,
|
|
38479
|
+
node12: ts.ModuleKind.Node12,
|
|
38480
|
+
nodenext: ts.ModuleKind.NodeNext,
|
|
38426
38481
|
})),
|
|
38427
38482
|
affectsModuleResolution: true,
|
|
38428
38483
|
affectsEmit: true,
|
|
@@ -39327,7 +39382,7 @@ var ts;
|
|
|
39327
39382
|
/* @internal */
|
|
39328
39383
|
ts.defaultInitCompilerOptions = {
|
|
39329
39384
|
module: ts.ModuleKind.CommonJS,
|
|
39330
|
-
target:
|
|
39385
|
+
target: 3 /* ES2016 */,
|
|
39331
39386
|
strict: true,
|
|
39332
39387
|
esModuleInterop: true,
|
|
39333
39388
|
forceConsistentCasingInFileNames: true,
|
|
@@ -40848,7 +40903,7 @@ var ts;
|
|
|
40848
40903
|
// Rather than re-query this for each file and filespec, we query the supported extensions
|
|
40849
40904
|
// once and store it on the expansion context.
|
|
40850
40905
|
var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
|
|
40851
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
40906
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
40852
40907
|
// Literal files are always included verbatim. An "include" or "exclude" specification cannot
|
|
40853
40908
|
// remove a literal file.
|
|
40854
40909
|
if (validatedFilesSpec) {
|
|
@@ -40896,7 +40951,7 @@ var ts;
|
|
|
40896
40951
|
wildcardFileMap.set(key, file);
|
|
40897
40952
|
}
|
|
40898
40953
|
};
|
|
40899
|
-
for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40954
|
+
for (var _a = 0, _b = host.readDirectory(basePath, ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) {
|
|
40900
40955
|
var file = _b[_a];
|
|
40901
40956
|
_loop_6(file);
|
|
40902
40957
|
}
|
|
@@ -41059,16 +41114,25 @@ var ts;
|
|
|
41059
41114
|
* extension priority.
|
|
41060
41115
|
*
|
|
41061
41116
|
* @param file The path to the file.
|
|
41062
|
-
* @param extensionPriority The priority of the extension.
|
|
41063
|
-
* @param context The expansion context.
|
|
41064
41117
|
*/
|
|
41065
41118
|
function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
|
|
41066
|
-
var
|
|
41067
|
-
|
|
41068
|
-
|
|
41069
|
-
|
|
41070
|
-
|
|
41119
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
41120
|
+
if (!extensionGroup) {
|
|
41121
|
+
return false;
|
|
41122
|
+
}
|
|
41123
|
+
for (var _i = 0, extensionGroup_1 = extensionGroup; _i < extensionGroup_1.length; _i++) {
|
|
41124
|
+
var ext = extensionGroup_1[_i];
|
|
41125
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
41126
|
+
return false;
|
|
41127
|
+
}
|
|
41128
|
+
var higherPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
41071
41129
|
if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
|
|
41130
|
+
if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) {
|
|
41131
|
+
// LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration
|
|
41132
|
+
// files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to
|
|
41133
|
+
// prevent breakage.
|
|
41134
|
+
continue;
|
|
41135
|
+
}
|
|
41072
41136
|
return true;
|
|
41073
41137
|
}
|
|
41074
41138
|
}
|
|
@@ -41079,15 +41143,18 @@ var ts;
|
|
|
41079
41143
|
* already been included.
|
|
41080
41144
|
*
|
|
41081
41145
|
* @param file The path to the file.
|
|
41082
|
-
* @param extensionPriority The priority of the extension.
|
|
41083
|
-
* @param context The expansion context.
|
|
41084
41146
|
*/
|
|
41085
41147
|
function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
|
|
41086
|
-
var
|
|
41087
|
-
|
|
41088
|
-
|
|
41089
|
-
|
|
41090
|
-
|
|
41148
|
+
var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; });
|
|
41149
|
+
if (!extensionGroup) {
|
|
41150
|
+
return;
|
|
41151
|
+
}
|
|
41152
|
+
for (var i = extensionGroup.length - 1; i >= 0; i--) {
|
|
41153
|
+
var ext = extensionGroup[i];
|
|
41154
|
+
if (ts.fileExtensionIs(file, ext)) {
|
|
41155
|
+
return;
|
|
41156
|
+
}
|
|
41157
|
+
var lowerPriorityPath = keyMapper(ts.changeExtension(file, ext));
|
|
41091
41158
|
wildcardFiles.delete(lowerPriorityPath);
|
|
41092
41159
|
}
|
|
41093
41160
|
}
|
|
@@ -41347,7 +41414,7 @@ var ts;
|
|
|
41347
41414
|
}
|
|
41348
41415
|
var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined;
|
|
41349
41416
|
var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined;
|
|
41350
|
-
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName);
|
|
41417
|
+
var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined);
|
|
41351
41418
|
if (result) {
|
|
41352
41419
|
if (traceEnabled) {
|
|
41353
41420
|
trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile);
|
|
@@ -41381,7 +41448,7 @@ var ts;
|
|
|
41381
41448
|
}
|
|
41382
41449
|
}
|
|
41383
41450
|
var failedLookupLocations = [];
|
|
41384
|
-
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
41451
|
+
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] };
|
|
41385
41452
|
var resolved = primaryLookup();
|
|
41386
41453
|
var primary = true;
|
|
41387
41454
|
if (!resolved) {
|
|
@@ -41401,7 +41468,7 @@ var ts;
|
|
|
41401
41468
|
};
|
|
41402
41469
|
}
|
|
41403
41470
|
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
41404
|
-
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result);
|
|
41471
|
+
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result);
|
|
41405
41472
|
if (traceEnabled)
|
|
41406
41473
|
traceResult(result);
|
|
41407
41474
|
return result;
|
|
@@ -41614,9 +41681,56 @@ var ts;
|
|
|
41614
41681
|
}
|
|
41615
41682
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
41616
41683
|
var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
41617
|
-
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return
|
|
41684
|
+
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); });
|
|
41618
41685
|
}
|
|
41619
41686
|
}
|
|
41687
|
+
/* @internal */
|
|
41688
|
+
function createModeAwareCache() {
|
|
41689
|
+
var underlying = new ts.Map();
|
|
41690
|
+
var memoizedReverseKeys = new ts.Map();
|
|
41691
|
+
var cache = {
|
|
41692
|
+
get: function (specifier, mode) {
|
|
41693
|
+
return underlying.get(getUnderlyingCacheKey(specifier, mode));
|
|
41694
|
+
},
|
|
41695
|
+
set: function (specifier, mode, value) {
|
|
41696
|
+
underlying.set(getUnderlyingCacheKey(specifier, mode), value);
|
|
41697
|
+
return cache;
|
|
41698
|
+
},
|
|
41699
|
+
delete: function (specifier, mode) {
|
|
41700
|
+
underlying.delete(getUnderlyingCacheKey(specifier, mode));
|
|
41701
|
+
return cache;
|
|
41702
|
+
},
|
|
41703
|
+
has: function (specifier, mode) {
|
|
41704
|
+
return underlying.has(getUnderlyingCacheKey(specifier, mode));
|
|
41705
|
+
},
|
|
41706
|
+
forEach: function (cb) {
|
|
41707
|
+
return underlying.forEach(function (elem, key) {
|
|
41708
|
+
var _a = memoizedReverseKeys.get(key), specifier = _a[0], mode = _a[1];
|
|
41709
|
+
return cb(elem, specifier, mode);
|
|
41710
|
+
});
|
|
41711
|
+
},
|
|
41712
|
+
size: function () {
|
|
41713
|
+
return underlying.size;
|
|
41714
|
+
}
|
|
41715
|
+
};
|
|
41716
|
+
return cache;
|
|
41717
|
+
function getUnderlyingCacheKey(specifier, mode) {
|
|
41718
|
+
var result = mode === undefined ? specifier : mode + "|" + specifier;
|
|
41719
|
+
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
41720
|
+
return result;
|
|
41721
|
+
}
|
|
41722
|
+
}
|
|
41723
|
+
ts.createModeAwareCache = createModeAwareCache;
|
|
41724
|
+
/* @internal */
|
|
41725
|
+
function zipToModeAwareCache(file, keys, values) {
|
|
41726
|
+
ts.Debug.assert(keys.length === values.length);
|
|
41727
|
+
var map = createModeAwareCache();
|
|
41728
|
+
for (var i = 0; i < keys.length; ++i) {
|
|
41729
|
+
map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]);
|
|
41730
|
+
}
|
|
41731
|
+
return map;
|
|
41732
|
+
}
|
|
41733
|
+
ts.zipToModeAwareCache = zipToModeAwareCache;
|
|
41620
41734
|
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
41621
41735
|
var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options)));
|
|
41622
41736
|
moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options));
|
|
@@ -41630,9 +41744,9 @@ var ts;
|
|
|
41630
41744
|
function update(options) {
|
|
41631
41745
|
updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap);
|
|
41632
41746
|
}
|
|
41633
|
-
function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
|
|
41747
|
+
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
41634
41748
|
ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
|
|
41635
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
|
|
41749
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache);
|
|
41636
41750
|
}
|
|
41637
41751
|
function createPerModuleNameCache() {
|
|
41638
41752
|
var directoryPathMap = new ts.Map();
|
|
@@ -41711,13 +41825,15 @@ var ts;
|
|
|
41711
41825
|
}
|
|
41712
41826
|
}
|
|
41713
41827
|
ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache;
|
|
41714
|
-
function resolveModuleNameFromCache(moduleName, containingFile, cache) {
|
|
41828
|
+
function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) {
|
|
41715
41829
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41716
41830
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
|
|
41717
|
-
|
|
41831
|
+
if (!perFolderCache)
|
|
41832
|
+
return undefined;
|
|
41833
|
+
return perFolderCache.get(moduleName, mode);
|
|
41718
41834
|
}
|
|
41719
41835
|
ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
|
|
41720
|
-
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
41836
|
+
function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
41721
41837
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41722
41838
|
if (redirectedReference) {
|
|
41723
41839
|
compilerOptions = redirectedReference.commandLine.options;
|
|
@@ -41730,7 +41846,7 @@ var ts;
|
|
|
41730
41846
|
}
|
|
41731
41847
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
41732
41848
|
var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
|
|
41733
|
-
var result = perFolderCache && perFolderCache.get(moduleName);
|
|
41849
|
+
var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode);
|
|
41734
41850
|
if (result) {
|
|
41735
41851
|
if (traceEnabled) {
|
|
41736
41852
|
trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
|
|
@@ -41739,7 +41855,20 @@ var ts;
|
|
|
41739
41855
|
else {
|
|
41740
41856
|
var moduleResolution = compilerOptions.moduleResolution;
|
|
41741
41857
|
if (moduleResolution === undefined) {
|
|
41742
|
-
|
|
41858
|
+
switch (ts.getEmitModuleKind(compilerOptions)) {
|
|
41859
|
+
case ts.ModuleKind.CommonJS:
|
|
41860
|
+
moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
41861
|
+
break;
|
|
41862
|
+
case ts.ModuleKind.Node12:
|
|
41863
|
+
moduleResolution = ts.ModuleResolutionKind.Node12;
|
|
41864
|
+
break;
|
|
41865
|
+
case ts.ModuleKind.NodeNext:
|
|
41866
|
+
moduleResolution = ts.ModuleResolutionKind.NodeNext;
|
|
41867
|
+
break;
|
|
41868
|
+
default:
|
|
41869
|
+
moduleResolution = ts.ModuleResolutionKind.Classic;
|
|
41870
|
+
break;
|
|
41871
|
+
}
|
|
41743
41872
|
if (traceEnabled) {
|
|
41744
41873
|
trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
|
|
41745
41874
|
}
|
|
@@ -41751,6 +41880,12 @@ var ts;
|
|
|
41751
41880
|
}
|
|
41752
41881
|
ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/);
|
|
41753
41882
|
switch (moduleResolution) {
|
|
41883
|
+
case ts.ModuleResolutionKind.Node12:
|
|
41884
|
+
result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41885
|
+
break;
|
|
41886
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
41887
|
+
result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
41888
|
+
break;
|
|
41754
41889
|
case ts.ModuleResolutionKind.NodeJs:
|
|
41755
41890
|
result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
|
|
41756
41891
|
break;
|
|
@@ -41764,10 +41899,10 @@ var ts;
|
|
|
41764
41899
|
ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
|
|
41765
41900
|
ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
|
|
41766
41901
|
if (perFolderCache) {
|
|
41767
|
-
perFolderCache.set(moduleName, result);
|
|
41902
|
+
perFolderCache.set(moduleName, resolutionMode, result);
|
|
41768
41903
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
41769
41904
|
// put result in per-module name cache
|
|
41770
|
-
cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
|
|
41905
|
+
cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
|
|
41771
41906
|
}
|
|
41772
41907
|
}
|
|
41773
41908
|
}
|
|
@@ -41974,22 +42109,60 @@ var ts;
|
|
|
41974
42109
|
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
41975
42110
|
}
|
|
41976
42111
|
ts.tryResolveJSModule = tryResolveJSModule;
|
|
42112
|
+
/* @internal */
|
|
42113
|
+
var NodeResolutionFeatures;
|
|
42114
|
+
(function (NodeResolutionFeatures) {
|
|
42115
|
+
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
42116
|
+
// resolving `#local` names in your own package.json
|
|
42117
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Imports"] = 2] = "Imports";
|
|
42118
|
+
// resolving `your-own-name` from your own package.json
|
|
42119
|
+
NodeResolutionFeatures[NodeResolutionFeatures["SelfName"] = 4] = "SelfName";
|
|
42120
|
+
// respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names
|
|
42121
|
+
NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports";
|
|
42122
|
+
// allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"`
|
|
42123
|
+
// not currently backported to node 12 - https://github.com/nodejs/Release/issues/690
|
|
42124
|
+
NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers";
|
|
42125
|
+
NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures";
|
|
42126
|
+
NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode";
|
|
42127
|
+
})(NodeResolutionFeatures || (NodeResolutionFeatures = {}));
|
|
42128
|
+
function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42129
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42130
|
+
}
|
|
42131
|
+
function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42132
|
+
return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode);
|
|
42133
|
+
}
|
|
42134
|
+
function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) {
|
|
42135
|
+
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
42136
|
+
// es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features
|
|
42137
|
+
var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0;
|
|
42138
|
+
return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference);
|
|
42139
|
+
}
|
|
41977
42140
|
var jsOnlyExtensions = [Extensions.JavaScript];
|
|
41978
42141
|
var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
|
|
41979
42142
|
var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions, true), [Extensions.Json], false);
|
|
41980
42143
|
var tsconfigExtensions = [Extensions.TSConfig];
|
|
41981
42144
|
function tryResolveJSModuleWorker(moduleName, initialDir, host) {
|
|
41982
|
-
return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
42145
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined);
|
|
41983
42146
|
}
|
|
41984
42147
|
function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
|
|
41985
|
-
return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
42148
|
+
return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
|
|
41986
42149
|
}
|
|
41987
42150
|
ts.nodeModuleNameResolver = nodeModuleNameResolver;
|
|
41988
|
-
function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
42151
|
+
function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
|
|
41989
42152
|
var _a, _b;
|
|
41990
42153
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
41991
42154
|
var failedLookupLocations = [];
|
|
41992
|
-
|
|
42155
|
+
// conditions are only used by the node12/nodenext resolver - there's no priority order in the list,
|
|
42156
|
+
//it's essentially a set (priority is determined by object insertion order in the object we look at).
|
|
42157
|
+
var state = {
|
|
42158
|
+
compilerOptions: compilerOptions,
|
|
42159
|
+
host: host,
|
|
42160
|
+
traceEnabled: traceEnabled,
|
|
42161
|
+
failedLookupLocations: failedLookupLocations,
|
|
42162
|
+
packageJsonInfoCache: cache,
|
|
42163
|
+
features: features,
|
|
42164
|
+
conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]
|
|
42165
|
+
};
|
|
41993
42166
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
41994
42167
|
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);
|
|
41995
42168
|
function tryResolve(extensions) {
|
|
@@ -41999,10 +42172,19 @@ var ts;
|
|
|
41999
42172
|
return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
42000
42173
|
}
|
|
42001
42174
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
42002
|
-
|
|
42003
|
-
|
|
42175
|
+
var resolved_1;
|
|
42176
|
+
if (features & NodeResolutionFeatures.Imports && ts.startsWith(moduleName, "#")) {
|
|
42177
|
+
resolved_1 = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42178
|
+
}
|
|
42179
|
+
if (!resolved_1 && features & NodeResolutionFeatures.SelfName) {
|
|
42180
|
+
resolved_1 = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42181
|
+
}
|
|
42182
|
+
if (!resolved_1) {
|
|
42183
|
+
if (traceEnabled) {
|
|
42184
|
+
trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
|
|
42185
|
+
}
|
|
42186
|
+
resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42004
42187
|
}
|
|
42005
|
-
var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
|
|
42006
42188
|
if (!resolved_1)
|
|
42007
42189
|
return undefined;
|
|
42008
42190
|
var resolvedValue = resolved_1.value;
|
|
@@ -42111,26 +42293,40 @@ var ts;
|
|
|
42111
42293
|
function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
|
|
42112
42294
|
if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
|
|
42113
42295
|
var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */);
|
|
42114
|
-
|
|
42296
|
+
var extension = extensionLess ? candidate.substring(extensionLess.length) : "";
|
|
42297
|
+
return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state);
|
|
42115
42298
|
}
|
|
42116
|
-
//
|
|
42117
|
-
|
|
42118
|
-
|
|
42119
|
-
|
|
42299
|
+
// esm mode resolutions don't include automatic extension lookup (without additional flags, at least)
|
|
42300
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42301
|
+
// First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts"
|
|
42302
|
+
var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state);
|
|
42303
|
+
if (resolvedByAddingExtension) {
|
|
42304
|
+
return resolvedByAddingExtension;
|
|
42305
|
+
}
|
|
42120
42306
|
}
|
|
42307
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
42308
|
+
}
|
|
42309
|
+
function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) {
|
|
42121
42310
|
// If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one;
|
|
42122
42311
|
// e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts"
|
|
42123
|
-
if (ts.hasJSFileExtension(candidate)) {
|
|
42312
|
+
if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) {
|
|
42124
42313
|
var extensionless = ts.removeFileExtension(candidate);
|
|
42314
|
+
var extension = candidate.substring(extensionless.length);
|
|
42125
42315
|
if (state.traceEnabled) {
|
|
42126
|
-
var extension = candidate.substring(extensionless.length);
|
|
42127
42316
|
trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
|
|
42128
42317
|
}
|
|
42129
|
-
return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
|
|
42318
|
+
return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state);
|
|
42319
|
+
}
|
|
42320
|
+
}
|
|
42321
|
+
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
42322
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) {
|
|
42323
|
+
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
42324
|
+
return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined;
|
|
42130
42325
|
}
|
|
42326
|
+
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
42131
42327
|
}
|
|
42132
42328
|
/** Try to return an existing file that adds one of the `extensions` to `candidate`. */
|
|
42133
|
-
function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
|
|
42329
|
+
function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecordFailures, state) {
|
|
42134
42330
|
if (!onlyRecordFailures) {
|
|
42135
42331
|
// check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing
|
|
42136
42332
|
var directory = ts.getDirectoryPath(candidate);
|
|
@@ -42140,11 +42336,51 @@ var ts;
|
|
|
42140
42336
|
}
|
|
42141
42337
|
switch (extensions) {
|
|
42142
42338
|
case Extensions.DtsOnly:
|
|
42143
|
-
|
|
42339
|
+
switch (originalExtension) {
|
|
42340
|
+
case ".mjs" /* Mjs */:
|
|
42341
|
+
case ".mts" /* Mts */:
|
|
42342
|
+
case ".d.mts" /* Dmts */:
|
|
42343
|
+
return tryExtension(".d.mts" /* Dmts */);
|
|
42344
|
+
case ".cjs" /* Cjs */:
|
|
42345
|
+
case ".cts" /* Cts */:
|
|
42346
|
+
case ".d.cts" /* Dcts */:
|
|
42347
|
+
return tryExtension(".d.cts" /* Dcts */);
|
|
42348
|
+
case ".json" /* Json */:
|
|
42349
|
+
candidate += ".json" /* Json */;
|
|
42350
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42351
|
+
default: return tryExtension(".d.ts" /* Dts */);
|
|
42352
|
+
}
|
|
42144
42353
|
case Extensions.TypeScript:
|
|
42145
|
-
|
|
42354
|
+
switch (originalExtension) {
|
|
42355
|
+
case ".mjs" /* Mjs */:
|
|
42356
|
+
case ".mts" /* Mts */:
|
|
42357
|
+
case ".d.mts" /* Dmts */:
|
|
42358
|
+
return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */);
|
|
42359
|
+
case ".cjs" /* Cjs */:
|
|
42360
|
+
case ".cts" /* Cts */:
|
|
42361
|
+
case ".d.cts" /* Dcts */:
|
|
42362
|
+
return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */);
|
|
42363
|
+
case ".json" /* Json */:
|
|
42364
|
+
candidate += ".json" /* Json */;
|
|
42365
|
+
return tryExtension(".d.ts" /* Dts */);
|
|
42366
|
+
default:
|
|
42367
|
+
return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */);
|
|
42368
|
+
}
|
|
42146
42369
|
case Extensions.JavaScript:
|
|
42147
|
-
|
|
42370
|
+
switch (originalExtension) {
|
|
42371
|
+
case ".mjs" /* Mjs */:
|
|
42372
|
+
case ".mts" /* Mts */:
|
|
42373
|
+
case ".d.mts" /* Dmts */:
|
|
42374
|
+
return tryExtension(".mjs" /* Mjs */);
|
|
42375
|
+
case ".cjs" /* Cjs */:
|
|
42376
|
+
case ".cts" /* Cts */:
|
|
42377
|
+
case ".d.cts" /* Dcts */:
|
|
42378
|
+
return tryExtension(".cjs" /* Cjs */);
|
|
42379
|
+
case ".json" /* Json */:
|
|
42380
|
+
return tryExtension(".json" /* Json */);
|
|
42381
|
+
default:
|
|
42382
|
+
return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */);
|
|
42383
|
+
}
|
|
42148
42384
|
case Extensions.TSConfig:
|
|
42149
42385
|
case Extensions.Json:
|
|
42150
42386
|
return tryExtension(".json" /* Json */);
|
|
@@ -42179,6 +42415,33 @@ var ts;
|
|
|
42179
42415
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
42180
42416
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
42181
42417
|
}
|
|
42418
|
+
/**
|
|
42419
|
+
* A function for locating the package.json scope for a given path
|
|
42420
|
+
*/
|
|
42421
|
+
/*@internal*/
|
|
42422
|
+
function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
|
|
42423
|
+
var state = {
|
|
42424
|
+
host: host,
|
|
42425
|
+
compilerOptions: options,
|
|
42426
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42427
|
+
failedLookupLocations: [],
|
|
42428
|
+
packageJsonInfoCache: packageJsonInfoCache,
|
|
42429
|
+
features: 0,
|
|
42430
|
+
conditions: [],
|
|
42431
|
+
};
|
|
42432
|
+
var parts = ts.getPathComponents(fileName);
|
|
42433
|
+
parts.pop();
|
|
42434
|
+
while (parts.length > 0) {
|
|
42435
|
+
var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state);
|
|
42436
|
+
if (pkg) {
|
|
42437
|
+
return pkg;
|
|
42438
|
+
}
|
|
42439
|
+
parts.pop();
|
|
42440
|
+
}
|
|
42441
|
+
return undefined;
|
|
42442
|
+
}
|
|
42443
|
+
ts.getPackageScopeForPath = getPackageScopeForPath;
|
|
42444
|
+
/*@internal*/
|
|
42182
42445
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
42183
42446
|
var _a, _b, _c;
|
|
42184
42447
|
var host = state.host, traceEnabled = state.traceEnabled;
|
|
@@ -42221,6 +42484,7 @@ var ts;
|
|
|
42221
42484
|
state.failedLookupLocations.push(packageJsonPath);
|
|
42222
42485
|
}
|
|
42223
42486
|
}
|
|
42487
|
+
ts.getPackageJsonInfo = getPackageJsonInfo;
|
|
42224
42488
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
42225
42489
|
var packageFile;
|
|
42226
42490
|
if (jsonContent) {
|
|
@@ -42276,7 +42540,10 @@ var ts;
|
|
|
42276
42540
|
var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
|
|
42277
42541
|
if (packageFileResult)
|
|
42278
42542
|
return packageFileResult;
|
|
42279
|
-
|
|
42543
|
+
// esm mode resolutions don't do package `index` lookups
|
|
42544
|
+
if (!(state.features & NodeResolutionFeatures.EsmMode)) {
|
|
42545
|
+
return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
|
|
42546
|
+
}
|
|
42280
42547
|
}
|
|
42281
42548
|
/** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */
|
|
42282
42549
|
function resolvedIfExtensionMatches(extensions, path) {
|
|
@@ -42306,6 +42573,226 @@ var ts;
|
|
|
42306
42573
|
return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
|
|
42307
42574
|
}
|
|
42308
42575
|
ts.parsePackageName = parsePackageName;
|
|
42576
|
+
function allKeysStartWithDot(obj) {
|
|
42577
|
+
return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42578
|
+
}
|
|
42579
|
+
function noKeyStartsWithDot(obj) {
|
|
42580
|
+
return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
|
|
42581
|
+
}
|
|
42582
|
+
function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42583
|
+
var _a, _b;
|
|
42584
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42585
|
+
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));
|
|
42586
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42587
|
+
if (!scope || !scope.packageJsonContent.exports) {
|
|
42588
|
+
return undefined;
|
|
42589
|
+
}
|
|
42590
|
+
var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
|
|
42591
|
+
if (scope.packageJsonContent.name !== parts[1]) {
|
|
42592
|
+
return undefined;
|
|
42593
|
+
}
|
|
42594
|
+
var trailingParts = parts.slice(2);
|
|
42595
|
+
return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference);
|
|
42596
|
+
}
|
|
42597
|
+
function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
|
|
42598
|
+
if (!scope.packageJsonContent.exports) {
|
|
42599
|
+
return undefined;
|
|
42600
|
+
}
|
|
42601
|
+
if (subpath === ".") {
|
|
42602
|
+
var mainExport = void 0;
|
|
42603
|
+
if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports))) {
|
|
42604
|
+
mainExport = scope.packageJsonContent.exports;
|
|
42605
|
+
}
|
|
42606
|
+
else if (ts.hasProperty(scope.packageJsonContent.exports, ".")) {
|
|
42607
|
+
mainExport = scope.packageJsonContent.exports["."];
|
|
42608
|
+
}
|
|
42609
|
+
if (mainExport) {
|
|
42610
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
42611
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
42612
|
+
}
|
|
42613
|
+
}
|
|
42614
|
+
else if (allKeysStartWithDot(scope.packageJsonContent.exports)) {
|
|
42615
|
+
if (typeof scope.packageJsonContent.exports !== "object") {
|
|
42616
|
+
if (state.traceEnabled) {
|
|
42617
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42618
|
+
}
|
|
42619
|
+
return toSearchResult(/*value*/ undefined);
|
|
42620
|
+
}
|
|
42621
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false);
|
|
42622
|
+
if (result) {
|
|
42623
|
+
return result;
|
|
42624
|
+
}
|
|
42625
|
+
}
|
|
42626
|
+
if (state.traceEnabled) {
|
|
42627
|
+
trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory);
|
|
42628
|
+
}
|
|
42629
|
+
return toSearchResult(/*value*/ undefined);
|
|
42630
|
+
}
|
|
42631
|
+
function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42632
|
+
var _a, _b;
|
|
42633
|
+
if (moduleName === "#" || ts.startsWith(moduleName, "#/")) {
|
|
42634
|
+
if (state.traceEnabled) {
|
|
42635
|
+
trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
|
|
42636
|
+
}
|
|
42637
|
+
return toSearchResult(/*value*/ undefined);
|
|
42638
|
+
}
|
|
42639
|
+
var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
|
|
42640
|
+
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));
|
|
42641
|
+
var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
|
|
42642
|
+
if (!scope) {
|
|
42643
|
+
if (state.traceEnabled) {
|
|
42644
|
+
trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
|
|
42645
|
+
}
|
|
42646
|
+
return toSearchResult(/*value*/ undefined);
|
|
42647
|
+
}
|
|
42648
|
+
if (!scope.packageJsonContent.imports) {
|
|
42649
|
+
if (state.traceEnabled) {
|
|
42650
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
|
|
42651
|
+
}
|
|
42652
|
+
return toSearchResult(/*value*/ undefined);
|
|
42653
|
+
}
|
|
42654
|
+
var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
|
|
42655
|
+
if (result) {
|
|
42656
|
+
return result;
|
|
42657
|
+
}
|
|
42658
|
+
if (state.traceEnabled) {
|
|
42659
|
+
trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
|
|
42660
|
+
}
|
|
42661
|
+
return toSearchResult(/*value*/ undefined);
|
|
42662
|
+
}
|
|
42663
|
+
function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
42664
|
+
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
42665
|
+
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
42666
|
+
var target = lookupTable[moduleName];
|
|
42667
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
42668
|
+
}
|
|
42669
|
+
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; });
|
|
42670
|
+
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
42671
|
+
var potentialTarget = expandingKeys_1[_i];
|
|
42672
|
+
if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) {
|
|
42673
|
+
var target = lookupTable[potentialTarget];
|
|
42674
|
+
var starPos = potentialTarget.indexOf("*");
|
|
42675
|
+
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
42676
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42677
|
+
}
|
|
42678
|
+
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
42679
|
+
var target = lookupTable[potentialTarget];
|
|
42680
|
+
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
42681
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
42682
|
+
}
|
|
42683
|
+
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
42684
|
+
var target = lookupTable[potentialTarget];
|
|
42685
|
+
var subpath = moduleName.substring(potentialTarget.length);
|
|
42686
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
42687
|
+
}
|
|
42688
|
+
}
|
|
42689
|
+
function matchesPatternWithTrailer(target, name) {
|
|
42690
|
+
if (ts.endsWith(target, "*"))
|
|
42691
|
+
return false; // handled by next case in loop
|
|
42692
|
+
var starPos = target.indexOf("*");
|
|
42693
|
+
if (starPos === -1)
|
|
42694
|
+
return false; // handled by last case in loop
|
|
42695
|
+
return ts.startsWith(name, target.substring(0, starPos)) && ts.endsWith(name, target.substring(starPos + 1));
|
|
42696
|
+
}
|
|
42697
|
+
}
|
|
42698
|
+
/**
|
|
42699
|
+
* Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration
|
|
42700
|
+
*/
|
|
42701
|
+
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
42702
|
+
return loadModuleFromTargetImportOrExport;
|
|
42703
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
42704
|
+
var _a, _b;
|
|
42705
|
+
if (typeof target === "string") {
|
|
42706
|
+
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
42707
|
+
if (state.traceEnabled) {
|
|
42708
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42709
|
+
}
|
|
42710
|
+
return toSearchResult(/*value*/ undefined);
|
|
42711
|
+
}
|
|
42712
|
+
if (!ts.startsWith(target, "./")) {
|
|
42713
|
+
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
42714
|
+
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
42715
|
+
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
42716
|
+
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
42717
|
+
}
|
|
42718
|
+
if (state.traceEnabled) {
|
|
42719
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42720
|
+
}
|
|
42721
|
+
return toSearchResult(/*value*/ undefined);
|
|
42722
|
+
}
|
|
42723
|
+
var parts = ts.pathIsRelative(target) ? ts.getPathComponents(target).slice(1) : ts.getPathComponents(target);
|
|
42724
|
+
var partsAfterFirst = parts.slice(1);
|
|
42725
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42726
|
+
if (state.traceEnabled) {
|
|
42727
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42728
|
+
}
|
|
42729
|
+
return toSearchResult(/*value*/ undefined);
|
|
42730
|
+
}
|
|
42731
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42732
|
+
// TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need
|
|
42733
|
+
// to be in the business of validating everyone's import and export map correctness.
|
|
42734
|
+
var subpathParts = ts.getPathComponents(subpath);
|
|
42735
|
+
if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) {
|
|
42736
|
+
if (state.traceEnabled) {
|
|
42737
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42738
|
+
}
|
|
42739
|
+
return toSearchResult(/*value*/ undefined);
|
|
42740
|
+
}
|
|
42741
|
+
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));
|
|
42742
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
42743
|
+
}
|
|
42744
|
+
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
42745
|
+
if (!Array.isArray(target)) {
|
|
42746
|
+
for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) {
|
|
42747
|
+
var key = _c[_i];
|
|
42748
|
+
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
42749
|
+
var subTarget = target[key];
|
|
42750
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
42751
|
+
if (result) {
|
|
42752
|
+
return result;
|
|
42753
|
+
}
|
|
42754
|
+
}
|
|
42755
|
+
}
|
|
42756
|
+
return undefined;
|
|
42757
|
+
}
|
|
42758
|
+
else {
|
|
42759
|
+
if (!ts.length(target)) {
|
|
42760
|
+
if (state.traceEnabled) {
|
|
42761
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42762
|
+
}
|
|
42763
|
+
return toSearchResult(/*value*/ undefined);
|
|
42764
|
+
}
|
|
42765
|
+
for (var _d = 0, target_1 = target; _d < target_1.length; _d++) {
|
|
42766
|
+
var elem = target_1[_d];
|
|
42767
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
42768
|
+
if (result) {
|
|
42769
|
+
return result;
|
|
42770
|
+
}
|
|
42771
|
+
}
|
|
42772
|
+
}
|
|
42773
|
+
}
|
|
42774
|
+
else if (target === null) { // eslint-disable-line no-null/no-null
|
|
42775
|
+
if (state.traceEnabled) {
|
|
42776
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName);
|
|
42777
|
+
}
|
|
42778
|
+
return toSearchResult(/*value*/ undefined);
|
|
42779
|
+
}
|
|
42780
|
+
if (state.traceEnabled) {
|
|
42781
|
+
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
42782
|
+
}
|
|
42783
|
+
return toSearchResult(/*value*/ undefined);
|
|
42784
|
+
}
|
|
42785
|
+
function isApplicableVersionedTypesKey(conditions, key) {
|
|
42786
|
+
if (conditions.indexOf("types") === -1)
|
|
42787
|
+
return false; // only apply versioned types conditions if the types condition is applied
|
|
42788
|
+
if (!ts.startsWith(key, "types@"))
|
|
42789
|
+
return false;
|
|
42790
|
+
var range = ts.VersionRange.tryParse(key.substring("types@".length));
|
|
42791
|
+
if (!range)
|
|
42792
|
+
return false;
|
|
42793
|
+
return range.test(ts.version);
|
|
42794
|
+
}
|
|
42795
|
+
}
|
|
42309
42796
|
function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
|
|
42310
42797
|
return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference);
|
|
42311
42798
|
}
|
|
@@ -42314,24 +42801,24 @@ var ts;
|
|
|
42314
42801
|
return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42315
42802
|
}
|
|
42316
42803
|
function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42317
|
-
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42804
|
+
var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference);
|
|
42318
42805
|
return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
|
|
42319
42806
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
42320
42807
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
|
|
42321
42808
|
if (resolutionFromCache) {
|
|
42322
42809
|
return resolutionFromCache;
|
|
42323
42810
|
}
|
|
42324
|
-
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
|
|
42811
|
+
return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference));
|
|
42325
42812
|
}
|
|
42326
42813
|
});
|
|
42327
42814
|
}
|
|
42328
|
-
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
|
|
42815
|
+
function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
|
|
42329
42816
|
var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
|
|
42330
42817
|
var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
|
|
42331
42818
|
if (!nodeModulesFolderExists && state.traceEnabled) {
|
|
42332
42819
|
trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
|
|
42333
42820
|
}
|
|
42334
|
-
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
|
|
42821
|
+
var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference);
|
|
42335
42822
|
if (packageResult) {
|
|
42336
42823
|
return packageResult;
|
|
42337
42824
|
}
|
|
@@ -42344,27 +42831,35 @@ var ts;
|
|
|
42344
42831
|
}
|
|
42345
42832
|
nodeModulesAtTypesExists = false;
|
|
42346
42833
|
}
|
|
42347
|
-
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
|
|
42834
|
+
return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state, cache, redirectedReference);
|
|
42348
42835
|
}
|
|
42349
42836
|
}
|
|
42350
|
-
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
|
|
42837
|
+
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
|
|
42351
42838
|
var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
|
|
42352
42839
|
// First look for a nested package.json, as in `node_modules/foo/bar/package.json`.
|
|
42353
42840
|
var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
|
|
42354
|
-
if (
|
|
42355
|
-
|
|
42356
|
-
if (
|
|
42357
|
-
|
|
42841
|
+
// But only if we're not respecting export maps (if we are, we might redirect around this location)
|
|
42842
|
+
if (!(state.features & NodeResolutionFeatures.Exports)) {
|
|
42843
|
+
if (packageInfo) {
|
|
42844
|
+
var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
|
|
42845
|
+
if (fromFile) {
|
|
42846
|
+
return noPackageId(fromFile);
|
|
42847
|
+
}
|
|
42848
|
+
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42849
|
+
return withPackageId(packageInfo, fromDirectory);
|
|
42358
42850
|
}
|
|
42359
|
-
var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
|
|
42360
|
-
return withPackageId(packageInfo, fromDirectory);
|
|
42361
42851
|
}
|
|
42852
|
+
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42362
42853
|
var loader = function (extensions, candidate, onlyRecordFailures, state) {
|
|
42854
|
+
var _a;
|
|
42855
|
+
// package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them)
|
|
42856
|
+
if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) {
|
|
42857
|
+
return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value;
|
|
42858
|
+
}
|
|
42363
42859
|
var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
|
|
42364
42860
|
loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
|
|
42365
42861
|
return withPackageId(packageInfo, pathAndExtension);
|
|
42366
42862
|
};
|
|
42367
|
-
var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
|
|
42368
42863
|
if (rest !== "") { // If "rest" is empty, we just did this search above.
|
|
42369
42864
|
var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
|
|
42370
42865
|
// 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.
|
|
@@ -42466,7 +42961,7 @@ var ts;
|
|
|
42466
42961
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
42467
42962
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
42468
42963
|
var failedLookupLocations = [];
|
|
42469
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache };
|
|
42964
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
42470
42965
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
42471
42966
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
42472
42967
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
@@ -42477,7 +42972,7 @@ var ts;
|
|
|
42477
42972
|
return { value: resolvedUsingSettings };
|
|
42478
42973
|
}
|
|
42479
42974
|
if (!ts.isExternalModuleNameRelative(moduleName)) {
|
|
42480
|
-
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
|
|
42975
|
+
var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference);
|
|
42481
42976
|
// Climb up parent directories looking for a module.
|
|
42482
42977
|
var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
|
|
42483
42978
|
var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
|
|
@@ -42513,8 +43008,8 @@ var ts;
|
|
|
42513
43008
|
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);
|
|
42514
43009
|
}
|
|
42515
43010
|
var failedLookupLocations = [];
|
|
42516
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache };
|
|
42517
|
-
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false);
|
|
43011
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
43012
|
+
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
42518
43013
|
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
42519
43014
|
}
|
|
42520
43015
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
@@ -44695,7 +45190,7 @@ var ts;
|
|
|
44695
45190
|
}
|
|
44696
45191
|
function checkStrictModeLabeledStatement(node) {
|
|
44697
45192
|
// Grammar checking for labeledStatement
|
|
44698
|
-
if (inStrictMode && options
|
|
45193
|
+
if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) {
|
|
44699
45194
|
if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
|
|
44700
45195
|
errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
|
|
44701
45196
|
}
|
|
@@ -46211,7 +46706,7 @@ var ts;
|
|
|
46211
46706
|
host.getSourceFiles().forEach(function (sf) {
|
|
46212
46707
|
if (!sf.resolvedModules)
|
|
46213
46708
|
return;
|
|
46214
|
-
|
|
46709
|
+
sf.resolvedModules.forEach(function (r) {
|
|
46215
46710
|
if (r && r.packageId)
|
|
46216
46711
|
map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name));
|
|
46217
46712
|
});
|
|
@@ -46629,10 +47124,13 @@ var ts;
|
|
|
46629
47124
|
var undefinedProperties = new ts.Map();
|
|
46630
47125
|
var unknownSymbol = createSymbol(4 /* Property */, "unknown");
|
|
46631
47126
|
var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */);
|
|
47127
|
+
var unresolvedSymbols = new ts.Map();
|
|
47128
|
+
var errorTypes = new ts.Map();
|
|
46632
47129
|
var anyType = createIntrinsicType(1 /* Any */, "any");
|
|
46633
47130
|
var autoType = createIntrinsicType(1 /* Any */, "any");
|
|
46634
47131
|
var wildcardType = createIntrinsicType(1 /* Any */, "any");
|
|
46635
47132
|
var errorType = createIntrinsicType(1 /* Any */, "error");
|
|
47133
|
+
var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved");
|
|
46636
47134
|
var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */);
|
|
46637
47135
|
var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic");
|
|
46638
47136
|
var unknownType = createIntrinsicType(2 /* Unknown */, "unknown");
|
|
@@ -47354,7 +47852,7 @@ var ts;
|
|
|
47354
47852
|
}
|
|
47355
47853
|
else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
47356
47854
|
// foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property
|
|
47357
|
-
return !(compilerOptions
|
|
47855
|
+
return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47358
47856
|
&& ts.getContainingClass(declaration) === ts.getContainingClass(usage)
|
|
47359
47857
|
&& isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
47360
47858
|
}
|
|
@@ -47382,7 +47880,7 @@ var ts;
|
|
|
47382
47880
|
return true;
|
|
47383
47881
|
}
|
|
47384
47882
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
47385
|
-
if (compilerOptions
|
|
47883
|
+
if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields
|
|
47386
47884
|
&& ts.getContainingClass(declaration)
|
|
47387
47885
|
&& (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
47388
47886
|
return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true);
|
|
@@ -47560,7 +48058,7 @@ var ts;
|
|
|
47560
48058
|
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, issueSuggestions);
|
|
47561
48059
|
}
|
|
47562
48060
|
function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, issueSuggestions) {
|
|
47563
|
-
var _a;
|
|
48061
|
+
var _a, _b, _c;
|
|
47564
48062
|
var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location
|
|
47565
48063
|
var result;
|
|
47566
48064
|
var lastLocation;
|
|
@@ -47630,7 +48128,7 @@ var ts;
|
|
|
47630
48128
|
isInExternalModule = true;
|
|
47631
48129
|
// falls through
|
|
47632
48130
|
case 260 /* ModuleDeclaration */:
|
|
47633
|
-
var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
|
|
48131
|
+
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
47634
48132
|
if (location.kind === 303 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
47635
48133
|
// It's an external module. First see if the module has an export default and if the local
|
|
47636
48134
|
// name of that export default matches.
|
|
@@ -47661,7 +48159,7 @@ var ts;
|
|
|
47661
48159
|
}
|
|
47662
48160
|
// ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs)
|
|
47663
48161
|
if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) {
|
|
47664
|
-
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((
|
|
48162
|
+
if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) {
|
|
47665
48163
|
result = undefined;
|
|
47666
48164
|
}
|
|
47667
48165
|
else {
|
|
@@ -47670,7 +48168,7 @@ var ts;
|
|
|
47670
48168
|
}
|
|
47671
48169
|
break;
|
|
47672
48170
|
case 259 /* EnumDeclaration */:
|
|
47673
|
-
if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
|
|
48171
|
+
if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) {
|
|
47674
48172
|
break loop;
|
|
47675
48173
|
}
|
|
47676
48174
|
break;
|
|
@@ -47753,7 +48251,7 @@ var ts;
|
|
|
47753
48251
|
case 213 /* ArrowFunction */:
|
|
47754
48252
|
// when targeting ES6 or higher there is no 'arguments' in an arrow function
|
|
47755
48253
|
// for lower compile targets the resolved symbol is used to emit an error
|
|
47756
|
-
if (compilerOptions
|
|
48254
|
+
if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) {
|
|
47757
48255
|
break;
|
|
47758
48256
|
}
|
|
47759
48257
|
// falls through
|
|
@@ -47921,7 +48419,7 @@ var ts;
|
|
|
47921
48419
|
}
|
|
47922
48420
|
// Perform extra checks only if error reporting was requested
|
|
47923
48421
|
if (nameNotFoundMessage) {
|
|
47924
|
-
if (propertyWithInvalidInitializer && !(compilerOptions
|
|
48422
|
+
if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
|
|
47925
48423
|
// We have a match, but the reference occurred within a property initializer and the identifier also binds
|
|
47926
48424
|
// to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
|
|
47927
48425
|
// with ESNext+useDefineForClassFields because the scope semantics are different.
|
|
@@ -48499,7 +48997,7 @@ var ts;
|
|
|
48499
48997
|
if (!ts.isIdentifier(name)) {
|
|
48500
48998
|
return undefined;
|
|
48501
48999
|
}
|
|
48502
|
-
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions
|
|
49000
|
+
var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions));
|
|
48503
49001
|
var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
|
|
48504
49002
|
if (targetSymbol) {
|
|
48505
49003
|
if (name.escapedText) {
|
|
@@ -48577,18 +49075,18 @@ var ts;
|
|
|
48577
49075
|
}
|
|
48578
49076
|
function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
|
|
48579
49077
|
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
48580
|
-
var message = compilerOptions
|
|
49078
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
|
|
48581
49079
|
ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48582
49080
|
error(name, message, declarationName);
|
|
48583
49081
|
}
|
|
48584
49082
|
else {
|
|
48585
49083
|
if (ts.isInJSFile(node)) {
|
|
48586
|
-
var message = compilerOptions
|
|
49084
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
|
|
48587
49085
|
ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
|
|
48588
49086
|
error(name, message, declarationName);
|
|
48589
49087
|
}
|
|
48590
49088
|
else {
|
|
48591
|
-
var message = compilerOptions
|
|
49089
|
+
var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
|
|
48592
49090
|
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;
|
|
48593
49091
|
error(name, message, declarationName, declarationName, moduleName);
|
|
48594
49092
|
}
|
|
@@ -49029,6 +49527,7 @@ var ts;
|
|
|
49029
49527
|
: undefined;
|
|
49030
49528
|
}
|
|
49031
49529
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
49530
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49032
49531
|
if (isForAugmentation === void 0) { isForAugmentation = false; }
|
|
49033
49532
|
if (ts.startsWith(moduleReference, "@types/")) {
|
|
49034
49533
|
var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
@@ -49040,7 +49539,15 @@ var ts;
|
|
|
49040
49539
|
return ambientModule;
|
|
49041
49540
|
}
|
|
49042
49541
|
var currentSourceFile = ts.getSourceFileOfNode(location);
|
|
49043
|
-
var
|
|
49542
|
+
var contextSpecifier = ts.isStringLiteralLike(location)
|
|
49543
|
+
? location
|
|
49544
|
+
: ((_a = ts.findAncestor(location, ts.isImportCall)) === null || _a === void 0 ? void 0 : _a.arguments[0]) ||
|
|
49545
|
+
((_b = ts.findAncestor(location, ts.isImportDeclaration)) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) ||
|
|
49546
|
+
((_c = ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) ||
|
|
49547
|
+
((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) ||
|
|
49548
|
+
((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
|
|
49549
|
+
((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
|
|
49550
|
+
var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined); // TODO: GH#18217
|
|
49044
49551
|
var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
|
|
49045
49552
|
var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
|
|
49046
49553
|
if (sourceFile) {
|
|
@@ -49048,6 +49555,12 @@ var ts;
|
|
|
49048
49555
|
if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
49049
49556
|
errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference);
|
|
49050
49557
|
}
|
|
49558
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) {
|
|
49559
|
+
var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration);
|
|
49560
|
+
if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
49561
|
+
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);
|
|
49562
|
+
}
|
|
49563
|
+
}
|
|
49051
49564
|
// merged symbol is module declaration symbol combined with all augmentations
|
|
49052
49565
|
return getMergedSymbol(sourceFile.symbol);
|
|
49053
49566
|
}
|
|
@@ -49105,15 +49618,14 @@ var ts;
|
|
|
49105
49618
|
* Direct users to import source with .js extension if outputting an ES module.
|
|
49106
49619
|
* @see https://github.com/microsoft/TypeScript/issues/42151
|
|
49107
49620
|
*/
|
|
49108
|
-
|
|
49109
|
-
|
|
49110
|
-
replacedImportSource += ".js";
|
|
49621
|
+
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
49622
|
+
replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js";
|
|
49111
49623
|
}
|
|
49112
49624
|
error(errorNode, diag, tsExtension, replacedImportSource);
|
|
49113
49625
|
}
|
|
49114
49626
|
else if (!compilerOptions.resolveJsonModule &&
|
|
49115
49627
|
ts.fileExtensionIs(moduleReference, ".json" /* Json */) &&
|
|
49116
|
-
ts.getEmitModuleResolutionKind(compilerOptions)
|
|
49628
|
+
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic &&
|
|
49117
49629
|
ts.hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
49118
49630
|
error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
49119
49631
|
}
|
|
@@ -49186,7 +49698,7 @@ var ts;
|
|
|
49186
49698
|
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);
|
|
49187
49699
|
return symbol;
|
|
49188
49700
|
}
|
|
49189
|
-
if (compilerOptions
|
|
49701
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
49190
49702
|
var referenceParent = referencingLocation.parent;
|
|
49191
49703
|
if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
|
|
49192
49704
|
ts.isImportCall(referenceParent)) {
|
|
@@ -50071,7 +50583,9 @@ var ts;
|
|
|
50071
50583
|
var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer);
|
|
50072
50584
|
if (typeNode === undefined)
|
|
50073
50585
|
return ts.Debug.fail("should always get typenode");
|
|
50074
|
-
|
|
50586
|
+
// The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`.
|
|
50587
|
+
// Otherwise, we always strip comments out.
|
|
50588
|
+
var options = { removeComments: type !== unresolvedType };
|
|
50075
50589
|
var printer = ts.createPrinter(options);
|
|
50076
50590
|
var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
|
|
50077
50591
|
printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer);
|
|
@@ -50151,6 +50665,7 @@ var ts;
|
|
|
50151
50665
|
isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
|
|
50152
50666
|
fileExists: function (fileName) { return host.fileExists(fileName); },
|
|
50153
50667
|
getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
|
|
50668
|
+
readFile: host.readFile ? (function (fileName) { return host.readFile(fileName); }) : undefined,
|
|
50154
50669
|
} : undefined },
|
|
50155
50670
|
encounteredError: false,
|
|
50156
50671
|
reportedDiagnostic: false,
|
|
@@ -50216,6 +50731,12 @@ var ts;
|
|
|
50216
50731
|
type = getReducedType(type);
|
|
50217
50732
|
}
|
|
50218
50733
|
if (type.flags & 1 /* Any */) {
|
|
50734
|
+
if (type.aliasSymbol) {
|
|
50735
|
+
return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context));
|
|
50736
|
+
}
|
|
50737
|
+
if (type === unresolvedType) {
|
|
50738
|
+
return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved");
|
|
50739
|
+
}
|
|
50219
50740
|
context.approximateLength += 3;
|
|
50220
50741
|
return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */);
|
|
50221
50742
|
}
|
|
@@ -51304,6 +51825,10 @@ var ts;
|
|
|
51304
51825
|
}
|
|
51305
51826
|
return specifier;
|
|
51306
51827
|
}
|
|
51828
|
+
function symbolToEntityNameNode(symbol) {
|
|
51829
|
+
var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName));
|
|
51830
|
+
return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier;
|
|
51831
|
+
}
|
|
51307
51832
|
function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
|
|
51308
51833
|
var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module
|
|
51309
51834
|
var isTypeOf = meaning === 111551 /* Value */;
|
|
@@ -51312,7 +51837,7 @@ var ts;
|
|
|
51312
51837
|
var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
|
|
51313
51838
|
var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
|
|
51314
51839
|
var specifier = getSpecifierForModuleSymbol(chain[0], context);
|
|
51315
|
-
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions)
|
|
51840
|
+
if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) {
|
|
51316
51841
|
// If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error
|
|
51317
51842
|
// since declaration files with these kinds of references are liable to fail when published :(
|
|
51318
51843
|
context.encounteredError = true;
|
|
@@ -51535,7 +52060,7 @@ var ts;
|
|
|
51535
52060
|
if (nameType) {
|
|
51536
52061
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
51537
52062
|
var name = "" + nameType.value;
|
|
51538
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
52063
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
51539
52064
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51540
52065
|
}
|
|
51541
52066
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -51549,7 +52074,7 @@ var ts;
|
|
|
51549
52074
|
}
|
|
51550
52075
|
}
|
|
51551
52076
|
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
51552
|
-
return ts.isIdentifierText(name, compilerOptions
|
|
52077
|
+
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
51553
52078
|
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
51554
52079
|
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
51555
52080
|
}
|
|
@@ -51590,7 +52115,7 @@ var ts;
|
|
|
51590
52115
|
* so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
|
|
51591
52116
|
*/
|
|
51592
52117
|
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
51593
|
-
if (type
|
|
52118
|
+
if (!isErrorType(type) && enclosingDeclaration) {
|
|
51594
52119
|
var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
|
|
51595
52120
|
if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
51596
52121
|
// try to reuse the existing annotation
|
|
@@ -51613,7 +52138,7 @@ var ts;
|
|
|
51613
52138
|
return result;
|
|
51614
52139
|
}
|
|
51615
52140
|
function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
|
|
51616
|
-
if (type
|
|
52141
|
+
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
51617
52142
|
var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
|
|
51618
52143
|
if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) {
|
|
51619
52144
|
var annotated = getTypeFromTypeNode(annotation);
|
|
@@ -51720,7 +52245,7 @@ var ts;
|
|
|
51720
52245
|
/*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
51721
52246
|
}
|
|
51722
52247
|
}
|
|
51723
|
-
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(
|
|
52248
|
+
if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) {
|
|
51724
52249
|
return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
51725
52250
|
}
|
|
51726
52251
|
if (ts.isLiteralImportTypeNode(node)) {
|
|
@@ -52483,6 +53008,27 @@ var ts;
|
|
|
52483
53008
|
/*decorators*/ undefined,
|
|
52484
53009
|
/*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);
|
|
52485
53010
|
}
|
|
53011
|
+
function getSomeTargetNameFromDeclarations(declarations) {
|
|
53012
|
+
return ts.firstDefined(declarations, function (d) {
|
|
53013
|
+
if (ts.isImportSpecifier(d) || ts.isExportSpecifier(d)) {
|
|
53014
|
+
return ts.idText(d.propertyName || d.name);
|
|
53015
|
+
}
|
|
53016
|
+
if (ts.isBinaryExpression(d) || ts.isExportAssignment(d)) {
|
|
53017
|
+
var expression = ts.isExportAssignment(d) ? d.expression : d.right;
|
|
53018
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
53019
|
+
return ts.idText(expression.name);
|
|
53020
|
+
}
|
|
53021
|
+
}
|
|
53022
|
+
if (isAliasSymbolDeclaration(d)) {
|
|
53023
|
+
// This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module.
|
|
53024
|
+
var name = ts.getNameOfDeclaration(d);
|
|
53025
|
+
if (name && ts.isIdentifier(name)) {
|
|
53026
|
+
return ts.idText(name);
|
|
53027
|
+
}
|
|
53028
|
+
}
|
|
53029
|
+
return undefined;
|
|
53030
|
+
});
|
|
53031
|
+
}
|
|
52486
53032
|
function serializeAsAlias(symbol, localName, modifierFlags) {
|
|
52487
53033
|
var _a, _b, _c, _d, _e;
|
|
52488
53034
|
// synthesize an alias, eg `export { symbolName as Name }`
|
|
@@ -52495,8 +53041,10 @@ var ts;
|
|
|
52495
53041
|
if (!target) {
|
|
52496
53042
|
return;
|
|
52497
53043
|
}
|
|
52498
|
-
|
|
52499
|
-
|
|
53044
|
+
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
|
|
53045
|
+
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
|
|
53046
|
+
var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName);
|
|
53047
|
+
if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) {
|
|
52500
53048
|
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
|
|
52501
53049
|
verbatimTargetName = "default" /* Default */;
|
|
52502
53050
|
}
|
|
@@ -53043,7 +53591,7 @@ var ts;
|
|
|
53043
53591
|
if (nameType) {
|
|
53044
53592
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
53045
53593
|
var name = "" + nameType.value;
|
|
53046
|
-
if (!ts.isIdentifierText(name, compilerOptions
|
|
53594
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
53047
53595
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
53048
53596
|
}
|
|
53049
53597
|
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
@@ -53348,6 +53896,11 @@ var ts;
|
|
|
53348
53896
|
function isTypeAny(type) {
|
|
53349
53897
|
return type && (type.flags & 1 /* Any */) !== 0;
|
|
53350
53898
|
}
|
|
53899
|
+
function isErrorType(type) {
|
|
53900
|
+
// The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for
|
|
53901
|
+
// a reference to an unresolved symbol. We want those to behave like the errorType.
|
|
53902
|
+
return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol);
|
|
53903
|
+
}
|
|
53351
53904
|
// Return the type of a binding element parent. We check SymbolLinks first to see if a type has been
|
|
53352
53905
|
// assigned by contextual typing.
|
|
53353
53906
|
function getTypeForBindingElementParent(node) {
|
|
@@ -53865,7 +54418,7 @@ var ts;
|
|
|
53865
54418
|
if (!declaredType) {
|
|
53866
54419
|
return type;
|
|
53867
54420
|
}
|
|
53868
|
-
else if (declaredType
|
|
54421
|
+
else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) {
|
|
53869
54422
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type);
|
|
53870
54423
|
}
|
|
53871
54424
|
}
|
|
@@ -54759,7 +55312,7 @@ var ts;
|
|
|
54759
55312
|
for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
|
|
54760
55313
|
var node = implementsTypeNodes_1[_b];
|
|
54761
55314
|
var implementsType = getTypeFromTypeNode(node);
|
|
54762
|
-
if (implementsType
|
|
55315
|
+
if (!isErrorType(implementsType)) {
|
|
54763
55316
|
if (resolvedImplementsTypes === ts.emptyArray) {
|
|
54764
55317
|
resolvedImplementsTypes = [implementsType];
|
|
54765
55318
|
}
|
|
@@ -54839,7 +55392,7 @@ var ts;
|
|
|
54839
55392
|
}
|
|
54840
55393
|
baseType = getReturnTypeOfSignature(constructors[0]);
|
|
54841
55394
|
}
|
|
54842
|
-
if (baseType
|
|
55395
|
+
if (isErrorType(baseType)) {
|
|
54843
55396
|
return type.resolvedBaseTypes = ts.emptyArray;
|
|
54844
55397
|
}
|
|
54845
55398
|
var reducedBaseType = getReducedType(baseType);
|
|
@@ -54895,7 +55448,7 @@ var ts;
|
|
|
54895
55448
|
for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
|
|
54896
55449
|
var node = _c[_b];
|
|
54897
55450
|
var baseType = getReducedType(getTypeFromTypeNode(node));
|
|
54898
|
-
if (baseType
|
|
55451
|
+
if (!isErrorType(baseType)) {
|
|
54899
55452
|
if (isValidBaseType(baseType)) {
|
|
54900
55453
|
if (type !== baseType && !hasBaseType(baseType, type)) {
|
|
54901
55454
|
if (type.resolvedBaseTypes === ts.emptyArray) {
|
|
@@ -56737,7 +57290,7 @@ var ts;
|
|
|
56737
57290
|
for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) {
|
|
56738
57291
|
var current = _c[_i];
|
|
56739
57292
|
var type = getApparentType(current);
|
|
56740
|
-
if (!(type
|
|
57293
|
+
if (!(isErrorType(type) || type.flags & 131072 /* Never */)) {
|
|
56741
57294
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
56742
57295
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
56743
57296
|
if (prop) {
|
|
@@ -57687,7 +58240,7 @@ var ts;
|
|
|
57687
58240
|
}
|
|
57688
58241
|
else {
|
|
57689
58242
|
var type = getTypeFromTypeNode(constraintDeclaration);
|
|
57690
|
-
if (type.flags & 1 /* Any */ && type
|
|
58243
|
+
if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed
|
|
57691
58244
|
// use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was),
|
|
57692
58245
|
// use unknown otherwise
|
|
57693
58246
|
type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType;
|
|
@@ -57859,6 +58412,18 @@ var ts;
|
|
|
57859
58412
|
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
|
57860
58413
|
*/
|
|
57861
58414
|
function getTypeFromTypeAliasReference(node, symbol) {
|
|
58415
|
+
if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) {
|
|
58416
|
+
var typeArguments = typeArgumentsFromTypeReferenceNode(node);
|
|
58417
|
+
var id = getAliasId(symbol, typeArguments);
|
|
58418
|
+
var errorType_1 = errorTypes.get(id);
|
|
58419
|
+
if (!errorType_1) {
|
|
58420
|
+
errorType_1 = createIntrinsicType(1 /* Any */, "error");
|
|
58421
|
+
errorType_1.aliasSymbol = symbol;
|
|
58422
|
+
errorType_1.aliasTypeArguments = typeArguments;
|
|
58423
|
+
errorTypes.set(id, errorType_1);
|
|
58424
|
+
}
|
|
58425
|
+
return errorType_1;
|
|
58426
|
+
}
|
|
57862
58427
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
57863
58428
|
var typeParameters = getSymbolLinks(symbol).typeParameters;
|
|
57864
58429
|
if (typeParameters) {
|
|
@@ -57900,11 +58465,37 @@ var ts;
|
|
|
57900
58465
|
}
|
|
57901
58466
|
return undefined;
|
|
57902
58467
|
}
|
|
57903
|
-
function
|
|
57904
|
-
|
|
58468
|
+
function getSymbolPath(symbol) {
|
|
58469
|
+
return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName;
|
|
58470
|
+
}
|
|
58471
|
+
function getUnresolvedSymbolForEntityName(name) {
|
|
58472
|
+
var identifier = name.kind === 160 /* QualifiedName */ ? name.right :
|
|
58473
|
+
name.kind === 205 /* PropertyAccessExpression */ ? name.name :
|
|
58474
|
+
name;
|
|
58475
|
+
var text = identifier.escapedText;
|
|
58476
|
+
if (text) {
|
|
58477
|
+
var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) :
|
|
58478
|
+
name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) :
|
|
58479
|
+
undefined;
|
|
58480
|
+
var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text;
|
|
58481
|
+
var result = unresolvedSymbols.get(path);
|
|
58482
|
+
if (!result) {
|
|
58483
|
+
unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */));
|
|
58484
|
+
result.parent = parentSymbol;
|
|
58485
|
+
result.declaredType = unresolvedType;
|
|
58486
|
+
}
|
|
58487
|
+
return result;
|
|
58488
|
+
}
|
|
58489
|
+
return unknownSymbol;
|
|
58490
|
+
}
|
|
58491
|
+
function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) {
|
|
58492
|
+
var name = getTypeReferenceName(typeReference);
|
|
58493
|
+
if (!name) {
|
|
57905
58494
|
return unknownSymbol;
|
|
57906
58495
|
}
|
|
57907
|
-
|
|
58496
|
+
var symbol = resolveEntityName(name, meaning, ignoreErrors);
|
|
58497
|
+
return symbol && symbol !== unknownSymbol ? symbol :
|
|
58498
|
+
ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name);
|
|
57908
58499
|
}
|
|
57909
58500
|
function getTypeReferenceType(node, symbol) {
|
|
57910
58501
|
if (symbol === unknownSymbol) {
|
|
@@ -57929,7 +58520,7 @@ var ts;
|
|
|
57929
58520
|
}
|
|
57930
58521
|
else {
|
|
57931
58522
|
// Resolve the type reference as a Type for the purpose of reporting errors.
|
|
57932
|
-
resolveTypeReferenceName(
|
|
58523
|
+
resolveTypeReferenceName(node, 788968 /* Type */);
|
|
57933
58524
|
return getTypeOfSymbol(symbol);
|
|
57934
58525
|
}
|
|
57935
58526
|
}
|
|
@@ -58073,18 +58664,18 @@ var ts;
|
|
|
58073
58664
|
if (isJSDocTypeReference(node)) {
|
|
58074
58665
|
type = getIntendedTypeFromJSDocTypeReference(node);
|
|
58075
58666
|
if (!type) {
|
|
58076
|
-
symbol = resolveTypeReferenceName(
|
|
58667
|
+
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
|
|
58077
58668
|
if (symbol === unknownSymbol) {
|
|
58078
|
-
symbol = resolveTypeReferenceName(
|
|
58669
|
+
symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */);
|
|
58079
58670
|
}
|
|
58080
58671
|
else {
|
|
58081
|
-
resolveTypeReferenceName(
|
|
58672
|
+
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
|
|
58082
58673
|
}
|
|
58083
58674
|
type = getTypeReferenceType(node, symbol);
|
|
58084
58675
|
}
|
|
58085
58676
|
}
|
|
58086
58677
|
if (!type) {
|
|
58087
|
-
symbol = resolveTypeReferenceName(
|
|
58678
|
+
symbol = resolveTypeReferenceName(node, meaning);
|
|
58088
58679
|
type = getTypeReferenceType(node, symbol);
|
|
58089
58680
|
}
|
|
58090
58681
|
// Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the
|
|
@@ -58345,7 +58936,7 @@ var ts;
|
|
|
58345
58936
|
function mayResolveTypeAlias(node) {
|
|
58346
58937
|
switch (node.kind) {
|
|
58347
58938
|
case 177 /* TypeReference */:
|
|
58348
|
-
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node
|
|
58939
|
+
return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */);
|
|
58349
58940
|
case 180 /* TypeQuery */:
|
|
58350
58941
|
return true;
|
|
58351
58942
|
case 192 /* TypeOperator */:
|
|
@@ -58620,8 +59211,6 @@ var ts;
|
|
|
58620
59211
|
// We ignore 'never' types in unions
|
|
58621
59212
|
if (!(flags & 131072 /* Never */)) {
|
|
58622
59213
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58623
|
-
if (flags & 469499904 /* StructuredOrInstantiable */)
|
|
58624
|
-
includes |= 262144 /* IncludesStructuredOrInstantiable */;
|
|
58625
59214
|
if (type === wildcardType)
|
|
58626
59215
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58627
59216
|
if (!strictNullChecks && flags & 98304 /* Nullable */) {
|
|
@@ -58927,13 +59516,19 @@ var ts;
|
|
|
58927
59516
|
if (type === wildcardType)
|
|
58928
59517
|
includes |= 8388608 /* IncludesWildcard */;
|
|
58929
59518
|
}
|
|
58930
|
-
else if (
|
|
58931
|
-
if (
|
|
58932
|
-
|
|
58933
|
-
|
|
58934
|
-
|
|
59519
|
+
else if (strictNullChecks || !(flags & 98304 /* Nullable */)) {
|
|
59520
|
+
if (exactOptionalPropertyTypes && type === missingType) {
|
|
59521
|
+
includes |= 262144 /* IncludesMissingType */;
|
|
59522
|
+
type = undefinedType;
|
|
59523
|
+
}
|
|
59524
|
+
if (!typeSet.has(type.id.toString())) {
|
|
59525
|
+
if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) {
|
|
59526
|
+
// We have seen two distinct unit types which means we should reduce to an
|
|
59527
|
+
// empty intersection. Adding TypeFlags.NonPrimitive causes that to happen.
|
|
59528
|
+
includes |= 67108864 /* NonPrimitive */;
|
|
59529
|
+
}
|
|
59530
|
+
typeSet.set(type.id.toString(), type);
|
|
58935
59531
|
}
|
|
58936
|
-
typeSet.set(type.id.toString(), type);
|
|
58937
59532
|
}
|
|
58938
59533
|
includes |= flags & 205258751 /* IncludesMask */;
|
|
58939
59534
|
}
|
|
@@ -59006,14 +59601,13 @@ var ts;
|
|
|
59006
59601
|
}
|
|
59007
59602
|
return false;
|
|
59008
59603
|
}
|
|
59009
|
-
function
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59013
|
-
|
|
59014
|
-
return
|
|
59604
|
+
function eachIsUnionContaining(types, flag) {
|
|
59605
|
+
return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); });
|
|
59606
|
+
}
|
|
59607
|
+
function removeFromEach(types, flag) {
|
|
59608
|
+
for (var i = 0; i < types.length; i++) {
|
|
59609
|
+
types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
|
|
59015
59610
|
}
|
|
59016
|
-
return false;
|
|
59017
59611
|
}
|
|
59018
59612
|
// If the given list of types contains more than one union of primitive types, replace the
|
|
59019
59613
|
// first with a union containing an intersection of those primitive types, then remove the
|
|
@@ -59122,6 +59716,9 @@ var ts;
|
|
|
59122
59716
|
if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) {
|
|
59123
59717
|
ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
|
|
59124
59718
|
}
|
|
59719
|
+
if (includes & 262144 /* IncludesMissingType */) {
|
|
59720
|
+
typeSet[typeSet.indexOf(undefinedType)] = missingType;
|
|
59721
|
+
}
|
|
59125
59722
|
if (typeSet.length === 0) {
|
|
59126
59723
|
return unknownType;
|
|
59127
59724
|
}
|
|
@@ -59138,10 +59735,13 @@ var ts;
|
|
|
59138
59735
|
// reduced we'll never reduce again, so this occurs at most once.
|
|
59139
59736
|
result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
|
|
59140
59737
|
}
|
|
59141
|
-
else if (
|
|
59142
|
-
|
|
59738
|
+
else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) {
|
|
59739
|
+
var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType;
|
|
59740
|
+
removeFromEach(typeSet, 32768 /* Undefined */);
|
|
59741
|
+
result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
59143
59742
|
}
|
|
59144
|
-
else if (
|
|
59743
|
+
else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) {
|
|
59744
|
+
removeFromEach(typeSet, 65536 /* Null */);
|
|
59145
59745
|
result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
|
|
59146
59746
|
}
|
|
59147
59747
|
else {
|
|
@@ -60874,7 +61474,7 @@ var ts;
|
|
|
60874
61474
|
var mappedTypeVariable = instantiateType(typeVariable, mapper);
|
|
60875
61475
|
if (typeVariable !== mappedTypeVariable) {
|
|
60876
61476
|
return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
|
|
60877
|
-
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t
|
|
61477
|
+
if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
|
|
60878
61478
|
if (!type.declaration.nameType) {
|
|
60879
61479
|
if (isArrayType(t)) {
|
|
60880
61480
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -60916,7 +61516,7 @@ var ts;
|
|
|
60916
61516
|
}
|
|
60917
61517
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
60918
61518
|
var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper);
|
|
60919
|
-
return elementType
|
|
61519
|
+
return isErrorType(elementType) ? errorType :
|
|
60920
61520
|
createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
60921
61521
|
}
|
|
60922
61522
|
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
@@ -62134,7 +62734,7 @@ var ts;
|
|
|
62134
62734
|
path = "" + str;
|
|
62135
62735
|
}
|
|
62136
62736
|
// Otherwise write a dotted name if possible
|
|
62137
|
-
else if (ts.isIdentifierText(str, compilerOptions
|
|
62737
|
+
else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) {
|
|
62138
62738
|
path = path + "." + str;
|
|
62139
62739
|
}
|
|
62140
62740
|
// Failing that, check if the name is already a computed name
|
|
@@ -62498,7 +63098,7 @@ var ts;
|
|
|
62498
63098
|
var targetTypes = target.types;
|
|
62499
63099
|
var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
|
|
62500
63100
|
var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
|
|
62501
|
-
if (intrinsicAttributes
|
|
63101
|
+
if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) &&
|
|
62502
63102
|
(ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
|
|
62503
63103
|
// do not report top error
|
|
62504
63104
|
return result;
|
|
@@ -68013,6 +68613,9 @@ var ts;
|
|
|
68013
68613
|
case 102 /* InstanceOfKeyword */:
|
|
68014
68614
|
return narrowTypeByInstanceof(type, expr, assumeTrue);
|
|
68015
68615
|
case 101 /* InKeyword */:
|
|
68616
|
+
if (ts.isPrivateIdentifier(expr.left)) {
|
|
68617
|
+
return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue);
|
|
68618
|
+
}
|
|
68016
68619
|
var target = getReferenceCandidate(expr.right);
|
|
68017
68620
|
var leftType = getTypeOfNode(expr.left);
|
|
68018
68621
|
if (leftType.flags & 128 /* StringLiteral */) {
|
|
@@ -68042,6 +68645,22 @@ var ts;
|
|
|
68042
68645
|
}
|
|
68043
68646
|
return type;
|
|
68044
68647
|
}
|
|
68648
|
+
function narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue) {
|
|
68649
|
+
var target = getReferenceCandidate(expr.right);
|
|
68650
|
+
if (!isMatchingReference(reference, target)) {
|
|
68651
|
+
return type;
|
|
68652
|
+
}
|
|
68653
|
+
ts.Debug.assertNode(expr.left, ts.isPrivateIdentifier);
|
|
68654
|
+
var symbol = getSymbolForPrivateIdentifierExpression(expr.left);
|
|
68655
|
+
if (symbol === undefined) {
|
|
68656
|
+
return type;
|
|
68657
|
+
}
|
|
68658
|
+
var classSymbol = symbol.parent;
|
|
68659
|
+
var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration"))
|
|
68660
|
+
? getTypeOfSymbol(classSymbol)
|
|
68661
|
+
: getDeclaredTypeOfSymbol(classSymbol);
|
|
68662
|
+
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
|
|
68663
|
+
}
|
|
68045
68664
|
function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
|
|
68046
68665
|
// We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows:
|
|
68047
68666
|
// When operator is === and type of value excludes undefined, null and undefined is removed from type of obj in true branch.
|
|
@@ -69475,8 +70094,7 @@ var ts;
|
|
|
69475
70094
|
if (result) {
|
|
69476
70095
|
return result;
|
|
69477
70096
|
}
|
|
69478
|
-
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) {
|
|
69479
|
-
// This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
70097
|
+
if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name)) { // This is less a contextual type and more an implied shape - in some cases, this may be undesirable
|
|
69480
70098
|
return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false);
|
|
69481
70099
|
}
|
|
69482
70100
|
}
|
|
@@ -70057,7 +70675,7 @@ var ts;
|
|
|
70057
70675
|
var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
|
|
70058
70676
|
propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
|
|
70059
70677
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70060
|
-
if (intrinsicAttribs
|
|
70678
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70061
70679
|
propsType = intersectTypes(intrinsicAttribs, propsType);
|
|
70062
70680
|
}
|
|
70063
70681
|
return propsType;
|
|
@@ -70150,7 +70768,7 @@ var ts;
|
|
|
70150
70768
|
// Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
|
|
70151
70769
|
var apparentAttributesType = attributesType;
|
|
70152
70770
|
var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
|
|
70153
|
-
if (intrinsicClassAttribs
|
|
70771
|
+
if (!isErrorType(intrinsicClassAttribs)) {
|
|
70154
70772
|
var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
|
|
70155
70773
|
var hostClassType = getReturnTypeOfSignature(sig);
|
|
70156
70774
|
apparentAttributesType = intersectTypes(typeParams
|
|
@@ -70158,7 +70776,7 @@ var ts;
|
|
|
70158
70776
|
: intrinsicClassAttribs, apparentAttributesType);
|
|
70159
70777
|
}
|
|
70160
70778
|
var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
|
|
70161
|
-
if (intrinsicAttribs
|
|
70779
|
+
if (!isErrorType(intrinsicAttribs)) {
|
|
70162
70780
|
apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
|
|
70163
70781
|
}
|
|
70164
70782
|
return apparentAttributesType;
|
|
@@ -70626,7 +71244,7 @@ var ts;
|
|
|
70626
71244
|
checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl);
|
|
70627
71245
|
}
|
|
70628
71246
|
offset = propertiesArray.length;
|
|
70629
|
-
if (spread
|
|
71247
|
+
if (isErrorType(spread)) {
|
|
70630
71248
|
continue;
|
|
70631
71249
|
}
|
|
70632
71250
|
spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext);
|
|
@@ -70683,7 +71301,7 @@ var ts;
|
|
|
70683
71301
|
}
|
|
70684
71302
|
}
|
|
70685
71303
|
}
|
|
70686
|
-
if (spread
|
|
71304
|
+
if (isErrorType(spread)) {
|
|
70687
71305
|
return errorType;
|
|
70688
71306
|
}
|
|
70689
71307
|
if (spread !== emptyObjectType) {
|
|
@@ -70950,7 +71568,7 @@ var ts;
|
|
|
70950
71568
|
var links = getNodeLinks(node);
|
|
70951
71569
|
if (!links.resolvedSymbol) {
|
|
70952
71570
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
|
|
70953
|
-
if (intrinsicElementsType
|
|
71571
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
70954
71572
|
// Property case
|
|
70955
71573
|
if (!ts.isIdentifier(node.tagName))
|
|
70956
71574
|
return ts.Debug.fail();
|
|
@@ -71113,7 +71731,7 @@ var ts;
|
|
|
71113
71731
|
// var CustomTag: "h1" = "h1";
|
|
71114
71732
|
// <CustomTag> Hello World </CustomTag>
|
|
71115
71733
|
var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
|
|
71116
|
-
if (intrinsicElementsType
|
|
71734
|
+
if (!isErrorType(intrinsicElementsType)) {
|
|
71117
71735
|
var stringLiteralTypeName = type.value;
|
|
71118
71736
|
var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
|
|
71119
71737
|
if (intrinsicProp) {
|
|
@@ -71181,7 +71799,7 @@ var ts;
|
|
|
71181
71799
|
}
|
|
71182
71800
|
function getJsxElementClassTypeAt(location) {
|
|
71183
71801
|
var type = getJsxType(JsxNames.ElementClass, location);
|
|
71184
|
-
if (type
|
|
71802
|
+
if (isErrorType(type))
|
|
71185
71803
|
return undefined;
|
|
71186
71804
|
return type;
|
|
71187
71805
|
}
|
|
@@ -71487,7 +72105,7 @@ var ts;
|
|
|
71487
72105
|
}
|
|
71488
72106
|
function checkNonNullNonVoidType(type, node) {
|
|
71489
72107
|
var nonNullType = checkNonNullType(type, node);
|
|
71490
|
-
if (nonNullType
|
|
72108
|
+
if (nonNullType.flags & 16384 /* Void */) {
|
|
71491
72109
|
error(node, ts.Diagnostics.Object_is_possibly_undefined);
|
|
71492
72110
|
}
|
|
71493
72111
|
return nonNullType;
|
|
@@ -71522,6 +72140,36 @@ var ts;
|
|
|
71522
72140
|
}
|
|
71523
72141
|
}
|
|
71524
72142
|
}
|
|
72143
|
+
function checkGrammarPrivateIdentifierExpression(privId) {
|
|
72144
|
+
if (!ts.getContainingClass(privId)) {
|
|
72145
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
72146
|
+
}
|
|
72147
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72148
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression);
|
|
72149
|
+
}
|
|
72150
|
+
if (!getSymbolForPrivateIdentifierExpression(privId)) {
|
|
72151
|
+
return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId));
|
|
72152
|
+
}
|
|
72153
|
+
return false;
|
|
72154
|
+
}
|
|
72155
|
+
function checkPrivateIdentifierExpression(privId) {
|
|
72156
|
+
checkGrammarPrivateIdentifierExpression(privId);
|
|
72157
|
+
var symbol = getSymbolForPrivateIdentifierExpression(privId);
|
|
72158
|
+
if (symbol) {
|
|
72159
|
+
markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false);
|
|
72160
|
+
}
|
|
72161
|
+
return anyType;
|
|
72162
|
+
}
|
|
72163
|
+
function getSymbolForPrivateIdentifierExpression(privId) {
|
|
72164
|
+
if (!ts.isExpressionNode(privId)) {
|
|
72165
|
+
return undefined;
|
|
72166
|
+
}
|
|
72167
|
+
var links = getNodeLinks(privId);
|
|
72168
|
+
if (links.resolvedSymbol === undefined) {
|
|
72169
|
+
links.resolvedSymbol = lookupSymbolForPrivateIdentifierDeclaration(privId.escapedText, privId);
|
|
72170
|
+
}
|
|
72171
|
+
return links.resolvedSymbol;
|
|
72172
|
+
}
|
|
71525
72173
|
function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
|
|
71526
72174
|
return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
|
|
71527
72175
|
}
|
|
@@ -71585,7 +72233,7 @@ var ts;
|
|
|
71585
72233
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
71586
72234
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
71587
72235
|
}
|
|
71588
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions
|
|
72236
|
+
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
71589
72237
|
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
71590
72238
|
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
71591
72239
|
if (n === lexicalClass_1)
|
|
@@ -71604,7 +72252,7 @@ var ts;
|
|
|
71604
72252
|
}
|
|
71605
72253
|
if (isAnyLike) {
|
|
71606
72254
|
if (lexicallyScopedSymbol) {
|
|
71607
|
-
return apparentType;
|
|
72255
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
71608
72256
|
}
|
|
71609
72257
|
if (!ts.getContainingClass(right)) {
|
|
71610
72258
|
grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -71628,7 +72276,8 @@ var ts;
|
|
|
71628
72276
|
if (ts.isIdentifier(left) && parentSymbol) {
|
|
71629
72277
|
markAliasReferenced(parentSymbol, node);
|
|
71630
72278
|
}
|
|
71631
|
-
return apparentType;
|
|
72279
|
+
return isErrorType(apparentType) ? errorType : apparentType;
|
|
72280
|
+
;
|
|
71632
72281
|
}
|
|
71633
72282
|
prop = getPropertyOfType(apparentType, right.escapedText);
|
|
71634
72283
|
}
|
|
@@ -72087,7 +72736,7 @@ var ts;
|
|
|
72087
72736
|
}
|
|
72088
72737
|
function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
|
|
72089
72738
|
// Short-circuiting for improved performance.
|
|
72090
|
-
if (
|
|
72739
|
+
if (isTypeAny(type)) {
|
|
72091
72740
|
return true;
|
|
72092
72741
|
}
|
|
72093
72742
|
var prop = getPropertyOfType(type, propertyName);
|
|
@@ -72105,7 +72754,7 @@ var ts;
|
|
|
72105
72754
|
*/
|
|
72106
72755
|
function isPropertyAccessible(node, isSuper, isWrite, containingType, property) {
|
|
72107
72756
|
// Short-circuiting for improved performance.
|
|
72108
|
-
if (
|
|
72757
|
+
if (isTypeAny(containingType)) {
|
|
72109
72758
|
return true;
|
|
72110
72759
|
}
|
|
72111
72760
|
// A #private property access in an optional chain is an error dealt with by the parser.
|
|
@@ -72176,7 +72825,7 @@ var ts;
|
|
|
72176
72825
|
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
|
|
72177
72826
|
var indexExpression = node.argumentExpression;
|
|
72178
72827
|
var indexType = checkExpression(indexExpression);
|
|
72179
|
-
if (objectType
|
|
72828
|
+
if (isErrorType(objectType) || objectType === silentNeverType) {
|
|
72180
72829
|
return objectType;
|
|
72181
72830
|
}
|
|
72182
72831
|
if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
|
|
@@ -72421,7 +73070,7 @@ var ts;
|
|
|
72421
73070
|
// 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the
|
|
72422
73071
|
// return type of 'wrap'.
|
|
72423
73072
|
if (node.kind !== 164 /* Decorator */) {
|
|
72424
|
-
var contextualType = getContextualType(node, 8 /* SkipBindingPatterns */);
|
|
73073
|
+
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
72425
73074
|
if (contextualType) {
|
|
72426
73075
|
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
72427
73076
|
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
@@ -73370,7 +74019,7 @@ var ts;
|
|
|
73370
74019
|
}
|
|
73371
74020
|
return anySignature;
|
|
73372
74021
|
}
|
|
73373
|
-
if (superType
|
|
74022
|
+
if (!isErrorType(superType)) {
|
|
73374
74023
|
// In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated
|
|
73375
74024
|
// with the type arguments specified in the extends clause.
|
|
73376
74025
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
|
|
@@ -73398,7 +74047,7 @@ var ts;
|
|
|
73398
74047
|
return silentNeverSignature;
|
|
73399
74048
|
}
|
|
73400
74049
|
var apparentType = getApparentType(funcType);
|
|
73401
|
-
if (apparentType
|
|
74050
|
+
if (isErrorType(apparentType)) {
|
|
73402
74051
|
// Another error has already been reported
|
|
73403
74052
|
return resolveErrorCall(node);
|
|
73404
74053
|
}
|
|
@@ -73414,7 +74063,7 @@ var ts;
|
|
|
73414
74063
|
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
|
|
73415
74064
|
// The unknownType indicates that an error already occurred (and was reported). No
|
|
73416
74065
|
// need to report another error in this case.
|
|
73417
|
-
if (funcType
|
|
74066
|
+
if (!isErrorType(funcType) && node.typeArguments) {
|
|
73418
74067
|
error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
|
|
73419
74068
|
}
|
|
73420
74069
|
return resolveUntypedCall(node);
|
|
@@ -73491,7 +74140,7 @@ var ts;
|
|
|
73491
74140
|
// signatures for overload resolution. The result type of the function call becomes
|
|
73492
74141
|
// the result type of the operation.
|
|
73493
74142
|
expressionType = getApparentType(expressionType);
|
|
73494
|
-
if (expressionType
|
|
74143
|
+
if (isErrorType(expressionType)) {
|
|
73495
74144
|
// Another error has already been reported
|
|
73496
74145
|
return resolveErrorCall(node);
|
|
73497
74146
|
}
|
|
@@ -73706,7 +74355,7 @@ var ts;
|
|
|
73706
74355
|
function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
|
|
73707
74356
|
var tagType = checkExpression(node.tag);
|
|
73708
74357
|
var apparentType = getApparentType(tagType);
|
|
73709
|
-
if (apparentType
|
|
74358
|
+
if (isErrorType(apparentType)) {
|
|
73710
74359
|
// Another error has already been reported
|
|
73711
74360
|
return resolveErrorCall(node);
|
|
73712
74361
|
}
|
|
@@ -73752,7 +74401,7 @@ var ts;
|
|
|
73752
74401
|
function resolveDecorator(node, candidatesOutArray, checkMode) {
|
|
73753
74402
|
var funcType = checkExpression(node.expression);
|
|
73754
74403
|
var apparentType = getApparentType(funcType);
|
|
73755
|
-
if (apparentType
|
|
74404
|
+
if (isErrorType(apparentType)) {
|
|
73756
74405
|
return resolveErrorCall(node);
|
|
73757
74406
|
}
|
|
73758
74407
|
var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */);
|
|
@@ -73807,7 +74456,7 @@ var ts;
|
|
|
73807
74456
|
}
|
|
73808
74457
|
var exprTypes = checkExpression(node.tagName);
|
|
73809
74458
|
var apparentType = getApparentType(exprTypes);
|
|
73810
|
-
if (apparentType
|
|
74459
|
+
if (isErrorType(apparentType)) {
|
|
73811
74460
|
return resolveErrorCall(node);
|
|
73812
74461
|
}
|
|
73813
74462
|
var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
|
|
@@ -74130,7 +74779,7 @@ var ts;
|
|
|
74130
74779
|
}
|
|
74131
74780
|
function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
|
|
74132
74781
|
var _a;
|
|
74133
|
-
if (allowSyntheticDefaultImports && type && type
|
|
74782
|
+
if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
|
|
74134
74783
|
var synthType = type;
|
|
74135
74784
|
if (!synthType.syntheticType) {
|
|
74136
74785
|
var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
|
|
@@ -74193,6 +74842,12 @@ var ts;
|
|
|
74193
74842
|
return getReturnTypeOfSignature(signature);
|
|
74194
74843
|
}
|
|
74195
74844
|
function checkAssertion(node) {
|
|
74845
|
+
if (node.kind === 210 /* TypeAssertionExpression */) {
|
|
74846
|
+
var file = ts.getSourceFileOfNode(node);
|
|
74847
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) {
|
|
74848
|
+
grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead);
|
|
74849
|
+
}
|
|
74850
|
+
}
|
|
74196
74851
|
return checkAssertionWorker(node, node.type, node.expression);
|
|
74197
74852
|
}
|
|
74198
74853
|
function isValidConstAssertionArgument(node) {
|
|
@@ -74236,7 +74891,7 @@ var ts;
|
|
|
74236
74891
|
checkSourceElement(type);
|
|
74237
74892
|
exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
|
|
74238
74893
|
var targetType = getTypeFromTypeNode(type);
|
|
74239
|
-
if (produceDiagnostics && targetType
|
|
74894
|
+
if (produceDiagnostics && !isErrorType(targetType)) {
|
|
74240
74895
|
var widenedType = getWidenedType(exprType);
|
|
74241
74896
|
if (!isTypeComparableTo(targetType, widenedType)) {
|
|
74242
74897
|
checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
|
|
@@ -74269,7 +74924,7 @@ var ts;
|
|
|
74269
74924
|
return getGlobalImportMetaExpressionType();
|
|
74270
74925
|
case 103 /* NewKeyword */:
|
|
74271
74926
|
var type = checkNewTargetMetaProperty(node);
|
|
74272
|
-
return type
|
|
74927
|
+
return isErrorType(type) ? errorType : createNewTargetExpressionType(type);
|
|
74273
74928
|
default:
|
|
74274
74929
|
ts.Debug.assertNever(node.keywordToken);
|
|
74275
74930
|
}
|
|
@@ -74291,7 +74946,14 @@ var ts;
|
|
|
74291
74946
|
}
|
|
74292
74947
|
function checkImportMetaProperty(node) {
|
|
74293
74948
|
if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
|
|
74294
|
-
|
|
74949
|
+
if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
|
|
74950
|
+
if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
74951
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output);
|
|
74952
|
+
}
|
|
74953
|
+
}
|
|
74954
|
+
else {
|
|
74955
|
+
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext);
|
|
74956
|
+
}
|
|
74295
74957
|
}
|
|
74296
74958
|
var file = ts.getSourceFileOfNode(node);
|
|
74297
74959
|
ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
@@ -75235,9 +75897,9 @@ var ts;
|
|
|
75235
75897
|
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);
|
|
75236
75898
|
diagnostics.add(diagnostic);
|
|
75237
75899
|
}
|
|
75238
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
75900
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
75239
75901
|
span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
|
|
75240
|
-
var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.
|
|
75902
|
+
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);
|
|
75241
75903
|
diagnostics.add(diagnostic);
|
|
75242
75904
|
}
|
|
75243
75905
|
}
|
|
@@ -75262,7 +75924,7 @@ var ts;
|
|
|
75262
75924
|
}
|
|
75263
75925
|
var operandType = checkExpression(node.expression);
|
|
75264
75926
|
var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
|
|
75265
|
-
if (awaitedType === operandType && awaitedType
|
|
75927
|
+
if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) {
|
|
75266
75928
|
addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
|
|
75267
75929
|
}
|
|
75268
75930
|
return awaitedType;
|
|
@@ -75411,11 +76073,29 @@ var ts;
|
|
|
75411
76073
|
if (leftType === silentNeverType || rightType === silentNeverType) {
|
|
75412
76074
|
return silentNeverType;
|
|
75413
76075
|
}
|
|
75414
|
-
|
|
76076
|
+
if (ts.isPrivateIdentifier(left)) {
|
|
76077
|
+
if (languageVersion < 99 /* ESNext */) {
|
|
76078
|
+
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
76079
|
+
}
|
|
76080
|
+
// Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type
|
|
76081
|
+
// which provides us with the opportunity to emit more detailed errors
|
|
76082
|
+
if (!getNodeLinks(left).resolvedSymbol && ts.getContainingClass(left)) {
|
|
76083
|
+
var isUncheckedJS = isUncheckedJSSuggestion(left, rightType.symbol, /*excludeClasses*/ true);
|
|
76084
|
+
reportNonexistentProperty(left, rightType, isUncheckedJS);
|
|
76085
|
+
}
|
|
76086
|
+
}
|
|
76087
|
+
else {
|
|
76088
|
+
leftType = checkNonNullType(leftType, left);
|
|
76089
|
+
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
76090
|
+
// Require the left operand to be of type Any, the String primitive type, or the Number primitive type.
|
|
76091
|
+
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
76092
|
+
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
76093
|
+
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol);
|
|
76094
|
+
}
|
|
76095
|
+
}
|
|
75415
76096
|
rightType = checkNonNullType(rightType, right);
|
|
75416
76097
|
// TypeScript 1.0 spec (April 2014): 4.15.5
|
|
75417
|
-
// The in operator requires the
|
|
75418
|
-
// and the right operand to be
|
|
76098
|
+
// The in operator requires the right operand to be
|
|
75419
76099
|
//
|
|
75420
76100
|
// 1. assignable to the non-primitive type,
|
|
75421
76101
|
// 2. an unconstrained type parameter,
|
|
@@ -75433,10 +76113,6 @@ var ts;
|
|
|
75433
76113
|
// unless *all* instantiations would result in an error.
|
|
75434
76114
|
//
|
|
75435
76115
|
// The result is always of the Boolean primitive type.
|
|
75436
|
-
if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) ||
|
|
75437
|
-
isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) {
|
|
75438
|
-
error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
|
|
75439
|
-
}
|
|
75440
76116
|
var rightTypeConstraint = getConstraintOfType(rightType);
|
|
75441
76117
|
if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
75442
76118
|
rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) ||
|
|
@@ -75903,7 +76579,7 @@ var ts;
|
|
|
75903
76579
|
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
|
|
75904
76580
|
// Otherwise, the result is of type Any.
|
|
75905
76581
|
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
|
|
75906
|
-
resultType = leftType
|
|
76582
|
+
resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType;
|
|
75907
76583
|
}
|
|
75908
76584
|
// Symbols are not allowed at all in arithmetic expressions
|
|
75909
76585
|
if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
|
|
@@ -76682,6 +77358,8 @@ var ts;
|
|
|
76682
77358
|
switch (kind) {
|
|
76683
77359
|
case 79 /* Identifier */:
|
|
76684
77360
|
return checkIdentifier(node, checkMode);
|
|
77361
|
+
case 80 /* PrivateIdentifier */:
|
|
77362
|
+
return checkPrivateIdentifierExpression(node);
|
|
76685
77363
|
case 108 /* ThisKeyword */:
|
|
76686
77364
|
return checkThisExpression(node);
|
|
76687
77365
|
case 106 /* SuperKeyword */:
|
|
@@ -77275,7 +77953,7 @@ var ts;
|
|
|
77275
77953
|
// - The containing class is a derived class.
|
|
77276
77954
|
// - The constructor declares parameter properties
|
|
77277
77955
|
// or the containing class declares instance member variables with initializers.
|
|
77278
|
-
var superCallShouldBeFirst = (compilerOptions
|
|
77956
|
+
var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
77279
77957
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
77280
77958
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
77281
77959
|
// Skip past any prologue directives to find the first statement
|
|
@@ -77381,7 +78059,7 @@ var ts;
|
|
|
77381
78059
|
}
|
|
77382
78060
|
function getTypeParametersForTypeReference(node) {
|
|
77383
78061
|
var type = getTypeFromTypeReference(node);
|
|
77384
|
-
if (type
|
|
78062
|
+
if (!isErrorType(type)) {
|
|
77385
78063
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
77386
78064
|
if (symbol) {
|
|
77387
78065
|
return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters ||
|
|
@@ -77397,7 +78075,7 @@ var ts;
|
|
|
77397
78075
|
}
|
|
77398
78076
|
ts.forEach(node.typeArguments, checkSourceElement);
|
|
77399
78077
|
var type = getTypeFromTypeReference(node);
|
|
77400
|
-
if (type
|
|
78078
|
+
if (!isErrorType(type)) {
|
|
77401
78079
|
if (node.typeArguments && produceDiagnostics) {
|
|
77402
78080
|
var typeParameters = getTypeParametersForTypeReference(node);
|
|
77403
78081
|
if (typeParameters) {
|
|
@@ -78223,7 +78901,7 @@ var ts;
|
|
|
78223
78901
|
//
|
|
78224
78902
|
var returnType = getTypeFromTypeNode(returnTypeNode);
|
|
78225
78903
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
78226
|
-
if (returnType
|
|
78904
|
+
if (isErrorType(returnType)) {
|
|
78227
78905
|
return;
|
|
78228
78906
|
}
|
|
78229
78907
|
var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true);
|
|
@@ -78237,7 +78915,7 @@ var ts;
|
|
|
78237
78915
|
else {
|
|
78238
78916
|
// Always mark the type node as referenced if it points to a value
|
|
78239
78917
|
markTypeNodeAsReferenced(returnTypeNode);
|
|
78240
|
-
if (returnType
|
|
78918
|
+
if (isErrorType(returnType)) {
|
|
78241
78919
|
return;
|
|
78242
78920
|
}
|
|
78243
78921
|
var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
|
|
@@ -78247,7 +78925,7 @@ var ts;
|
|
|
78247
78925
|
}
|
|
78248
78926
|
var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true);
|
|
78249
78927
|
var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
|
|
78250
|
-
if (promiseConstructorType
|
|
78928
|
+
if (isErrorType(promiseConstructorType)) {
|
|
78251
78929
|
if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) {
|
|
78252
78930
|
error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
78253
78931
|
}
|
|
@@ -79019,7 +79697,7 @@ var ts;
|
|
|
79019
79697
|
}
|
|
79020
79698
|
function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
|
|
79021
79699
|
// No need to check for require or exports for ES6 modules and later
|
|
79022
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
79700
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
79023
79701
|
return;
|
|
79024
79702
|
}
|
|
79025
79703
|
if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
|
@@ -79299,7 +79977,7 @@ var ts;
|
|
|
79299
79977
|
// Node is a secondary declaration, check that type is identical to primary declaration and check that
|
|
79300
79978
|
// initializer is consistent with type associated with the node
|
|
79301
79979
|
var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
|
|
79302
|
-
if (type
|
|
79980
|
+
if (!isErrorType(type) && !isErrorType(declarationType) &&
|
|
79303
79981
|
!isTypeIdenticalTo(type, declarationType) &&
|
|
79304
79982
|
!(symbol.flags & 67108864 /* Assignment */)) {
|
|
79305
79983
|
errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
|
|
@@ -80580,8 +81258,8 @@ var ts;
|
|
|
80580
81258
|
* The name cannot be used as 'Object' of user defined types with special target.
|
|
80581
81259
|
*/
|
|
80582
81260
|
function checkClassNameCollisionWithObject(name) {
|
|
80583
|
-
if (languageVersion
|
|
80584
|
-
&& moduleKind < ts.ModuleKind.ES2015) {
|
|
81261
|
+
if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object"
|
|
81262
|
+
&& (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
80585
81263
|
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
|
|
80586
81264
|
}
|
|
80587
81265
|
}
|
|
@@ -80797,7 +81475,7 @@ var ts;
|
|
|
80797
81475
|
checkTypeReferenceNode(typeRefNode);
|
|
80798
81476
|
if (produceDiagnostics) {
|
|
80799
81477
|
var t = getReducedType(getTypeFromTypeNode(typeRefNode));
|
|
80800
|
-
if (t
|
|
81478
|
+
if (!isErrorType(t)) {
|
|
80801
81479
|
if (isValidBaseType(t)) {
|
|
80802
81480
|
var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ?
|
|
80803
81481
|
ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
|
|
@@ -81751,8 +82429,8 @@ var ts;
|
|
|
81751
82429
|
checkAliasSymbol(node);
|
|
81752
82430
|
if (node.kind === 269 /* ImportSpecifier */ &&
|
|
81753
82431
|
ts.idText(node.propertyName || node.name) === "default" &&
|
|
81754
|
-
compilerOptions
|
|
81755
|
-
moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82432
|
+
ts.getESModuleInterop(compilerOptions) &&
|
|
82433
|
+
moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81756
82434
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81757
82435
|
}
|
|
81758
82436
|
}
|
|
@@ -81784,7 +82462,7 @@ var ts;
|
|
|
81784
82462
|
if (importClause.namedBindings) {
|
|
81785
82463
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
81786
82464
|
checkImportBinding(importClause.namedBindings);
|
|
81787
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions
|
|
82465
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) {
|
|
81788
82466
|
// import * as ns from "foo";
|
|
81789
82467
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81790
82468
|
}
|
|
@@ -81830,7 +82508,7 @@ var ts;
|
|
|
81830
82508
|
}
|
|
81831
82509
|
}
|
|
81832
82510
|
else {
|
|
81833
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
82511
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) {
|
|
81834
82512
|
// Import equals declaration is deprecated in es6 or above
|
|
81835
82513
|
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);
|
|
81836
82514
|
}
|
|
@@ -81846,7 +82524,7 @@ var ts;
|
|
|
81846
82524
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
81847
82525
|
}
|
|
81848
82526
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
81849
|
-
checkExternalEmitHelpers(node,
|
|
82527
|
+
checkExternalEmitHelpers(node, 4194304 /* CreateBinding */);
|
|
81850
82528
|
}
|
|
81851
82529
|
checkGrammarExportDeclaration(node);
|
|
81852
82530
|
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
|
|
@@ -81871,12 +82549,12 @@ var ts;
|
|
|
81871
82549
|
else if (node.exportClause) {
|
|
81872
82550
|
checkAliasSymbol(node.exportClause);
|
|
81873
82551
|
}
|
|
81874
|
-
if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
|
|
82552
|
+
if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) {
|
|
81875
82553
|
if (node.exportClause) {
|
|
81876
82554
|
// export * as ns from "foo";
|
|
81877
82555
|
// 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.
|
|
81878
82556
|
// We only use the helper here when in esModuleInterop
|
|
81879
|
-
if (compilerOptions
|
|
82557
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
81880
82558
|
checkExternalEmitHelpers(node, 65536 /* ImportStar */);
|
|
81881
82559
|
}
|
|
81882
82560
|
}
|
|
@@ -81960,9 +82638,9 @@ var ts;
|
|
|
81960
82638
|
}
|
|
81961
82639
|
}
|
|
81962
82640
|
else {
|
|
81963
|
-
if (compilerOptions
|
|
82641
|
+
if (ts.getESModuleInterop(compilerOptions) &&
|
|
81964
82642
|
moduleKind !== ts.ModuleKind.System &&
|
|
81965
|
-
moduleKind < ts.ModuleKind.ES2015 &&
|
|
82643
|
+
(moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) &&
|
|
81966
82644
|
ts.idText(node.propertyName || node.name) === "default") {
|
|
81967
82645
|
checkExternalEmitHelpers(node, 131072 /* ImportDefault */);
|
|
81968
82646
|
}
|
|
@@ -82021,7 +82699,7 @@ var ts;
|
|
|
82021
82699
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
82022
82700
|
}
|
|
82023
82701
|
if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) {
|
|
82024
|
-
if (moduleKind >= ts.ModuleKind.ES2015) {
|
|
82702
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
82025
82703
|
// export assignment is not supported in es6 modules
|
|
82026
82704
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
82027
82705
|
}
|
|
@@ -82815,6 +83493,9 @@ var ts;
|
|
|
82815
83493
|
}
|
|
82816
83494
|
return result;
|
|
82817
83495
|
}
|
|
83496
|
+
else if (ts.isPrivateIdentifier(name)) {
|
|
83497
|
+
return getSymbolForPrivateIdentifierExpression(name);
|
|
83498
|
+
}
|
|
82818
83499
|
else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) {
|
|
82819
83500
|
var links = getNodeLinks(name);
|
|
82820
83501
|
if (links.resolvedSymbol) {
|
|
@@ -82837,7 +83518,8 @@ var ts;
|
|
|
82837
83518
|
}
|
|
82838
83519
|
else if (isTypeReferenceIdentifier(name)) {
|
|
82839
83520
|
var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */;
|
|
82840
|
-
|
|
83521
|
+
var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true);
|
|
83522
|
+
return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name);
|
|
82841
83523
|
}
|
|
82842
83524
|
if (name.parent.kind === 176 /* TypePredicate */) {
|
|
82843
83525
|
return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */);
|
|
@@ -83064,7 +83746,7 @@ var ts;
|
|
|
83064
83746
|
var symbol = getSymbolAtLocation(node);
|
|
83065
83747
|
if (symbol) {
|
|
83066
83748
|
var declaredType = getDeclaredTypeOfSymbol(symbol);
|
|
83067
|
-
return declaredType
|
|
83749
|
+
return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol);
|
|
83068
83750
|
}
|
|
83069
83751
|
}
|
|
83070
83752
|
if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
@@ -83562,7 +84244,7 @@ var ts;
|
|
|
83562
84244
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83563
84245
|
}
|
|
83564
84246
|
var type = getDeclaredTypeOfSymbol(typeSymbol);
|
|
83565
|
-
if (type
|
|
84247
|
+
if (isErrorType(type)) {
|
|
83566
84248
|
return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
|
|
83567
84249
|
}
|
|
83568
84250
|
else if (type.flags & 3 /* AnyOrUnknown */) {
|
|
@@ -84074,7 +84756,7 @@ var ts;
|
|
|
84074
84756
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
84075
84757
|
if (helpersModule !== unknownSymbol) {
|
|
84076
84758
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
84077
|
-
for (var helper = 1 /* FirstEmitHelper */; helper <=
|
|
84759
|
+
for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) {
|
|
84078
84760
|
if (uncheckedHelpers & helper) {
|
|
84079
84761
|
var name = getHelperName(helper);
|
|
84080
84762
|
var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */);
|
|
@@ -84126,7 +84808,8 @@ var ts;
|
|
|
84126
84808
|
case 262144 /* MakeTemplateObject */: return "__makeTemplateObject";
|
|
84127
84809
|
case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet";
|
|
84128
84810
|
case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet";
|
|
84129
|
-
case 2097152 /*
|
|
84811
|
+
case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn";
|
|
84812
|
+
case 4194304 /* CreateBinding */: return "__createBinding";
|
|
84130
84813
|
default: return ts.Debug.fail("Unrecognized helper");
|
|
84131
84814
|
}
|
|
84132
84815
|
}
|
|
@@ -84558,6 +85241,11 @@ var ts;
|
|
|
84558
85241
|
if (!ts.isArrowFunction(node)) {
|
|
84559
85242
|
return false;
|
|
84560
85243
|
}
|
|
85244
|
+
if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) {
|
|
85245
|
+
if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) {
|
|
85246
|
+
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);
|
|
85247
|
+
}
|
|
85248
|
+
}
|
|
84561
85249
|
var equalsGreaterThanToken = node.equalsGreaterThanToken;
|
|
84562
85250
|
var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
|
|
84563
85251
|
var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
|
|
@@ -84890,8 +85578,8 @@ var ts;
|
|
|
84890
85578
|
if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
|
|
84891
85579
|
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));
|
|
84892
85580
|
}
|
|
84893
|
-
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) {
|
|
84894
|
-
diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.
|
|
85581
|
+
if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) {
|
|
85582
|
+
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));
|
|
84895
85583
|
}
|
|
84896
85584
|
}
|
|
84897
85585
|
}
|
|
@@ -85232,8 +85920,7 @@ var ts;
|
|
|
85232
85920
|
: ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
|
|
85233
85921
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
85234
85922
|
}
|
|
85235
|
-
|
|
85236
|
-
if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
|
|
85923
|
+
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
85237
85924
|
!(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
85238
85925
|
checkESModuleMarker(node.name);
|
|
85239
85926
|
}
|
|
@@ -85568,7 +86255,7 @@ var ts;
|
|
|
85568
86255
|
}
|
|
85569
86256
|
function checkGrammarImportCallExpression(node) {
|
|
85570
86257
|
if (moduleKind === ts.ModuleKind.ES2015) {
|
|
85571
|
-
return grammarErrorOnNode(node, ts.Diagnostics.
|
|
86258
|
+
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);
|
|
85572
86259
|
}
|
|
85573
86260
|
if (node.typeArguments) {
|
|
85574
86261
|
return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
|
|
@@ -90728,7 +91415,7 @@ var ts;
|
|
|
90728
91415
|
function transformSourceFile(node) {
|
|
90729
91416
|
var options = context.getCompilerOptions();
|
|
90730
91417
|
if (node.isDeclarationFile
|
|
90731
|
-
|| useDefineForClassFields && options
|
|
91418
|
+
|| useDefineForClassFields && ts.getEmitScriptTarget(options) === 99 /* ESNext */) {
|
|
90732
91419
|
return node;
|
|
90733
91420
|
}
|
|
90734
91421
|
var visited = ts.visitEachChild(node, visitor, context);
|
|
@@ -90816,14 +91503,37 @@ var ts;
|
|
|
90816
91503
|
}
|
|
90817
91504
|
/**
|
|
90818
91505
|
* If we visit a private name, this means it is an undeclared private name.
|
|
90819
|
-
* Replace it with an empty identifier to indicate a problem with the code
|
|
91506
|
+
* Replace it with an empty identifier to indicate a problem with the code,
|
|
91507
|
+
* unless we are in a statement position - otherwise this will not trigger
|
|
91508
|
+
* a SyntaxError.
|
|
90820
91509
|
*/
|
|
90821
91510
|
function visitPrivateIdentifier(node) {
|
|
90822
91511
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
90823
91512
|
return node;
|
|
90824
91513
|
}
|
|
91514
|
+
if (ts.isStatement(node.parent)) {
|
|
91515
|
+
return node;
|
|
91516
|
+
}
|
|
90825
91517
|
return ts.setOriginalNode(factory.createIdentifier(""), node);
|
|
90826
91518
|
}
|
|
91519
|
+
/**
|
|
91520
|
+
* Visits `#id in expr`
|
|
91521
|
+
*/
|
|
91522
|
+
function visitPrivateIdentifierInInExpression(node) {
|
|
91523
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
91524
|
+
return node;
|
|
91525
|
+
}
|
|
91526
|
+
var privId = node.left;
|
|
91527
|
+
ts.Debug.assertNode(privId, ts.isPrivateIdentifier);
|
|
91528
|
+
ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */);
|
|
91529
|
+
var info = accessPrivateIdentifier(privId);
|
|
91530
|
+
if (info) {
|
|
91531
|
+
var receiver = ts.visitNode(node.right, visitor, ts.isExpression);
|
|
91532
|
+
return ts.setOriginalNode(context.getEmitHelperFactory().createClassPrivateFieldInHelper(info.brandCheckIdentifier, receiver), node);
|
|
91533
|
+
}
|
|
91534
|
+
// Private name has not been declared. Subsequent transformers will handle this error
|
|
91535
|
+
return ts.visitEachChild(node, visitor, context);
|
|
91536
|
+
}
|
|
90827
91537
|
/**
|
|
90828
91538
|
* Visits the members of a class that has fields.
|
|
90829
91539
|
*
|
|
@@ -91210,6 +91920,9 @@ var ts;
|
|
|
91210
91920
|
}
|
|
91211
91921
|
}
|
|
91212
91922
|
}
|
|
91923
|
+
if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) {
|
|
91924
|
+
return visitPrivateIdentifierInInExpression(node);
|
|
91925
|
+
}
|
|
91213
91926
|
return ts.visitEachChild(node, visitor, context);
|
|
91214
91927
|
}
|
|
91215
91928
|
function createPrivateIdentifierAssignment(info, receiver, right, operator) {
|
|
@@ -94104,7 +94817,7 @@ var ts;
|
|
|
94104
94817
|
// When there are no attributes, React wants "null"
|
|
94105
94818
|
}
|
|
94106
94819
|
else {
|
|
94107
|
-
var target = compilerOptions
|
|
94820
|
+
var target = ts.getEmitScriptTarget(compilerOptions);
|
|
94108
94821
|
if (target && target >= 5 /* ES2018 */) {
|
|
94109
94822
|
objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) {
|
|
94110
94823
|
return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement);
|
|
@@ -94303,7 +95016,8 @@ var ts;
|
|
|
94303
95016
|
}
|
|
94304
95017
|
}
|
|
94305
95018
|
function visitJsxExpression(node) {
|
|
94306
|
-
|
|
95019
|
+
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
95020
|
+
return node.dotDotDotToken ? factory.createSpreadElement(expression) : expression;
|
|
94307
95021
|
}
|
|
94308
95022
|
}
|
|
94309
95023
|
ts.transformJsx = transformJsx;
|
|
@@ -100939,7 +101653,7 @@ var ts;
|
|
|
100939
101653
|
case 348 /* PartiallyEmittedExpression */:
|
|
100940
101654
|
return visitPartiallyEmittedExpression(node, valueIsDiscarded);
|
|
100941
101655
|
case 207 /* CallExpression */:
|
|
100942
|
-
if (ts.isImportCall(node)) {
|
|
101656
|
+
if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) {
|
|
100943
101657
|
return visitImportCallExpression(node);
|
|
100944
101658
|
}
|
|
100945
101659
|
break;
|
|
@@ -101162,7 +101876,7 @@ var ts;
|
|
|
101162
101876
|
}
|
|
101163
101877
|
}
|
|
101164
101878
|
var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
|
101165
|
-
if (compilerOptions
|
|
101879
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
101166
101880
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
|
|
101167
101881
|
}
|
|
101168
101882
|
return promise;
|
|
@@ -101175,7 +101889,7 @@ var ts;
|
|
|
101175
101889
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
101176
101890
|
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
|
101177
101891
|
var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
|
101178
|
-
if (compilerOptions
|
|
101892
|
+
if (ts.getESModuleInterop(compilerOptions)) {
|
|
101179
101893
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
101180
101894
|
}
|
|
101181
101895
|
var func;
|
|
@@ -101205,7 +101919,7 @@ var ts;
|
|
|
101205
101919
|
return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
101206
101920
|
}
|
|
101207
101921
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
101208
|
-
if (!compilerOptions
|
|
101922
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101209
101923
|
return innerExpr;
|
|
101210
101924
|
}
|
|
101211
101925
|
if (ts.getExportNeedsImportStarHelper(node)) {
|
|
@@ -101214,7 +101928,7 @@ var ts;
|
|
|
101214
101928
|
return innerExpr;
|
|
101215
101929
|
}
|
|
101216
101930
|
function getHelperExpressionForImport(node, innerExpr) {
|
|
101217
|
-
if (!compilerOptions
|
|
101931
|
+
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) {
|
|
101218
101932
|
return innerExpr;
|
|
101219
101933
|
}
|
|
101220
101934
|
if (ts.getImportNeedsImportStarHelper(node)) {
|
|
@@ -101368,7 +102082,7 @@ var ts;
|
|
|
101368
102082
|
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));
|
|
101369
102083
|
}
|
|
101370
102084
|
else {
|
|
101371
|
-
var exportNeedsImportDefault = !!compilerOptions
|
|
102085
|
+
var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) &&
|
|
101372
102086
|
!(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) &&
|
|
101373
102087
|
ts.idText(specifier.propertyName || specifier.name) === "default";
|
|
101374
102088
|
var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
|
|
@@ -103537,7 +104251,10 @@ var ts;
|
|
|
103537
104251
|
(function (ts) {
|
|
103538
104252
|
function transformECMAScriptModule(context) {
|
|
103539
104253
|
var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
|
|
104254
|
+
var host = context.getEmitHost();
|
|
104255
|
+
var resolver = context.getEmitResolver();
|
|
103540
104256
|
var compilerOptions = context.getCompilerOptions();
|
|
104257
|
+
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
103541
104258
|
var previousOnEmitNode = context.onEmitNode;
|
|
103542
104259
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
103543
104260
|
context.onEmitNode = onEmitNode;
|
|
@@ -103545,13 +104262,21 @@ var ts;
|
|
|
103545
104262
|
context.enableEmitNotification(303 /* SourceFile */);
|
|
103546
104263
|
context.enableSubstitution(79 /* Identifier */);
|
|
103547
104264
|
var helperNameSubstitutions;
|
|
104265
|
+
var currentSourceFile;
|
|
104266
|
+
var importRequireStatements;
|
|
103548
104267
|
return ts.chainBundle(context, transformSourceFile);
|
|
103549
104268
|
function transformSourceFile(node) {
|
|
103550
104269
|
if (node.isDeclarationFile) {
|
|
103551
104270
|
return node;
|
|
103552
104271
|
}
|
|
103553
104272
|
if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
|
|
104273
|
+
currentSourceFile = node;
|
|
104274
|
+
importRequireStatements = undefined;
|
|
103554
104275
|
var result = updateExternalModule(node);
|
|
104276
|
+
currentSourceFile = undefined;
|
|
104277
|
+
if (importRequireStatements) {
|
|
104278
|
+
result = factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(ts.insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements));
|
|
104279
|
+
}
|
|
103555
104280
|
if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
|
|
103556
104281
|
return result;
|
|
103557
104282
|
}
|
|
@@ -103575,8 +104300,10 @@ var ts;
|
|
|
103575
104300
|
function visitor(node) {
|
|
103576
104301
|
switch (node.kind) {
|
|
103577
104302
|
case 264 /* ImportEqualsDeclaration */:
|
|
103578
|
-
//
|
|
103579
|
-
|
|
104303
|
+
// Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call
|
|
104304
|
+
// 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`
|
|
104305
|
+
// is available, just because the output is reasonable for a node-like runtime.
|
|
104306
|
+
return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined;
|
|
103580
104307
|
case 270 /* ExportAssignment */:
|
|
103581
104308
|
return visitExportAssignment(node);
|
|
103582
104309
|
case 271 /* ExportDeclaration */:
|
|
@@ -103585,6 +104312,68 @@ var ts;
|
|
|
103585
104312
|
}
|
|
103586
104313
|
return node;
|
|
103587
104314
|
}
|
|
104315
|
+
/**
|
|
104316
|
+
* Creates a `require()` call to import an external module.
|
|
104317
|
+
*
|
|
104318
|
+
* @param importNode The declaration to import.
|
|
104319
|
+
*/
|
|
104320
|
+
function createRequireCall(importNode) {
|
|
104321
|
+
var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, ts.Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions);
|
|
104322
|
+
var args = [];
|
|
104323
|
+
if (moduleName) {
|
|
104324
|
+
args.push(moduleName);
|
|
104325
|
+
}
|
|
104326
|
+
if (!importRequireStatements) {
|
|
104327
|
+
var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104328
|
+
var importStatement = factory.createImportDeclaration(
|
|
104329
|
+
/*decorators*/ undefined,
|
|
104330
|
+
/*modifiers*/ undefined, factory.createImportClause(
|
|
104331
|
+
/*isTypeOnly*/ false,
|
|
104332
|
+
/*name*/ undefined, factory.createNamedImports([
|
|
104333
|
+
factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName)
|
|
104334
|
+
])), factory.createStringLiteral("module"));
|
|
104335
|
+
var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
104336
|
+
var requireStatement = factory.createVariableStatement(
|
|
104337
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104338
|
+
factory.createVariableDeclaration(requireHelperName,
|
|
104339
|
+
/*exclamationToken*/ undefined,
|
|
104340
|
+
/*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [
|
|
104341
|
+
factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url"))
|
|
104342
|
+
]))
|
|
104343
|
+
],
|
|
104344
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */));
|
|
104345
|
+
importRequireStatements = [importStatement, requireStatement];
|
|
104346
|
+
}
|
|
104347
|
+
var name = importRequireStatements[1].declarationList.declarations[0].name;
|
|
104348
|
+
ts.Debug.assertNode(name, ts.isIdentifier);
|
|
104349
|
+
return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args);
|
|
104350
|
+
}
|
|
104351
|
+
/**
|
|
104352
|
+
* Visits an ImportEqualsDeclaration node.
|
|
104353
|
+
*
|
|
104354
|
+
* @param node The node to visit.
|
|
104355
|
+
*/
|
|
104356
|
+
function visitImportEqualsDeclaration(node) {
|
|
104357
|
+
ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
|
|
104358
|
+
var statements;
|
|
104359
|
+
statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(
|
|
104360
|
+
/*modifiers*/ undefined, factory.createVariableDeclarationList([
|
|
104361
|
+
factory.createVariableDeclaration(factory.cloneNode(node.name),
|
|
104362
|
+
/*exclamationToken*/ undefined,
|
|
104363
|
+
/*type*/ undefined, createRequireCall(node))
|
|
104364
|
+
],
|
|
104365
|
+
/*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node));
|
|
104366
|
+
statements = appendExportsOfImportEqualsDeclaration(statements, node);
|
|
104367
|
+
return ts.singleOrMany(statements);
|
|
104368
|
+
}
|
|
104369
|
+
function appendExportsOfImportEqualsDeclaration(statements, node) {
|
|
104370
|
+
if (ts.hasSyntacticModifier(node, 1 /* Export */)) {
|
|
104371
|
+
statements = ts.append(statements, factory.createExportDeclaration(
|
|
104372
|
+
/*decorators*/ undefined,
|
|
104373
|
+
/*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, ts.idText(node.name))])));
|
|
104374
|
+
}
|
|
104375
|
+
return statements;
|
|
104376
|
+
}
|
|
103588
104377
|
function visitExportAssignment(node) {
|
|
103589
104378
|
// Elide `export=` as it is not legal with --module ES6
|
|
103590
104379
|
return node.isExportEquals ? undefined : node;
|
|
@@ -103662,6 +104451,78 @@ var ts;
|
|
|
103662
104451
|
}
|
|
103663
104452
|
ts.transformECMAScriptModule = transformECMAScriptModule;
|
|
103664
104453
|
})(ts || (ts = {}));
|
|
104454
|
+
/*@internal*/
|
|
104455
|
+
var ts;
|
|
104456
|
+
(function (ts) {
|
|
104457
|
+
function transformNodeModule(context) {
|
|
104458
|
+
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
104459
|
+
var previousOnEmitNode = context.onEmitNode;
|
|
104460
|
+
var esmTransform = ts.transformECMAScriptModule(context);
|
|
104461
|
+
var esmOnSubstituteNode = context.onSubstituteNode;
|
|
104462
|
+
var esmOnEmitNode = context.onEmitNode;
|
|
104463
|
+
context.onSubstituteNode = previousOnSubstituteNode;
|
|
104464
|
+
context.onEmitNode = previousOnEmitNode;
|
|
104465
|
+
var cjsTransform = ts.transformModule(context);
|
|
104466
|
+
var cjsOnSubstituteNode = context.onSubstituteNode;
|
|
104467
|
+
var cjsOnEmitNode = context.onEmitNode;
|
|
104468
|
+
context.onSubstituteNode = onSubstituteNode;
|
|
104469
|
+
context.onEmitNode = onEmitNode;
|
|
104470
|
+
context.enableSubstitution(303 /* SourceFile */);
|
|
104471
|
+
context.enableEmitNotification(303 /* SourceFile */);
|
|
104472
|
+
var currentSourceFile;
|
|
104473
|
+
return transformSourceFileOrBundle;
|
|
104474
|
+
function onSubstituteNode(hint, node) {
|
|
104475
|
+
if (ts.isSourceFile(node)) {
|
|
104476
|
+
currentSourceFile = node;
|
|
104477
|
+
// Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on
|
|
104478
|
+
// the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute
|
|
104479
|
+
// functions on source files safely, as that context only gets setup in a later pipeline phase!)
|
|
104480
|
+
return previousOnSubstituteNode(hint, node);
|
|
104481
|
+
}
|
|
104482
|
+
else {
|
|
104483
|
+
if (!currentSourceFile) {
|
|
104484
|
+
return previousOnSubstituteNode(hint, node);
|
|
104485
|
+
}
|
|
104486
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104487
|
+
return esmOnSubstituteNode(hint, node);
|
|
104488
|
+
}
|
|
104489
|
+
return cjsOnSubstituteNode(hint, node);
|
|
104490
|
+
}
|
|
104491
|
+
}
|
|
104492
|
+
function onEmitNode(hint, node, emitCallback) {
|
|
104493
|
+
if (ts.isSourceFile(node)) {
|
|
104494
|
+
currentSourceFile = node;
|
|
104495
|
+
}
|
|
104496
|
+
if (!currentSourceFile) {
|
|
104497
|
+
return previousOnEmitNode(hint, node, emitCallback);
|
|
104498
|
+
}
|
|
104499
|
+
if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
|
|
104500
|
+
return esmOnEmitNode(hint, node, emitCallback);
|
|
104501
|
+
}
|
|
104502
|
+
return cjsOnEmitNode(hint, node, emitCallback);
|
|
104503
|
+
}
|
|
104504
|
+
function getModuleTransformForFile(file) {
|
|
104505
|
+
return file.impliedNodeFormat === ts.ModuleKind.ESNext ? esmTransform : cjsTransform;
|
|
104506
|
+
}
|
|
104507
|
+
function transformSourceFile(node) {
|
|
104508
|
+
if (node.isDeclarationFile) {
|
|
104509
|
+
return node;
|
|
104510
|
+
}
|
|
104511
|
+
currentSourceFile = node;
|
|
104512
|
+
var result = getModuleTransformForFile(node)(node);
|
|
104513
|
+
currentSourceFile = undefined;
|
|
104514
|
+
ts.Debug.assert(ts.isSourceFile(result));
|
|
104515
|
+
return result;
|
|
104516
|
+
}
|
|
104517
|
+
function transformSourceFileOrBundle(node) {
|
|
104518
|
+
return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node);
|
|
104519
|
+
}
|
|
104520
|
+
function transformBundle(node) {
|
|
104521
|
+
return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
|
|
104522
|
+
}
|
|
104523
|
+
}
|
|
104524
|
+
ts.transformNodeModule = transformNodeModule;
|
|
104525
|
+
})(ts || (ts = {}));
|
|
103665
104526
|
/* @internal */
|
|
103666
104527
|
var ts;
|
|
103667
104528
|
(function (ts) {
|
|
@@ -105483,6 +106344,9 @@ var ts;
|
|
|
105483
106344
|
return ts.transformECMAScriptModule;
|
|
105484
106345
|
case ts.ModuleKind.System:
|
|
105485
106346
|
return ts.transformSystemModule;
|
|
106347
|
+
case ts.ModuleKind.Node12:
|
|
106348
|
+
case ts.ModuleKind.NodeNext:
|
|
106349
|
+
return ts.transformNodeModule;
|
|
105486
106350
|
default:
|
|
105487
106351
|
return ts.transformModule;
|
|
105488
106352
|
}
|
|
@@ -106093,7 +106957,7 @@ var ts;
|
|
|
106093
106957
|
return getOutputPathsForBundle(options, forceDtsPaths);
|
|
106094
106958
|
}
|
|
106095
106959
|
else {
|
|
106096
|
-
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
|
|
106960
|
+
var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options));
|
|
106097
106961
|
var isJsonFile = ts.isJsonSourceFile(sourceFile);
|
|
106098
106962
|
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
|
|
106099
106963
|
var isJsonEmittedToSameLocation = isJsonFile &&
|
|
@@ -106109,26 +106973,13 @@ var ts;
|
|
|
106109
106973
|
function getSourceMapFilePath(jsFilePath, options) {
|
|
106110
106974
|
return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
|
|
106111
106975
|
}
|
|
106112
|
-
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
|
|
106113
|
-
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
|
|
106114
|
-
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
|
|
106115
106976
|
/* @internal */
|
|
106116
|
-
function getOutputExtension(
|
|
106117
|
-
|
|
106118
|
-
|
|
106119
|
-
|
|
106120
|
-
|
|
106121
|
-
|
|
106122
|
-
if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) {
|
|
106123
|
-
return ".jsx" /* Jsx */;
|
|
106124
|
-
}
|
|
106125
|
-
}
|
|
106126
|
-
else if (sourceFile.languageVariant === 1 /* JSX */) {
|
|
106127
|
-
// TypeScript source file preserving JSX syntax
|
|
106128
|
-
return ".jsx" /* Jsx */;
|
|
106129
|
-
}
|
|
106130
|
-
}
|
|
106131
|
-
return ".js" /* Js */;
|
|
106977
|
+
function getOutputExtension(fileName, options) {
|
|
106978
|
+
return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ :
|
|
106979
|
+
options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ :
|
|
106980
|
+
ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ :
|
|
106981
|
+
ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ :
|
|
106982
|
+
".js" /* Js */;
|
|
106132
106983
|
}
|
|
106133
106984
|
ts.getOutputExtension = getOutputExtension;
|
|
106134
106985
|
function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
|
|
@@ -106138,19 +106989,14 @@ var ts;
|
|
|
106138
106989
|
}
|
|
106139
106990
|
/* @internal */
|
|
106140
106991
|
function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
106141
|
-
ts.
|
|
106142
|
-
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts" /* Dts */);
|
|
106992
|
+
return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ts.getDeclarationEmitExtensionForPath(inputFileName));
|
|
106143
106993
|
}
|
|
106144
106994
|
ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
|
|
106145
106995
|
function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
|
|
106146
106996
|
if (configFile.options.emitDeclarationOnly)
|
|
106147
106997
|
return undefined;
|
|
106148
106998
|
var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */);
|
|
106149
|
-
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory),
|
|
106150
|
-
".json" /* Json */ :
|
|
106151
|
-
configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ?
|
|
106152
|
-
".jsx" /* Jsx */ :
|
|
106153
|
-
".js" /* Js */);
|
|
106999
|
+
var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options));
|
|
106154
107000
|
return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ?
|
|
106155
107001
|
outputFileName :
|
|
106156
107002
|
undefined;
|
|
@@ -106221,7 +107067,7 @@ var ts;
|
|
|
106221
107067
|
/*@internal*/
|
|
106222
107068
|
function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
|
|
106223
107069
|
var options = _a.options, fileNames = _a.fileNames;
|
|
106224
|
-
return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.
|
|
107070
|
+
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));
|
|
106225
107071
|
}
|
|
106226
107072
|
ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
|
|
106227
107073
|
/*@internal*/
|
|
@@ -107498,6 +108344,8 @@ var ts;
|
|
|
107498
108344
|
// Identifiers
|
|
107499
108345
|
case 79 /* Identifier */:
|
|
107500
108346
|
return emitIdentifier(node);
|
|
108347
|
+
case 80 /* PrivateIdentifier */:
|
|
108348
|
+
return emitPrivateIdentifier(node);
|
|
107501
108349
|
// Expressions
|
|
107502
108350
|
case 203 /* ArrayLiteralExpression */:
|
|
107503
108351
|
return emitArrayLiteralExpression(node);
|
|
@@ -111484,7 +112332,7 @@ var ts;
|
|
|
111484
112332
|
if (options.declarationDir)
|
|
111485
112333
|
return false;
|
|
111486
112334
|
}
|
|
111487
|
-
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.
|
|
112335
|
+
else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensionsFlat)) {
|
|
111488
112336
|
return false;
|
|
111489
112337
|
}
|
|
111490
112338
|
// just check if sourceFile with the name exists
|
|
@@ -112096,6 +112944,56 @@ var ts;
|
|
|
112096
112944
|
return resolutions;
|
|
112097
112945
|
}
|
|
112098
112946
|
ts.loadWithLocalCache = loadWithLocalCache;
|
|
112947
|
+
;
|
|
112948
|
+
/* @internal */
|
|
112949
|
+
function getModeForResolutionAtIndex(file, index) {
|
|
112950
|
+
if (file.impliedNodeFormat === undefined)
|
|
112951
|
+
return undefined;
|
|
112952
|
+
// we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup,
|
|
112953
|
+
// so it's safe to use them even pre-bind
|
|
112954
|
+
return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index));
|
|
112955
|
+
}
|
|
112956
|
+
ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex;
|
|
112957
|
+
/* @internal */
|
|
112958
|
+
function getModeForUsageLocation(file, usage) {
|
|
112959
|
+
var _a;
|
|
112960
|
+
if (file.impliedNodeFormat === undefined)
|
|
112961
|
+
return undefined;
|
|
112962
|
+
if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) {
|
|
112963
|
+
// in cjs files, import call expressions are esm format, otherwise everything is cjs
|
|
112964
|
+
return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
112965
|
+
}
|
|
112966
|
+
// in esm files, import=require statements are cjs format, otherwise everything is esm
|
|
112967
|
+
// imports are only parent'd up to their containing declaration/expression, so access farther parents with care
|
|
112968
|
+
var exprParentParent = (_a = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _a === void 0 ? void 0 : _a.parent;
|
|
112969
|
+
return exprParentParent && ts.isImportEqualsDeclaration(exprParentParent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext;
|
|
112970
|
+
}
|
|
112971
|
+
ts.getModeForUsageLocation = getModeForUsageLocation;
|
|
112972
|
+
/* @internal */
|
|
112973
|
+
function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) {
|
|
112974
|
+
if (names.length === 0) {
|
|
112975
|
+
return [];
|
|
112976
|
+
}
|
|
112977
|
+
var resolutions = [];
|
|
112978
|
+
var cache = new ts.Map();
|
|
112979
|
+
var i = 0;
|
|
112980
|
+
for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
|
|
112981
|
+
var name = names_3[_i];
|
|
112982
|
+
var result = void 0;
|
|
112983
|
+
var mode = getModeForResolutionAtIndex(containingFile, i);
|
|
112984
|
+
i++;
|
|
112985
|
+
var cacheKey = mode !== undefined ? mode + "|" + name : name;
|
|
112986
|
+
if (cache.has(cacheKey)) {
|
|
112987
|
+
result = cache.get(cacheKey);
|
|
112988
|
+
}
|
|
112989
|
+
else {
|
|
112990
|
+
cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference));
|
|
112991
|
+
}
|
|
112992
|
+
resolutions.push(result);
|
|
112993
|
+
}
|
|
112994
|
+
return resolutions;
|
|
112995
|
+
}
|
|
112996
|
+
ts.loadWithModeAwareCache = loadWithModeAwareCache;
|
|
112099
112997
|
/* @internal */
|
|
112100
112998
|
function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
|
|
112101
112999
|
return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
|
|
@@ -112154,7 +113052,7 @@ var ts;
|
|
|
112154
113052
|
switch (kind) {
|
|
112155
113053
|
case ts.FileIncludeKind.Import:
|
|
112156
113054
|
var importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
112157
|
-
packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId;
|
|
113055
|
+
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;
|
|
112158
113056
|
if (importLiteral.pos === -1)
|
|
112159
113057
|
return { file: file, packageId: packageId, text: importLiteral.text };
|
|
112160
113058
|
pos = ts.skipTrivia(file.text, importLiteral.pos);
|
|
@@ -112165,7 +113063,7 @@ var ts;
|
|
|
112165
113063
|
break;
|
|
112166
113064
|
case ts.FileIncludeKind.TypeReferenceDirective:
|
|
112167
113065
|
(_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
|
|
112168
|
-
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;
|
|
113066
|
+
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;
|
|
112169
113067
|
break;
|
|
112170
113068
|
case ts.FileIncludeKind.LibReferenceDirective:
|
|
112171
113069
|
(_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
|
|
@@ -112252,6 +113150,33 @@ var ts;
|
|
|
112252
113150
|
configFileParseResult.errors;
|
|
112253
113151
|
}
|
|
112254
113152
|
ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
|
|
113153
|
+
/**
|
|
113154
|
+
* A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the
|
|
113155
|
+
* `options` parameter.
|
|
113156
|
+
*
|
|
113157
|
+
* @param fileName The normalized absolute path to check the format of (it need not exist on disk)
|
|
113158
|
+
* @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often
|
|
113159
|
+
* @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data
|
|
113160
|
+
* @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution`
|
|
113161
|
+
* @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format
|
|
113162
|
+
*/
|
|
113163
|
+
function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) {
|
|
113164
|
+
switch (ts.getEmitModuleResolutionKind(options)) {
|
|
113165
|
+
case ts.ModuleResolutionKind.Node12:
|
|
113166
|
+
case ts.ModuleResolutionKind.NodeNext:
|
|
113167
|
+
return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext :
|
|
113168
|
+
ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS :
|
|
113169
|
+
ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() :
|
|
113170
|
+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
|
113171
|
+
default:
|
|
113172
|
+
return undefined;
|
|
113173
|
+
}
|
|
113174
|
+
function lookupFromPackageJson() {
|
|
113175
|
+
var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
|
|
113176
|
+
return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
|
|
113177
|
+
}
|
|
113178
|
+
}
|
|
113179
|
+
ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile;
|
|
112255
113180
|
/**
|
|
112256
113181
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
112257
113182
|
*/
|
|
@@ -112272,7 +113197,7 @@ var ts;
|
|
|
112272
113197
|
};
|
|
112273
113198
|
}
|
|
112274
113199
|
function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
112275
|
-
var _a, _b, _c;
|
|
113200
|
+
var _a, _b, _c, _d;
|
|
112276
113201
|
var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
|
|
112277
113202
|
var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
|
|
112278
113203
|
var oldProgram = createProgramOptions.oldProgram;
|
|
@@ -112314,7 +113239,7 @@ var ts;
|
|
|
112314
113239
|
var programDiagnostics = ts.createDiagnosticCollection();
|
|
112315
113240
|
var currentDirectory = host.getCurrentDirectory();
|
|
112316
113241
|
var supportedExtensions = ts.getSupportedExtensions(options);
|
|
112317
|
-
var supportedExtensionsWithJsonIfResolveJsonModule = ts.
|
|
113242
|
+
var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
|
112318
113243
|
// Map storing if there is emit blocking diagnostics for given input
|
|
112319
113244
|
var hasEmitBlockingDiagnostics = new ts.Map();
|
|
112320
113245
|
var _compilerOptionsObjectLiteralSyntax;
|
|
@@ -112323,7 +113248,7 @@ var ts;
|
|
|
112323
113248
|
var actualResolveModuleNamesWorker;
|
|
112324
113249
|
var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
|
|
112325
113250
|
if (host.resolveModuleNames) {
|
|
112326
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames),
|
|
113251
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
|
|
112327
113252
|
// An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
|
|
112328
113253
|
if (!resolved || resolved.extension !== undefined) {
|
|
112329
113254
|
return resolved;
|
|
@@ -112332,11 +113257,12 @@ var ts;
|
|
|
112332
113257
|
withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
|
|
112333
113258
|
return withExtension;
|
|
112334
113259
|
}); };
|
|
113260
|
+
moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
112335
113261
|
}
|
|
112336
113262
|
else {
|
|
112337
113263
|
moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options);
|
|
112338
|
-
var loader_1 = function (moduleName,
|
|
112339
|
-
actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return
|
|
113264
|
+
var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217
|
|
113265
|
+
actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); };
|
|
112340
113266
|
}
|
|
112341
113267
|
var actualResolveTypeReferenceDirectiveNamesWorker;
|
|
112342
113268
|
if (host.resolveTypeReferenceDirectives) {
|
|
@@ -112372,9 +113298,9 @@ var ts;
|
|
|
112372
113298
|
var projectReferenceRedirects;
|
|
112373
113299
|
var mapFromFileToProjectReferenceRedirects;
|
|
112374
113300
|
var mapFromToProjectReferenceRedirectSource;
|
|
112375
|
-
var useSourceOfProjectReferenceRedirect = !!((
|
|
113301
|
+
var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) &&
|
|
112376
113302
|
!options.disableSourceOfProjectReferenceRedirect;
|
|
112377
|
-
var
|
|
113303
|
+
var _e = updateHostForUseSourceOfProjectReferenceRedirect({
|
|
112378
113304
|
compilerHost: host,
|
|
112379
113305
|
getSymlinkCache: getSymlinkCache,
|
|
112380
113306
|
useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
|
|
@@ -112382,7 +113308,8 @@ var ts;
|
|
|
112382
113308
|
getResolvedProjectReferences: getResolvedProjectReferences,
|
|
112383
113309
|
getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
|
|
112384
113310
|
forEachResolvedProjectReference: forEachResolvedProjectReference
|
|
112385
|
-
}), onProgramCreateComplete =
|
|
113311
|
+
}), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists;
|
|
113312
|
+
var readFile = host.readFile.bind(host);
|
|
112386
113313
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
|
|
112387
113314
|
var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
|
|
112388
113315
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112441,7 +113368,7 @@ var ts;
|
|
|
112441
113368
|
var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
|
|
112442
113369
|
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
|
|
112443
113370
|
for (var i = 0; i < typeReferences.length; i++) {
|
|
112444
|
-
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (
|
|
113371
|
+
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId });
|
|
112445
113372
|
}
|
|
112446
113373
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
112447
113374
|
}
|
|
@@ -112557,9 +113484,10 @@ var ts;
|
|
|
112557
113484
|
isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
|
|
112558
113485
|
emitBuildInfo: emitBuildInfo,
|
|
112559
113486
|
fileExists: fileExists,
|
|
113487
|
+
readFile: readFile,
|
|
112560
113488
|
directoryExists: directoryExists,
|
|
112561
113489
|
getSymlinkCache: getSymlinkCache,
|
|
112562
|
-
realpath: (
|
|
113490
|
+
realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host),
|
|
112563
113491
|
useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
|
|
112564
113492
|
getFileIncludeReasons: function () { return fileReasons; },
|
|
112565
113493
|
structureIsReused: structureIsReused,
|
|
@@ -112589,7 +113517,7 @@ var ts;
|
|
|
112589
113517
|
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
112590
113518
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName });
|
|
112591
113519
|
ts.performance.mark("beforeResolveModule");
|
|
112592
|
-
var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
|
|
113520
|
+
var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference);
|
|
112593
113521
|
ts.performance.mark("afterResolveModule");
|
|
112594
113522
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
112595
113523
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
@@ -112610,7 +113538,7 @@ var ts;
|
|
|
112610
113538
|
}
|
|
112611
113539
|
function getRedirectReferenceForResolution(file) {
|
|
112612
113540
|
var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
|
|
112613
|
-
if (redirect || !ts.
|
|
113541
|
+
if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]))
|
|
112614
113542
|
return redirect;
|
|
112615
113543
|
// The originalFileName could not be actual source file name if file found was d.ts from referecned project
|
|
112616
113544
|
// So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
|
|
@@ -112655,8 +113583,8 @@ var ts;
|
|
|
112655
113583
|
}
|
|
112656
113584
|
return ts.libs.length + 2;
|
|
112657
113585
|
}
|
|
112658
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
112659
|
-
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
|
|
113586
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) {
|
|
113587
|
+
return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode);
|
|
112660
113588
|
}
|
|
112661
113589
|
function toPath(fileName) {
|
|
112662
113590
|
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
|
@@ -112698,9 +113626,11 @@ var ts;
|
|
|
112698
113626
|
// Since we assume the filesystem does not change during program creation,
|
|
112699
113627
|
// it is safe to reuse resolutions from the earlier call.
|
|
112700
113628
|
var result_14 = [];
|
|
113629
|
+
var i = 0;
|
|
112701
113630
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
112702
113631
|
var moduleName = moduleNames_1[_i];
|
|
112703
|
-
var resolvedModule = file.resolvedModules.get(moduleName);
|
|
113632
|
+
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
113633
|
+
i++;
|
|
112704
113634
|
result_14.push(resolvedModule);
|
|
112705
113635
|
}
|
|
112706
113636
|
return result_14;
|
|
@@ -112728,7 +113658,7 @@ var ts;
|
|
|
112728
113658
|
var moduleName = moduleNames[i];
|
|
112729
113659
|
// If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
|
|
112730
113660
|
if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
|
|
112731
|
-
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
|
|
113661
|
+
var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
|
|
112732
113662
|
if (oldResolvedModule) {
|
|
112733
113663
|
if (ts.isTraceEnabled(options, host)) {
|
|
112734
113664
|
ts.trace(host, oldResolvedModule.packageId ?
|
|
@@ -112752,7 +113682,7 @@ var ts;
|
|
|
112752
113682
|
}
|
|
112753
113683
|
}
|
|
112754
113684
|
else {
|
|
112755
|
-
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
|
|
113685
|
+
resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i);
|
|
112756
113686
|
}
|
|
112757
113687
|
if (resolvesToAmbientModuleInNonModifiedFile) {
|
|
112758
113688
|
(result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
|
|
@@ -112789,8 +113719,10 @@ var ts;
|
|
|
112789
113719
|
return result;
|
|
112790
113720
|
// If we change our policy of rechecking failed lookups on each program create,
|
|
112791
113721
|
// we should adjust the value returned here.
|
|
112792
|
-
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
112793
|
-
|
|
113722
|
+
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, index) {
|
|
113723
|
+
if (index >= ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.imports) + ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.moduleAugmentations))
|
|
113724
|
+
return false; // mode index out of bounds, don't reuse resolution
|
|
113725
|
+
var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index));
|
|
112794
113726
|
var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
112795
113727
|
if (resolutionToFile && resolvedFile) {
|
|
112796
113728
|
// In the old program, we resolved to an ambient module that was in the same
|
|
@@ -112873,8 +113805,8 @@ var ts;
|
|
|
112873
113805
|
for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
|
|
112874
113806
|
var oldSourceFile = oldSourceFiles_2[_i];
|
|
112875
113807
|
var newSourceFile = host.getSourceFileByPath
|
|
112876
|
-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options
|
|
112877
|
-
: host.getSourceFile(oldSourceFile.fileName, options
|
|
113808
|
+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
|
|
113809
|
+
: host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
|
|
112878
113810
|
if (!newSourceFile) {
|
|
112879
113811
|
return 0 /* Not */;
|
|
112880
113812
|
}
|
|
@@ -112981,10 +113913,10 @@ var ts;
|
|
|
112981
113913
|
var moduleNames = getModuleNames(newSourceFile);
|
|
112982
113914
|
var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
|
112983
113915
|
// ensure that module resolution results are still correct
|
|
112984
|
-
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
|
|
113916
|
+
var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo);
|
|
112985
113917
|
if (resolutionsChanged) {
|
|
112986
113918
|
structureIsReused = 1 /* SafeModules */;
|
|
112987
|
-
newSourceFile.resolvedModules = ts.
|
|
113919
|
+
newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions);
|
|
112988
113920
|
}
|
|
112989
113921
|
else {
|
|
112990
113922
|
newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
|
|
@@ -112993,10 +113925,10 @@ var ts;
|
|
|
112993
113925
|
var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
|
|
112994
113926
|
var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
|
|
112995
113927
|
// ensure that types resolutions are still correct
|
|
112996
|
-
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
|
|
113928
|
+
var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
|
|
112997
113929
|
if (typeReferenceEesolutionsChanged) {
|
|
112998
113930
|
structureIsReused = 1 /* SafeModules */;
|
|
112999
|
-
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.
|
|
113931
|
+
newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
|
|
113000
113932
|
}
|
|
113001
113933
|
else {
|
|
113002
113934
|
newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
|
|
@@ -113627,6 +114559,7 @@ var ts;
|
|
|
113627
114559
|
// An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules
|
|
113628
114560
|
// only through top - level external module names. Relative external module names are not permitted.
|
|
113629
114561
|
if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
|
|
114562
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113630
114563
|
imports = ts.append(imports, moduleNameExpr);
|
|
113631
114564
|
if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) {
|
|
113632
114565
|
usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:");
|
|
@@ -113635,6 +114568,7 @@ var ts;
|
|
|
113635
114568
|
}
|
|
113636
114569
|
else if (ts.isModuleDeclaration(node)) {
|
|
113637
114570
|
if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) {
|
|
114571
|
+
node.name.parent = node;
|
|
113638
114572
|
var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
|
|
113639
114573
|
// Ambient module declarations can be interpreted as augmentations for some existing external modules.
|
|
113640
114574
|
// This will happen in two cases:
|
|
@@ -113670,13 +114604,16 @@ var ts;
|
|
|
113670
114604
|
while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null
|
|
113671
114605
|
var node = getNodeAtPosition(file, r.lastIndex);
|
|
113672
114606
|
if (isJavaScriptFile && ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) {
|
|
114607
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113673
114608
|
imports = ts.append(imports, node.arguments[0]);
|
|
113674
114609
|
}
|
|
113675
114610
|
// we have to check the argument list has length of at least 1. We will still have to process these even though we have parsing error.
|
|
113676
114611
|
else if (ts.isImportCall(node) && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) {
|
|
114612
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113677
114613
|
imports = ts.append(imports, node.arguments[0]);
|
|
113678
114614
|
}
|
|
113679
114615
|
else if (ts.isLiteralImportTypeNode(node)) {
|
|
114616
|
+
ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
|
|
113680
114617
|
imports = ts.append(imports, node.argument.literal);
|
|
113681
114618
|
}
|
|
113682
114619
|
}
|
|
@@ -113712,13 +114649,13 @@ var ts;
|
|
|
113712
114649
|
function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) {
|
|
113713
114650
|
if (ts.hasExtension(fileName)) {
|
|
113714
114651
|
var canonicalFileName_1 = host.getCanonicalFileName(fileName);
|
|
113715
|
-
if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
114652
|
+
if (!options.allowNonTsExtensions && !ts.forEach(ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
|
|
113716
114653
|
if (fail) {
|
|
113717
114654
|
if (ts.hasJSFileExtension(canonicalFileName_1)) {
|
|
113718
114655
|
fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
|
|
113719
114656
|
}
|
|
113720
114657
|
else {
|
|
113721
|
-
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114658
|
+
fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113722
114659
|
}
|
|
113723
114660
|
}
|
|
113724
114661
|
return undefined;
|
|
@@ -113748,9 +114685,10 @@ var ts;
|
|
|
113748
114685
|
fail(ts.Diagnostics.File_0_not_found, fileName);
|
|
113749
114686
|
return undefined;
|
|
113750
114687
|
}
|
|
113751
|
-
|
|
114688
|
+
// Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts)
|
|
114689
|
+
var sourceFileWithAddedExtension = ts.forEach(supportedExtensions[0], function (extension) { return getSourceFile(fileName + extension); });
|
|
113752
114690
|
if (fail && !sourceFileWithAddedExtension)
|
|
113753
|
-
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
|
|
114691
|
+
fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'");
|
|
113754
114692
|
return sourceFileWithAddedExtension;
|
|
113755
114693
|
}
|
|
113756
114694
|
}
|
|
@@ -113895,7 +114833,7 @@ var ts;
|
|
|
113895
114833
|
}
|
|
113896
114834
|
}
|
|
113897
114835
|
// We haven't looked for this file, do so now and cache result
|
|
113898
|
-
var file = host.getSourceFile(fileName, options
|
|
114836
|
+
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);
|
|
113899
114837
|
if (packageId) {
|
|
113900
114838
|
var packageIdKey = ts.packageIdToString(packageId);
|
|
113901
114839
|
var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
|
|
@@ -113923,6 +114861,10 @@ var ts;
|
|
|
113923
114861
|
file.path = path;
|
|
113924
114862
|
file.resolvedPath = toPath(fileName);
|
|
113925
114863
|
file.originalFileName = originalFileName;
|
|
114864
|
+
// 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
|
|
114865
|
+
// 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
|
|
114866
|
+
// 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.
|
|
114867
|
+
file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
|
|
113926
114868
|
addFileIncludeReason(file, reason);
|
|
113927
114869
|
if (host.useCaseSensitiveFileNames()) {
|
|
113928
114870
|
var pathLowerCase = ts.toFileNameLowerCase(path);
|
|
@@ -114114,9 +115056,9 @@ var ts;
|
|
|
114114
115056
|
}
|
|
114115
115057
|
}
|
|
114116
115058
|
function pathForLibFile(libFileName) {
|
|
114117
|
-
// Support resolving to lib.dom.d.ts -> @typescript/dom, and
|
|
114118
|
-
// lib.dom.iterable.d.ts -> @typescript/dom/iterable
|
|
114119
|
-
// lib.es2015.symbol.wellknown.d.ts -> @typescript/es2015/symbol-wellknown
|
|
115059
|
+
// Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and
|
|
115060
|
+
// lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable
|
|
115061
|
+
// lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown
|
|
114120
115062
|
var components = libFileName.split(".");
|
|
114121
115063
|
var path = components[1];
|
|
114122
115064
|
var i = 2;
|
|
@@ -114125,7 +115067,7 @@ var ts;
|
|
|
114125
115067
|
i++;
|
|
114126
115068
|
}
|
|
114127
115069
|
var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts");
|
|
114128
|
-
var localOverrideModuleResult = ts.resolveModuleName("@typescript/" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
115070
|
+
var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache);
|
|
114129
115071
|
if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) {
|
|
114130
115072
|
return localOverrideModuleResult.resolvedModule.resolvedFileName;
|
|
114131
115073
|
}
|
|
@@ -114166,7 +115108,7 @@ var ts;
|
|
|
114166
115108
|
var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options;
|
|
114167
115109
|
for (var index = 0; index < moduleNames.length; index++) {
|
|
114168
115110
|
var resolution = resolutions[index];
|
|
114169
|
-
ts.setResolvedModule(file, moduleNames[index], resolution);
|
|
115111
|
+
ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index));
|
|
114170
115112
|
if (!resolution) {
|
|
114171
115113
|
continue;
|
|
114172
115114
|
}
|
|
@@ -114389,7 +115331,7 @@ var ts;
|
|
|
114389
115331
|
if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
|
|
114390
115332
|
createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
|
|
114391
115333
|
}
|
|
114392
|
-
var languageVersion = options
|
|
115334
|
+
var languageVersion = ts.getEmitScriptTarget(options);
|
|
114393
115335
|
var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
|
|
114394
115336
|
if (options.isolatedModules) {
|
|
114395
115337
|
if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) {
|
|
@@ -114650,7 +115592,7 @@ var ts;
|
|
|
114650
115592
|
message = ts.Diagnostics.File_is_library_specified_here;
|
|
114651
115593
|
break;
|
|
114652
115594
|
}
|
|
114653
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
115595
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
114654
115596
|
configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
|
|
114655
115597
|
message = ts.Diagnostics.File_is_default_library_for_target_specified_here;
|
|
114656
115598
|
break;
|
|
@@ -114818,7 +115760,7 @@ var ts;
|
|
|
114818
115760
|
if (options.outDir) {
|
|
114819
115761
|
return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
|
|
114820
115762
|
}
|
|
114821
|
-
if (ts.fileExtensionIsOneOf(filePath, ts.
|
|
115763
|
+
if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) {
|
|
114822
115764
|
// Otherwise just check if sourceFile with the name exists
|
|
114823
115765
|
var filePathWithoutExtension = ts.removeFileExtension(filePath);
|
|
114824
115766
|
return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) ||
|
|
@@ -115350,7 +116292,7 @@ var ts;
|
|
|
115350
116292
|
}
|
|
115351
116293
|
}
|
|
115352
116294
|
}
|
|
115353
|
-
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
|
|
116295
|
+
fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
|
|
115354
116296
|
}
|
|
115355
116297
|
return {
|
|
115356
116298
|
fileInfos: fileInfos,
|
|
@@ -115444,7 +116386,7 @@ var ts;
|
|
|
115444
116386
|
/*forceDtsEmit*/ true);
|
|
115445
116387
|
var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
|
|
115446
116388
|
if (firstDts_1) {
|
|
115447
|
-
ts.Debug.assert(ts.
|
|
116389
|
+
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; })); });
|
|
115448
116390
|
latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
|
|
115449
116391
|
if (exportedModulesMapCache && latestSignature !== prevSignature) {
|
|
115450
116392
|
updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
|
|
@@ -115768,6 +116710,14 @@ var ts;
|
|
|
115768
116710
|
ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
|
|
115769
116711
|
state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
|
|
115770
116712
|
}
|
|
116713
|
+
if (useOldState) {
|
|
116714
|
+
// Any time the interpretation of a source file changes, mark it as changed
|
|
116715
|
+
ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) {
|
|
116716
|
+
if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) {
|
|
116717
|
+
state.changedFilesSet.add(sourceFilePath);
|
|
116718
|
+
}
|
|
116719
|
+
});
|
|
116720
|
+
}
|
|
115771
116721
|
state.buildInfoEmitPending = !!state.changedFilesSet.size;
|
|
115772
116722
|
return state;
|
|
115773
116723
|
}
|
|
@@ -116164,13 +117114,13 @@ var ts;
|
|
|
116164
117114
|
var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature;
|
|
116165
117115
|
return value.version === actualSignature ?
|
|
116166
117116
|
value.affectsGlobalScope ?
|
|
116167
|
-
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
|
|
117117
|
+
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
|
|
116168
117118
|
value.version :
|
|
116169
117119
|
actualSignature !== undefined ?
|
|
116170
117120
|
signature === undefined ?
|
|
116171
117121
|
value :
|
|
116172
|
-
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } :
|
|
116173
|
-
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
|
|
117122
|
+
{ version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
|
|
117123
|
+
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
|
|
116174
117124
|
});
|
|
116175
117125
|
var referencedMap;
|
|
116176
117126
|
if (state.referencedMap) {
|
|
@@ -116590,10 +117540,10 @@ var ts;
|
|
|
116590
117540
|
}
|
|
116591
117541
|
function toBuilderStateFileInfo(fileInfo) {
|
|
116592
117542
|
return ts.isString(fileInfo) ?
|
|
116593
|
-
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
|
|
117543
|
+
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
|
|
116594
117544
|
ts.isString(fileInfo.signature) ?
|
|
116595
117545
|
fileInfo :
|
|
116596
|
-
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
|
|
117546
|
+
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
116597
117547
|
}
|
|
116598
117548
|
ts.toBuilderStateFileInfo = toBuilderStateFileInfo;
|
|
116599
117549
|
function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
|
|
@@ -116931,14 +117881,14 @@ var ts;
|
|
|
116931
117881
|
}
|
|
116932
117882
|
function resolveNamesWithLocalCache(_a) {
|
|
116933
117883
|
var _b, _c, _d;
|
|
116934
|
-
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;
|
|
117884
|
+
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;
|
|
116935
117885
|
var path = resolutionHost.toPath(containingFile);
|
|
116936
|
-
var resolutionsInFile = cache.get(path) || cache.set(path,
|
|
117886
|
+
var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
|
|
116937
117887
|
var dirPath = ts.getDirectoryPath(path);
|
|
116938
117888
|
var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
116939
117889
|
var perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
116940
117890
|
if (!perDirectoryResolution) {
|
|
116941
|
-
perDirectoryResolution =
|
|
117891
|
+
perDirectoryResolution = ts.createModeAwareCache();
|
|
116942
117892
|
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
116943
117893
|
}
|
|
116944
117894
|
var resolvedModules = [];
|
|
@@ -116950,17 +117900,20 @@ var ts;
|
|
|
116950
117900
|
var unmatchedRedirects = oldRedirect ?
|
|
116951
117901
|
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
|
116952
117902
|
!!redirectedReference;
|
|
116953
|
-
var seenNamesInFile =
|
|
116954
|
-
|
|
116955
|
-
|
|
116956
|
-
var
|
|
117903
|
+
var seenNamesInFile = ts.createModeAwareCache();
|
|
117904
|
+
var i = 0;
|
|
117905
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
117906
|
+
var name = names_4[_i];
|
|
117907
|
+
var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
|
|
117908
|
+
i++;
|
|
117909
|
+
var resolution = resolutionsInFile.get(name, mode);
|
|
116957
117910
|
// Resolution is valid if it is present and not invalidated
|
|
116958
|
-
if (!seenNamesInFile.has(name) &&
|
|
117911
|
+
if (!seenNamesInFile.has(name, mode) &&
|
|
116959
117912
|
unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
116960
117913
|
// If the name is unresolved import that was invalidated, recalculate
|
|
116961
117914
|
(hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
116962
117915
|
var existingResolution = resolution;
|
|
116963
|
-
var resolutionInDirectory = perDirectoryResolution.get(name);
|
|
117916
|
+
var resolutionInDirectory = perDirectoryResolution.get(name, mode);
|
|
116964
117917
|
if (resolutionInDirectory) {
|
|
116965
117918
|
resolution = resolutionInDirectory;
|
|
116966
117919
|
var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
@@ -116980,10 +117933,10 @@ var ts;
|
|
|
116980
117933
|
}
|
|
116981
117934
|
}
|
|
116982
117935
|
else {
|
|
116983
|
-
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference);
|
|
116984
|
-
perDirectoryResolution.set(name, resolution);
|
|
117936
|
+
resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
|
|
117937
|
+
perDirectoryResolution.set(name, mode, resolution);
|
|
116985
117938
|
}
|
|
116986
|
-
resolutionsInFile.set(name, resolution);
|
|
117939
|
+
resolutionsInFile.set(name, mode, resolution);
|
|
116987
117940
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
116988
117941
|
if (existingResolution) {
|
|
116989
117942
|
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
|
@@ -116996,7 +117949,7 @@ var ts;
|
|
|
116996
117949
|
}
|
|
116997
117950
|
else {
|
|
116998
117951
|
var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost;
|
|
116999
|
-
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) {
|
|
117952
|
+
if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
117000
117953
|
var resolved = getResolutionWithResolvedFileName(resolution);
|
|
117001
117954
|
ts.trace(host, loader === resolveModuleName ?
|
|
117002
117955
|
(resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
|
|
@@ -117012,14 +117965,14 @@ var ts;
|
|
|
117012
117965
|
}
|
|
117013
117966
|
}
|
|
117014
117967
|
ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
|
|
117015
|
-
seenNamesInFile.set(name, true);
|
|
117968
|
+
seenNamesInFile.set(name, mode, true);
|
|
117016
117969
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
117017
117970
|
}
|
|
117018
117971
|
// Stop watching and remove the unused name
|
|
117019
|
-
resolutionsInFile.forEach(function (resolution, name) {
|
|
117020
|
-
if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
|
|
117972
|
+
resolutionsInFile.forEach(function (resolution, name, mode) {
|
|
117973
|
+
if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) {
|
|
117021
117974
|
stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
|
|
117022
|
-
resolutionsInFile.delete(name);
|
|
117975
|
+
resolutionsInFile.delete(name, mode);
|
|
117023
117976
|
}
|
|
117024
117977
|
});
|
|
117025
117978
|
return resolvedModules;
|
|
@@ -117053,7 +118006,7 @@ var ts;
|
|
|
117053
118006
|
shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
|
|
117054
118007
|
});
|
|
117055
118008
|
}
|
|
117056
|
-
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
118009
|
+
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) {
|
|
117057
118010
|
return resolveNamesWithLocalCache({
|
|
117058
118011
|
names: moduleNames,
|
|
117059
118012
|
containingFile: containingFile,
|
|
@@ -117065,11 +118018,14 @@ var ts;
|
|
|
117065
118018
|
shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
|
|
117066
118019
|
reusedNames: reusedNames,
|
|
117067
118020
|
logChanges: logChangesWhenResolvingModule,
|
|
118021
|
+
containingSourceFile: containingSourceFile,
|
|
117068
118022
|
});
|
|
117069
118023
|
}
|
|
117070
|
-
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
|
|
118024
|
+
function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) {
|
|
117071
118025
|
var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
|
|
117072
|
-
|
|
118026
|
+
if (!cache)
|
|
118027
|
+
return undefined;
|
|
118028
|
+
return cache.get(moduleName, resolutionMode);
|
|
117073
118029
|
}
|
|
117074
118030
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
117075
118031
|
return ts.endsWith(dirPath, "/node_modules/@types");
|
|
@@ -117468,7 +118424,7 @@ var ts;
|
|
|
117468
118424
|
Ending[Ending["Index"] = 1] = "Index";
|
|
117469
118425
|
Ending[Ending["JsExtension"] = 2] = "JsExtension";
|
|
117470
118426
|
})(Ending || (Ending = {}));
|
|
117471
|
-
function getPreferences(_a, compilerOptions, importingSourceFile) {
|
|
118427
|
+
function getPreferences(host, _a, compilerOptions, importingSourceFile) {
|
|
117472
118428
|
var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
|
|
117473
118429
|
return {
|
|
117474
118430
|
relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ :
|
|
@@ -117482,21 +118438,39 @@ var ts;
|
|
|
117482
118438
|
case "minimal": return 0 /* Minimal */;
|
|
117483
118439
|
case "index": return 1 /* Index */;
|
|
117484
118440
|
case "js": return 2 /* JsExtension */;
|
|
117485
|
-
default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */
|
|
118441
|
+
default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */
|
|
117486
118442
|
: ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */;
|
|
117487
118443
|
}
|
|
117488
118444
|
}
|
|
117489
118445
|
}
|
|
117490
|
-
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
|
|
118446
|
+
function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) {
|
|
117491
118447
|
return {
|
|
117492
118448
|
relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */,
|
|
117493
|
-
ending: ts.hasJSFileExtension(oldImportSpecifier) ?
|
|
118449
|
+
ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ?
|
|
117494
118450
|
2 /* JsExtension */ :
|
|
117495
118451
|
ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */,
|
|
117496
118452
|
};
|
|
117497
118453
|
}
|
|
118454
|
+
function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
|
|
118455
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
|
|
118456
|
+
&& ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
118457
|
+
return false;
|
|
118458
|
+
}
|
|
118459
|
+
return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
|
|
118460
|
+
}
|
|
118461
|
+
function getModuleResolutionHost(host) {
|
|
118462
|
+
var _a;
|
|
118463
|
+
return {
|
|
118464
|
+
fileExists: host.fileExists,
|
|
118465
|
+
readFile: ts.Debug.checkDefined(host.readFile),
|
|
118466
|
+
directoryExists: host.directoryExists,
|
|
118467
|
+
getCurrentDirectory: host.getCurrentDirectory,
|
|
118468
|
+
realpath: host.realpath,
|
|
118469
|
+
useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
|
|
118470
|
+
};
|
|
118471
|
+
}
|
|
117498
118472
|
function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
|
|
117499
|
-
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier), {});
|
|
118473
|
+
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
|
|
117500
118474
|
if (res === oldImportSpecifier)
|
|
117501
118475
|
return undefined;
|
|
117502
118476
|
return res;
|
|
@@ -117504,7 +118478,7 @@ var ts;
|
|
|
117504
118478
|
moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
|
|
117505
118479
|
// Note: importingSourceFile is just for usesJsExtensionOnImports
|
|
117506
118480
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
|
|
117507
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {});
|
|
118481
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
117508
118482
|
}
|
|
117509
118483
|
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
|
|
117510
118484
|
function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) {
|
|
@@ -117558,7 +118532,7 @@ var ts;
|
|
|
117558
118532
|
moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo;
|
|
117559
118533
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) {
|
|
117560
118534
|
var info = getInfo(importingSourceFile.path, host);
|
|
117561
|
-
var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
|
|
118535
|
+
var preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile);
|
|
117562
118536
|
var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) {
|
|
117563
118537
|
if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path)
|
|
117564
118538
|
return undefined;
|
|
@@ -117994,7 +118968,7 @@ var ts;
|
|
|
117994
118968
|
if (!host.fileExists)
|
|
117995
118969
|
return;
|
|
117996
118970
|
// We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory
|
|
117997
|
-
var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]);
|
|
118971
|
+
var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]));
|
|
117998
118972
|
for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
|
|
117999
118973
|
var e = extensions_3[_i];
|
|
118000
118974
|
var fullPath = path + e;
|
|
@@ -118062,9 +119036,11 @@ var ts;
|
|
|
118062
119036
|
});
|
|
118063
119037
|
}
|
|
118064
119038
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
118065
|
-
if (ts.
|
|
119039
|
+
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
118066
119040
|
return fileName;
|
|
118067
119041
|
var noExtension = ts.removeFileExtension(fileName);
|
|
119042
|
+
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
119043
|
+
return noExtension + getJSExtensionForFile(fileName, options);
|
|
118068
119044
|
switch (ending) {
|
|
118069
119045
|
case 0 /* Minimal */:
|
|
118070
119046
|
return ts.removeSuffix(noExtension, "/index");
|
|
@@ -118092,6 +119068,14 @@ var ts;
|
|
|
118092
119068
|
case ".jsx" /* Jsx */:
|
|
118093
119069
|
case ".json" /* Json */:
|
|
118094
119070
|
return ext;
|
|
119071
|
+
case ".d.mts" /* Dmts */:
|
|
119072
|
+
case ".mts" /* Mts */:
|
|
119073
|
+
case ".mjs" /* Mjs */:
|
|
119074
|
+
return ".mjs" /* Mjs */;
|
|
119075
|
+
case ".d.cts" /* Dcts */:
|
|
119076
|
+
case ".cts" /* Cts */:
|
|
119077
|
+
case ".cjs" /* Cjs */:
|
|
119078
|
+
return ".cjs" /* Cjs */;
|
|
118095
119079
|
default:
|
|
118096
119080
|
return undefined;
|
|
118097
119081
|
}
|
|
@@ -118366,7 +119350,7 @@ var ts;
|
|
|
118366
119350
|
case ts.FileIncludeKind.LibFile:
|
|
118367
119351
|
if (reason.index !== undefined)
|
|
118368
119352
|
return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]);
|
|
118369
|
-
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options
|
|
119353
|
+
var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; });
|
|
118370
119354
|
return ts.chainDiagnosticMessages(
|
|
118371
119355
|
/*details*/ undefined, target ?
|
|
118372
119356
|
ts.Diagnostics.Default_library_for_target_0 :
|
|
@@ -118789,7 +119773,7 @@ var ts;
|
|
|
118789
119773
|
}
|
|
118790
119774
|
return host.resolveModuleNames.apply(host, args);
|
|
118791
119775
|
}) :
|
|
118792
|
-
(function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
|
|
119776
|
+
(function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); });
|
|
118793
119777
|
compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
|
|
118794
119778
|
(function () {
|
|
118795
119779
|
var args = [];
|
|
@@ -119517,10 +120501,11 @@ var ts;
|
|
|
119517
120501
|
var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
|
|
119518
120502
|
var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined;
|
|
119519
120503
|
if (!compilerHost.resolveModuleNames) {
|
|
119520
|
-
var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
|
|
119521
|
-
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
|
|
119522
|
-
return ts.
|
|
120504
|
+
var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; };
|
|
120505
|
+
compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) {
|
|
120506
|
+
return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3);
|
|
119523
120507
|
};
|
|
120508
|
+
compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; };
|
|
119524
120509
|
}
|
|
119525
120510
|
if (!compilerHost.resolveTypeReferenceDirectives) {
|
|
119526
120511
|
var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; };
|
|
@@ -121597,6 +122582,12 @@ var ts;
|
|
|
121597
122582
|
ScriptElementKindModifier["jsModifier"] = ".js";
|
|
121598
122583
|
ScriptElementKindModifier["jsxModifier"] = ".jsx";
|
|
121599
122584
|
ScriptElementKindModifier["jsonModifier"] = ".json";
|
|
122585
|
+
ScriptElementKindModifier["dmtsModifier"] = ".d.mts";
|
|
122586
|
+
ScriptElementKindModifier["mtsModifier"] = ".mts";
|
|
122587
|
+
ScriptElementKindModifier["mjsModifier"] = ".mjs";
|
|
122588
|
+
ScriptElementKindModifier["dctsModifier"] = ".d.cts";
|
|
122589
|
+
ScriptElementKindModifier["ctsModifier"] = ".cts";
|
|
122590
|
+
ScriptElementKindModifier["cjsModifier"] = ".cjs";
|
|
121600
122591
|
})(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {}));
|
|
121601
122592
|
var ClassificationTypeNames;
|
|
121602
122593
|
(function (ClassificationTypeNames) {
|
|
@@ -123386,7 +124377,7 @@ var ts;
|
|
|
123386
124377
|
}
|
|
123387
124378
|
ts.programContainsEs6Modules = programContainsEs6Modules;
|
|
123388
124379
|
function compilerOptionsIndicateEs6Modules(compilerOptions) {
|
|
123389
|
-
return !!compilerOptions.module || compilerOptions
|
|
124380
|
+
return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit;
|
|
123390
124381
|
}
|
|
123391
124382
|
ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules;
|
|
123392
124383
|
function createModuleSpecifierResolutionHost(program, host) {
|
|
@@ -126362,6 +127353,12 @@ var ts;
|
|
|
126362
127353
|
case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */;
|
|
126363
127354
|
case ".ts" /* Ts */: return ".ts" /* tsModifier */;
|
|
126364
127355
|
case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */;
|
|
127356
|
+
case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */;
|
|
127357
|
+
case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */;
|
|
127358
|
+
case ".mts" /* Mts */: return ".mts" /* mtsModifier */;
|
|
127359
|
+
case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */;
|
|
127360
|
+
case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */;
|
|
127361
|
+
case ".cts" /* Cts */: return ".cts" /* ctsModifier */;
|
|
126365
127362
|
case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported.");
|
|
126366
127363
|
case undefined: return "" /* none */;
|
|
126367
127364
|
default:
|
|
@@ -126551,15 +127548,18 @@ var ts;
|
|
|
126551
127548
|
var scriptPath = sourceFile.path;
|
|
126552
127549
|
var scriptDirectory = ts.getDirectoryPath(scriptPath);
|
|
126553
127550
|
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue))
|
|
126554
|
-
? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath,
|
|
127551
|
+
? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption())
|
|
126555
127552
|
: getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker);
|
|
127553
|
+
function getIncludeExtensionOption() {
|
|
127554
|
+
var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined;
|
|
127555
|
+
return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
|
|
127556
|
+
}
|
|
126556
127557
|
}
|
|
126557
127558
|
function getExtensionOptions(compilerOptions, includeExtensionsOption) {
|
|
126558
127559
|
if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; }
|
|
126559
|
-
return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption: includeExtensionsOption };
|
|
127560
|
+
return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption };
|
|
126560
127561
|
}
|
|
126561
|
-
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath,
|
|
126562
|
-
var includeExtensions = preferences.importModuleSpecifierEnding === "js" ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */;
|
|
127562
|
+
function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) {
|
|
126563
127563
|
var extensionOptions = getExtensionOptions(compilerOptions, includeExtensions);
|
|
126564
127564
|
if (compilerOptions.rootDirs) {
|
|
126565
127565
|
return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath);
|
|
@@ -126570,8 +127570,8 @@ var ts;
|
|
|
126570
127570
|
}
|
|
126571
127571
|
function getSupportedExtensionsForModuleResolution(compilerOptions) {
|
|
126572
127572
|
var extensions = ts.getSupportedExtensions(compilerOptions);
|
|
126573
|
-
return
|
|
126574
|
-
|
|
127573
|
+
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ?
|
|
127574
|
+
ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) :
|
|
126575
127575
|
extensions;
|
|
126576
127576
|
}
|
|
126577
127577
|
/**
|
|
@@ -126645,11 +127645,11 @@ var ts;
|
|
|
126645
127645
|
}
|
|
126646
127646
|
var foundFileName = void 0;
|
|
126647
127647
|
var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings());
|
|
126648
|
-
if (includeExtensionsOption === 0 /* Exclude */ && !ts.
|
|
127648
|
+
if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) {
|
|
126649
127649
|
foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath));
|
|
126650
127650
|
foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath));
|
|
126651
127651
|
}
|
|
126652
|
-
else if (includeExtensionsOption === 2 /* ModuleSpecifierCompletion */ && outputExtension) {
|
|
127652
|
+
else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) {
|
|
126653
127653
|
foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension);
|
|
126654
127654
|
foundFiles.set(foundFileName, outputExtension);
|
|
126655
127655
|
}
|
|
@@ -127249,15 +128249,15 @@ var ts;
|
|
|
127249
128249
|
var entries = [];
|
|
127250
128250
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
127251
128251
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
127252
|
-
/* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions
|
|
127253
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions
|
|
128252
|
+
/* contextToken */ undefined, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128253
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
127254
128254
|
}
|
|
127255
128255
|
else {
|
|
127256
128256
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
127257
128257
|
return undefined;
|
|
127258
128258
|
}
|
|
127259
128259
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
127260
|
-
/* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions
|
|
128260
|
+
/* contextToken */ undefined, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
127261
128261
|
}
|
|
127262
128262
|
if (keywordFilters !== 0 /* None */) {
|
|
127263
128263
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -127363,7 +128363,7 @@ var ts;
|
|
|
127363
128363
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
127364
128364
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
127365
128365
|
}
|
|
127366
|
-
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) {
|
|
128366
|
+
function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, options, preferences) {
|
|
127367
128367
|
var _a;
|
|
127368
128368
|
var insertText;
|
|
127369
128369
|
var replacementSpan = ts.getReplacementSpanForContextToken(contextToken);
|
|
@@ -127417,7 +128417,7 @@ var ts;
|
|
|
127417
128417
|
if (originIsResolvedExport(origin)) {
|
|
127418
128418
|
sourceDisplay = [ts.textPart(origin.moduleSpecifier)];
|
|
127419
128419
|
if (importCompletionNode) {
|
|
127420
|
-
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
128420
|
+
(_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnlyImport, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan);
|
|
127421
128421
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
127422
128422
|
}
|
|
127423
128423
|
}
|
|
@@ -127490,7 +128490,7 @@ var ts;
|
|
|
127490
128490
|
moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined,
|
|
127491
128491
|
};
|
|
127492
128492
|
}
|
|
127493
|
-
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) {
|
|
128493
|
+
function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, isTypeOnly, origin, useSemicolons, options, preferences) {
|
|
127494
128494
|
var sourceFile = importCompletionNode.getSourceFile();
|
|
127495
128495
|
var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile);
|
|
127496
128496
|
var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier);
|
|
@@ -127499,12 +128499,13 @@ var ts;
|
|
|
127499
128499
|
0 /* Named */;
|
|
127500
128500
|
var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : "";
|
|
127501
128501
|
var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true);
|
|
128502
|
+
var typeOnlyPrefix = isTypeOnly ? " " + ts.tokenToString(151 /* TypeKeyword */) + " " : " ";
|
|
127502
128503
|
var suffix = useSemicolons ? ";" : "";
|
|
127503
128504
|
switch (importKind) {
|
|
127504
|
-
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import
|
|
127505
|
-
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import
|
|
127506
|
-
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
127507
|
-
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
128505
|
+
case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
|
|
128506
|
+
case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
|
|
128507
|
+
case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
|
|
128508
|
+
case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + typeOnlyPrefix + "{ " + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
|
|
127508
128509
|
}
|
|
127509
128510
|
}
|
|
127510
128511
|
function quotePropertyName(sourceFile, preferences, name) {
|
|
@@ -127533,6 +128534,7 @@ var ts;
|
|
|
127533
128534
|
var start = ts.timestamp();
|
|
127534
128535
|
var variableDeclaration = getVariableDeclaration(location);
|
|
127535
128536
|
var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
|
|
128537
|
+
var isTypeOnlyImport = !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent);
|
|
127536
128538
|
// Tracks unique names.
|
|
127537
128539
|
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
|
127538
128540
|
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
|
@@ -127548,7 +128550,7 @@ var ts;
|
|
|
127548
128550
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
127549
128551
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
127550
128552
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
127551
|
-
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences);
|
|
128553
|
+
var entry = createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, isTypeOnlyImport, useSemicolons, compilerOptions, preferences);
|
|
127552
128554
|
if (!entry) {
|
|
127553
128555
|
continue;
|
|
127554
128556
|
}
|
|
@@ -127670,7 +128672,7 @@ var ts;
|
|
|
127670
128672
|
// completion entry.
|
|
127671
128673
|
return ts.firstDefined(symbols, function (symbol, index) {
|
|
127672
128674
|
var origin = symbolToOriginInfoMap[index];
|
|
127673
|
-
var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions
|
|
128675
|
+
var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
|
|
127674
128676
|
return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
|
|
127675
128677
|
? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
|
|
127676
128678
|
: undefined;
|
|
@@ -127747,7 +128749,7 @@ var ts;
|
|
|
127747
128749
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
127748
128750
|
var moduleSymbol = origin.moduleSymbol;
|
|
127749
128751
|
var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
127750
|
-
var _b = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions
|
|
128752
|
+
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;
|
|
127751
128753
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
127752
128754
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
127753
128755
|
}
|
|
@@ -128449,6 +129451,7 @@ var ts;
|
|
|
128449
129451
|
}
|
|
128450
129452
|
function isTypeOnlyCompletion() {
|
|
128451
129453
|
return insideJsDocTagTypeExpression
|
|
129454
|
+
|| !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent)
|
|
128452
129455
|
|| !isContextTokenValueLocation(contextToken) &&
|
|
128453
129456
|
(ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker)
|
|
128454
129457
|
|| ts.isPartOfTypeNode(location)
|
|
@@ -130300,7 +131303,7 @@ var ts;
|
|
|
130300
131303
|
}
|
|
130301
131304
|
function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
|
|
130302
131305
|
scriptKind = ts.ensureScriptKind(fileName, scriptKind);
|
|
130303
|
-
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings
|
|
131306
|
+
var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
|
|
130304
131307
|
var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
|
|
130305
131308
|
var bucketEntry = bucket.get(path);
|
|
130306
131309
|
var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
|
|
@@ -131579,7 +132582,7 @@ var ts;
|
|
|
131579
132582
|
if (!options.implementations && ts.isStringLiteralLike(node)) {
|
|
131580
132583
|
if (ts.isModuleSpecifierLike(node)) {
|
|
131581
132584
|
var fileIncludeReasons = program.getFileIncludeReasons();
|
|
131582
|
-
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;
|
|
132585
|
+
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;
|
|
131583
132586
|
var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined;
|
|
131584
132587
|
if (referencedFile) {
|
|
131585
132588
|
return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }];
|
|
@@ -133737,9 +134740,10 @@ var ts;
|
|
|
133737
134740
|
return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true };
|
|
133738
134741
|
}
|
|
133739
134742
|
else {
|
|
134743
|
+
var mode = ts.getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
133740
134744
|
var resolved = host.resolveModuleNames
|
|
133741
|
-
? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName)
|
|
133742
|
-
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName);
|
|
134745
|
+
? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode)
|
|
134746
|
+
: program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
133743
134747
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
133744
134748
|
}
|
|
133745
134749
|
}
|
|
@@ -133964,10 +134968,10 @@ var ts;
|
|
|
133964
134968
|
var file = program.getLibFileFromReference(libReferenceDirective);
|
|
133965
134969
|
return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false };
|
|
133966
134970
|
}
|
|
133967
|
-
if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) {
|
|
134971
|
+
if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) {
|
|
133968
134972
|
var node = ts.getTokenAtPosition(sourceFile, position);
|
|
133969
|
-
if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) {
|
|
133970
|
-
var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
134973
|
+
if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) {
|
|
134974
|
+
var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName;
|
|
133971
134975
|
var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text);
|
|
133972
134976
|
return {
|
|
133973
134977
|
file: program.getSourceFile(fileName),
|
|
@@ -138676,7 +139680,7 @@ var ts;
|
|
|
138676
139680
|
var name = importNameForConvertToDefaultImport(importNode);
|
|
138677
139681
|
if (!name)
|
|
138678
139682
|
continue;
|
|
138679
|
-
var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text);
|
|
139683
|
+
var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
|
|
138680
139684
|
var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
|
|
138681
139685
|
if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
|
138682
139686
|
diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
|
|
@@ -139576,7 +140580,7 @@ var ts;
|
|
|
139576
140580
|
options.allowNonTsExtensions = true;
|
|
139577
140581
|
// if jsx is specified then treat file as .tsx
|
|
139578
140582
|
var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
|
|
139579
|
-
var sourceFile = ts.createSourceFile(inputFileName, input, options
|
|
140583
|
+
var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
|
|
139580
140584
|
if (transpileOptions.moduleName) {
|
|
139581
140585
|
sourceFile.moduleName = transpileOptions.moduleName;
|
|
139582
140586
|
}
|
|
@@ -145163,7 +146167,7 @@ var ts;
|
|
|
145163
146167
|
return propName;
|
|
145164
146168
|
}
|
|
145165
146169
|
if (ts.isStringLiteralLike(propName)) {
|
|
145166
|
-
return ts.isIdentifierText(propName.text, compilerOptions
|
|
146170
|
+
return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text)
|
|
145167
146171
|
: ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */)
|
|
145168
146172
|
: propName;
|
|
145169
146173
|
}
|
|
@@ -145911,7 +146915,7 @@ var ts;
|
|
|
145911
146915
|
getCodeActions: function (context) {
|
|
145912
146916
|
var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences;
|
|
145913
146917
|
var changes = ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
145914
|
-
var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions()
|
|
146918
|
+
var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences));
|
|
145915
146919
|
if (moduleExportsChangedToDefault) {
|
|
145916
146920
|
for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
|
|
145917
146921
|
var importingFile = _a[_i];
|
|
@@ -145926,7 +146930,7 @@ var ts;
|
|
|
145926
146930
|
function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) {
|
|
145927
146931
|
for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) {
|
|
145928
146932
|
var moduleSpecifier = _a[_i];
|
|
145929
|
-
var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text);
|
|
146933
|
+
var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text, ts.getModeForUsageLocation(importingFile, moduleSpecifier));
|
|
145930
146934
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
145931
146935
|
continue;
|
|
145932
146936
|
}
|
|
@@ -146880,7 +147884,7 @@ var ts;
|
|
|
146880
147884
|
return;
|
|
146881
147885
|
}
|
|
146882
147886
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
146883
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions
|
|
147887
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
146884
147888
|
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 });
|
|
146885
147889
|
}
|
|
146886
147890
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
@@ -147175,6 +148179,9 @@ var ts;
|
|
|
147175
148179
|
case ts.ModuleKind.None:
|
|
147176
148180
|
// Fall back to the `import * as ns` style import.
|
|
147177
148181
|
return 2 /* Namespace */;
|
|
148182
|
+
case ts.ModuleKind.Node12:
|
|
148183
|
+
case ts.ModuleKind.NodeNext:
|
|
148184
|
+
return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */;
|
|
147178
148185
|
default:
|
|
147179
148186
|
return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind);
|
|
147180
148187
|
}
|
|
@@ -147229,7 +148236,7 @@ var ts;
|
|
|
147229
148236
|
cancellationToken.throwIfCancellationRequested();
|
|
147230
148237
|
var compilerOptions = program.getCompilerOptions();
|
|
147231
148238
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
147232
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions
|
|
148239
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
147233
148240
|
addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
|
|
147234
148241
|
}
|
|
147235
148242
|
// check exports with the same name
|
|
@@ -147751,14 +148758,14 @@ var ts;
|
|
|
147751
148758
|
if (!info)
|
|
147752
148759
|
return undefined;
|
|
147753
148760
|
var node = info.node, suggestedSymbol = info.suggestedSymbol;
|
|
147754
|
-
var target = context.host.getCompilationSettings()
|
|
148761
|
+
var target = ts.getEmitScriptTarget(context.host.getCompilationSettings());
|
|
147755
148762
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, node, suggestedSymbol, target); });
|
|
147756
148763
|
return [codefix.createCodeFixAction("spelling", changes, [ts.Diagnostics.Change_spelling_to_0, ts.symbolName(suggestedSymbol)], fixId, ts.Diagnostics.Fix_all_detected_spelling_errors)];
|
|
147757
148764
|
},
|
|
147758
148765
|
fixIds: [fixId],
|
|
147759
148766
|
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
147760
148767
|
var info = getInfo(diag.file, diag.start, context, diag.code);
|
|
147761
|
-
var target = context.host.getCompilationSettings()
|
|
148768
|
+
var target = ts.getEmitScriptTarget(context.host.getCompilationSettings());
|
|
147762
148769
|
if (info)
|
|
147763
148770
|
doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
147764
148771
|
}); },
|
|
@@ -147784,6 +148791,10 @@ var ts;
|
|
|
147784
148791
|
}
|
|
147785
148792
|
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType);
|
|
147786
148793
|
}
|
|
148794
|
+
else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) {
|
|
148795
|
+
var receiverType = checker.getTypeAtLocation(parent.right);
|
|
148796
|
+
suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType);
|
|
148797
|
+
}
|
|
147787
148798
|
else if (ts.isQualifiedName(parent) && parent.right === node) {
|
|
147788
148799
|
var symbol = checker.getSymbolAtLocation(parent.left);
|
|
147789
148800
|
if (symbol && symbol.flags & 1536 /* Module */) {
|
|
@@ -147851,7 +148862,7 @@ var ts;
|
|
|
147851
148862
|
function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration) {
|
|
147852
148863
|
if (!importDeclaration || !ts.isStringLiteralLike(importDeclaration.moduleSpecifier))
|
|
147853
148864
|
return undefined;
|
|
147854
|
-
var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text);
|
|
148865
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier));
|
|
147855
148866
|
if (!resolvedModule)
|
|
147856
148867
|
return undefined;
|
|
147857
148868
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -148898,8 +149909,8 @@ var ts;
|
|
|
148898
149909
|
(function (codefix) {
|
|
148899
149910
|
codefix.registerCodeFix({
|
|
148900
149911
|
errorCodes: [
|
|
148901
|
-
ts.Diagnostics.
|
|
148902
|
-
ts.Diagnostics.
|
|
149912
|
+
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,
|
|
149913
|
+
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,
|
|
148903
149914
|
],
|
|
148904
149915
|
getCodeActions: function (context) {
|
|
148905
149916
|
var compilerOptions = context.program.getCompilerOptions();
|
|
@@ -149028,7 +150039,7 @@ var ts;
|
|
|
149028
150039
|
var didYouMeanStaticMemberCode = ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
149029
150040
|
var errorCodes = [
|
|
149030
150041
|
ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
149031
|
-
ts.Diagnostics.
|
|
150042
|
+
ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression.code,
|
|
149032
150043
|
didYouMeanStaticMemberCode,
|
|
149033
150044
|
];
|
|
149034
150045
|
codefix.registerCodeFix({
|
|
@@ -149051,7 +150062,7 @@ var ts;
|
|
|
149051
150062
|
});
|
|
149052
150063
|
function getInfo(sourceFile, pos, diagCode) {
|
|
149053
150064
|
var node = ts.getTokenAtPosition(sourceFile, pos);
|
|
149054
|
-
if (ts.isIdentifier(node)) {
|
|
150065
|
+
if (ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) {
|
|
149055
150066
|
return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined };
|
|
149056
150067
|
}
|
|
149057
150068
|
}
|