typescript 5.4.0-dev.20240118 → 5.4.0-dev.20240120
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/cancellationToken.js +0 -1
- package/lib/tsc.js +186 -164
- package/lib/tsserver.js +687 -435
- package/lib/typescript.d.ts +51 -11
- package/lib/typescript.js +730 -468
- package/lib/typingsInstaller.js +23 -25
- package/package.json +28 -28
package/lib/tsserver.js
CHANGED
|
@@ -1042,6 +1042,7 @@ __export(server_exports, {
|
|
|
1042
1042
|
getStaticPropertiesAndClassStaticBlock: () => getStaticPropertiesAndClassStaticBlock,
|
|
1043
1043
|
getStrictOptionValue: () => getStrictOptionValue,
|
|
1044
1044
|
getStringComparer: () => getStringComparer,
|
|
1045
|
+
getSubPatternFromSpec: () => getSubPatternFromSpec,
|
|
1045
1046
|
getSuperCallFromStatement: () => getSuperCallFromStatement,
|
|
1046
1047
|
getSuperContainer: () => getSuperContainer,
|
|
1047
1048
|
getSupportedCodeFixes: () => getSupportedCodeFixes,
|
|
@@ -2128,7 +2129,6 @@ __export(server_exports, {
|
|
|
2128
2129
|
setValueDeclaration: () => setValueDeclaration,
|
|
2129
2130
|
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
|
|
2130
2131
|
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
|
|
2131
|
-
shouldResolveJsRequire: () => shouldResolveJsRequire,
|
|
2132
2132
|
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
|
|
2133
2133
|
showModuleSpecifier: () => showModuleSpecifier,
|
|
2134
2134
|
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
|
|
@@ -2291,7 +2291,6 @@ __export(server_exports, {
|
|
|
2291
2291
|
typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
|
|
2292
2292
|
typeKeywords: () => typeKeywords,
|
|
2293
2293
|
typeParameterNamePart: () => typeParameterNamePart,
|
|
2294
|
-
typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
|
|
2295
2294
|
typeToDisplayParts: () => typeToDisplayParts,
|
|
2296
2295
|
unchangedPollThresholds: () => unchangedPollThresholds,
|
|
2297
2296
|
unchangedTextChangeRange: () => unchangedTextChangeRange,
|
|
@@ -2341,7 +2340,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2341
2340
|
|
|
2342
2341
|
// src/compiler/corePublic.ts
|
|
2343
2342
|
var versionMajorMinor = "5.4";
|
|
2344
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2343
|
+
var version = `${versionMajorMinor}.0-dev.20240120`;
|
|
2345
2344
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2346
2345
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2347
2346
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6510,7 +6509,7 @@ var SymbolFlags = /* @__PURE__ */ ((SymbolFlags3) => {
|
|
|
6510
6509
|
SymbolFlags3[SymbolFlags3["Transient"] = 33554432] = "Transient";
|
|
6511
6510
|
SymbolFlags3[SymbolFlags3["Assignment"] = 67108864] = "Assignment";
|
|
6512
6511
|
SymbolFlags3[SymbolFlags3["ModuleExports"] = 134217728] = "ModuleExports";
|
|
6513
|
-
SymbolFlags3[SymbolFlags3["All"] =
|
|
6512
|
+
SymbolFlags3[SymbolFlags3["All"] = -1] = "All";
|
|
6514
6513
|
SymbolFlags3[SymbolFlags3["Enum"] = 384] = "Enum";
|
|
6515
6514
|
SymbolFlags3[SymbolFlags3["Variable"] = 3] = "Variable";
|
|
6516
6515
|
SymbolFlags3[SymbolFlags3["Value"] = 111551] = "Value";
|
|
@@ -6936,6 +6935,7 @@ var ModuleKind = /* @__PURE__ */ ((ModuleKind3) => {
|
|
|
6936
6935
|
ModuleKind3[ModuleKind3["ESNext"] = 99] = "ESNext";
|
|
6937
6936
|
ModuleKind3[ModuleKind3["Node16"] = 100] = "Node16";
|
|
6938
6937
|
ModuleKind3[ModuleKind3["NodeNext"] = 199] = "NodeNext";
|
|
6938
|
+
ModuleKind3[ModuleKind3["Preserve"] = 200] = "Preserve";
|
|
6939
6939
|
return ModuleKind3;
|
|
6940
6940
|
})(ModuleKind || {});
|
|
6941
6941
|
var JsxEmit = /* @__PURE__ */ ((JsxEmit3) => {
|
|
@@ -9574,7 +9574,7 @@ var Diagnostics = {
|
|
|
9574
9574
|
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, 1 /* 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."),
|
|
9575
9575
|
_0_was_imported_here: diag(1376, 3 /* Message */, "_0_was_imported_here_1376", "'{0}' was imported here."),
|
|
9576
9576
|
_0_was_exported_here: diag(1377, 3 /* Message */, "_0_was_exported_here_1377", "'{0}' was exported here."),
|
|
9577
|
-
|
|
9577
|
+
Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, 1 /* Error */, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
|
|
9578
9578
|
An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, 1 /* 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'."),
|
|
9579
9579
|
An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, 1 /* 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'."),
|
|
9580
9580
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, 1 /* Error */, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
@@ -9625,7 +9625,7 @@ var Diagnostics = {
|
|
|
9625
9625
|
File_redirects_to_file_0: diag(1429, 3 /* Message */, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
|
|
9626
9626
|
The_file_is_in_the_program_because_Colon: diag(1430, 3 /* Message */, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
|
|
9627
9627
|
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, 1 /* 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."),
|
|
9628
|
-
|
|
9628
|
+
Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, 1 /* Error */, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_nod_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
|
|
9629
9629
|
Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters: diag(1433, 1 /* Error */, "Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters_1433", "Neither decorators nor modifiers may be applied to 'this' parameters."),
|
|
9630
9630
|
Unexpected_keyword_or_identifier: diag(1434, 1 /* Error */, "Unexpected_keyword_or_identifier_1434", "Unexpected keyword or identifier."),
|
|
9631
9631
|
Unknown_keyword_or_identifier_Did_you_mean_0: diag(1435, 1 /* Error */, "Unknown_keyword_or_identifier_Did_you_mean_0_1435", "Unknown keyword or identifier. Did you mean '{0}'?"),
|
|
@@ -10208,9 +10208,9 @@ var Diagnostics = {
|
|
|
10208
10208
|
Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializers: diag(2818, 1 /* Error */, "Duplicate_identifier_0_Compiler_reserves_name_1_when_emitting_super_references_in_static_initializer_2818", "Duplicate identifier '{0}'. Compiler reserves name '{1}' when emitting 'super' references in static initializers."),
|
|
10209
10209
|
Namespace_name_cannot_be_0: diag(2819, 1 /* Error */, "Namespace_name_cannot_be_0_2819", "Namespace name cannot be '{0}'."),
|
|
10210
10210
|
Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, 1 /* Error */, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"),
|
|
10211
|
-
|
|
10211
|
+
Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve: diag(2821, 1 /* Error */, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve_2821", "Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'."),
|
|
10212
10212
|
Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, 1 /* Error */, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
|
|
10213
|
-
|
|
10213
|
+
Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve: diag(2823, 1 /* Error */, "Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve_2823", "Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'."),
|
|
10214
10214
|
Cannot_find_namespace_0_Did_you_mean_1: diag(2833, 1 /* Error */, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
|
|
10215
10215
|
Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, 1 /* Error */, "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path."),
|
|
10216
10216
|
Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0: diag(2835, 1 /* Error */, "Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean '{0}'?"),
|
|
@@ -10230,7 +10230,7 @@ var Diagnostics = {
|
|
|
10230
10230
|
The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_Symbol_dispose_method_or_be_null_or_undefined: diag(2851, 1 /* Error */, "The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_2851", "The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'."),
|
|
10231
10231
|
await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(2852, 1 /* Error */, "await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_2852", "'await using' statements are only allowed within async functions and at the top levels of modules."),
|
|
10232
10232
|
await_using_statements_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(2853, 1 /* Error */, "await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_th_2853", "'await using' statements 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."),
|
|
10233
|
-
|
|
10233
|
+
Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher: diag(2854, 1 /* Error */, "Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_sys_2854", "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher."),
|
|
10234
10234
|
Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super: diag(2855, 1 /* Error */, "Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super_2855", "Class field '{0}' defined by the parent class is not accessible in the child class via super."),
|
|
10235
10235
|
Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls: diag(2856, 1 /* Error */, "Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls_2856", "Import attributes are not allowed on statements that compile to CommonJS 'require' calls."),
|
|
10236
10236
|
Import_attributes_cannot_be_used_with_type_only_imports_or_exports: diag(2857, 1 /* Error */, "Import_attributes_cannot_be_used_with_type_only_imports_or_exports_2857", "Import attributes cannot be used with type-only imports or exports."),
|
|
@@ -10386,7 +10386,7 @@ var Diagnostics = {
|
|
|
10386
10386
|
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: diag(5068, 1 /* Error */, "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068", "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig."),
|
|
10387
10387
|
Option_0_cannot_be_specified_without_specifying_option_1_or_option_2: diag(5069, 1 /* Error */, "Option_0_cannot_be_specified_without_specifying_option_1_or_option_2_5069", "Option '{0}' cannot be specified without specifying option '{1}' or option '{2}'."),
|
|
10388
10388
|
Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic: diag(5070, 1 /* Error */, "Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic_5070", "Option '--resolveJsonModule' cannot be specified when 'moduleResolution' is set to 'classic'."),
|
|
10389
|
-
|
|
10389
|
+
Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd: diag(5071, 1 /* Error */, "Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd_5071", "Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'."),
|
|
10390
10390
|
Unknown_build_option_0: diag(5072, 1 /* Error */, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
|
|
10391
10391
|
Build_option_0_requires_a_value_of_type_1: diag(5073, 1 /* Error */, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."),
|
|
10392
10392
|
Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, 1 /* Error */, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."),
|
|
@@ -10409,7 +10409,7 @@ var Diagnostics = {
|
|
|
10409
10409
|
The_root_value_of_a_0_file_must_be_an_object: diag(5092, 1 /* Error */, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."),
|
|
10410
10410
|
Compiler_option_0_may_only_be_used_with_build: diag(5093, 1 /* Error */, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."),
|
|
10411
10411
|
Compiler_option_0_may_not_be_used_with_build: diag(5094, 1 /* Error */, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."),
|
|
10412
|
-
|
|
10412
|
+
Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later: diag(5095, 1 /* Error */, "Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later_5095", "Option '{0}' can only be used when 'module' is set to 'preserve' or to 'es2015' or later."),
|
|
10413
10413
|
Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set: diag(5096, 1 /* Error */, "Option_allowImportingTsExtensions_can_only_be_used_when_either_noEmit_or_emitDeclarationOnly_is_set_5096", "Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set."),
|
|
10414
10414
|
An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled: diag(5097, 1 /* Error */, "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097", "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled."),
|
|
10415
10415
|
Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler: diag(5098, 1 /* Error */, "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler_5098", "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'."),
|
|
@@ -11329,6 +11329,12 @@ var Diagnostics = {
|
|
|
11329
11329
|
Could_not_find_variable_to_inline: diag(95185, 3 /* Message */, "Could_not_find_variable_to_inline_95185", "Could not find variable to inline."),
|
|
11330
11330
|
Variables_with_multiple_declarations_cannot_be_inlined: diag(95186, 3 /* Message */, "Variables_with_multiple_declarations_cannot_be_inlined_95186", "Variables with multiple declarations cannot be inlined."),
|
|
11331
11331
|
Add_missing_comma_for_object_member_completion_0: diag(95187, 3 /* Message */, "Add_missing_comma_for_object_member_completion_0_95187", "Add missing comma for object member completion '{0}'."),
|
|
11332
|
+
Add_missing_parameter_to_0: diag(95188, 3 /* Message */, "Add_missing_parameter_to_0_95188", "Add missing parameter to '{0}'"),
|
|
11333
|
+
Add_missing_parameters_to_0: diag(95189, 3 /* Message */, "Add_missing_parameters_to_0_95189", "Add missing parameters to '{0}'"),
|
|
11334
|
+
Add_all_missing_parameters: diag(95190, 3 /* Message */, "Add_all_missing_parameters_95190", "Add all missing parameters"),
|
|
11335
|
+
Add_optional_parameter_to_0: diag(95191, 3 /* Message */, "Add_optional_parameter_to_0_95191", "Add optional parameter to '{0}'"),
|
|
11336
|
+
Add_optional_parameters_to_0: diag(95192, 3 /* Message */, "Add_optional_parameters_to_0_95192", "Add optional parameters to '{0}'"),
|
|
11337
|
+
Add_all_optional_parameters: diag(95193, 3 /* Message */, "Add_all_optional_parameters_95193", "Add all optional parameters"),
|
|
11332
11338
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
11333
11339
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
11334
11340
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -15354,14 +15360,12 @@ function packageIdToString(packageId) {
|
|
|
15354
15360
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
15355
15361
|
return oldResolution === newResolution || oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective || !!oldResolution.resolvedTypeReferenceDirective && !!newResolution.resolvedTypeReferenceDirective && oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName && !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary && oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath;
|
|
15356
15362
|
}
|
|
15357
|
-
function hasChangesInResolutions(names,
|
|
15363
|
+
function hasChangesInResolutions(names, newResolutions, getOldResolution, comparer) {
|
|
15358
15364
|
Debug.assert(names.length === newResolutions.length);
|
|
15359
15365
|
for (let i = 0; i < names.length; i++) {
|
|
15360
15366
|
const newResolution = newResolutions[i];
|
|
15361
15367
|
const entry = names[i];
|
|
15362
|
-
const
|
|
15363
|
-
const mode = nameAndModeGetter.getMode(entry, newSourceFile);
|
|
15364
|
-
const oldResolution = getOldResolution(name, mode);
|
|
15368
|
+
const oldResolution = getOldResolution(entry);
|
|
15365
15369
|
const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution;
|
|
15366
15370
|
if (changed) {
|
|
15367
15371
|
return true;
|
|
@@ -20628,6 +20632,9 @@ var computedOptions = createComputedCompilerOptions({
|
|
|
20628
20632
|
case 199 /* NodeNext */:
|
|
20629
20633
|
moduleResolution = 99 /* NodeNext */;
|
|
20630
20634
|
break;
|
|
20635
|
+
case 200 /* Preserve */:
|
|
20636
|
+
moduleResolution = 100 /* Bundler */;
|
|
20637
|
+
break;
|
|
20631
20638
|
default:
|
|
20632
20639
|
moduleResolution = 1 /* Classic */;
|
|
20633
20640
|
break;
|
|
@@ -20657,6 +20664,7 @@ var computedOptions = createComputedCompilerOptions({
|
|
|
20657
20664
|
switch (computedOptions.module.computeValue(compilerOptions)) {
|
|
20658
20665
|
case 100 /* Node16 */:
|
|
20659
20666
|
case 199 /* NodeNext */:
|
|
20667
|
+
case 200 /* Preserve */:
|
|
20660
20668
|
return true;
|
|
20661
20669
|
}
|
|
20662
20670
|
return false;
|
|
@@ -20824,18 +20832,12 @@ function emitModuleKindIsNonNodeESM(moduleKind) {
|
|
|
20824
20832
|
}
|
|
20825
20833
|
function hasJsonModuleEmitEnabled(options) {
|
|
20826
20834
|
switch (getEmitModuleKind(options)) {
|
|
20827
|
-
case
|
|
20828
|
-
case
|
|
20829
|
-
case
|
|
20830
|
-
case 6 /* ES2020 */:
|
|
20831
|
-
case 7 /* ES2022 */:
|
|
20832
|
-
case 99 /* ESNext */:
|
|
20833
|
-
case 100 /* Node16 */:
|
|
20834
|
-
case 199 /* NodeNext */:
|
|
20835
|
-
return true;
|
|
20836
|
-
default:
|
|
20835
|
+
case 0 /* None */:
|
|
20836
|
+
case 4 /* System */:
|
|
20837
|
+
case 3 /* UMD */:
|
|
20837
20838
|
return false;
|
|
20838
20839
|
}
|
|
20840
|
+
return true;
|
|
20839
20841
|
}
|
|
20840
20842
|
function importNameElisionDisabled(options) {
|
|
20841
20843
|
return options.verbatimModuleSyntax || options.isolatedModules && options.preserveValueImports;
|
|
@@ -20849,9 +20851,6 @@ function unusedLabelIsError(options) {
|
|
|
20849
20851
|
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
|
|
20850
20852
|
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
|
|
20851
20853
|
}
|
|
20852
|
-
function shouldResolveJsRequire(compilerOptions) {
|
|
20853
|
-
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
|
|
20854
|
-
}
|
|
20855
20854
|
function getStrictOptionValue(compilerOptions, flag) {
|
|
20856
20855
|
return compilerOptions[flag] === void 0 ? !!compilerOptions.strict : !!compilerOptions[flag];
|
|
20857
20856
|
}
|
|
@@ -21028,7 +21027,7 @@ function getPatternFromSpec(spec, basePath, usage) {
|
|
|
21028
21027
|
const pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
|
|
21029
21028
|
return pattern && `^(${pattern})${usage === "exclude" ? "($|/)" : "$"}`;
|
|
21030
21029
|
}
|
|
21031
|
-
function getSubPatternFromSpec(spec, basePath, usage, { singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter: replaceWildcardCharacter2 }) {
|
|
21030
|
+
function getSubPatternFromSpec(spec, basePath, usage, { singleAsteriskRegexFragment, doubleAsteriskRegexFragment, replaceWildcardCharacter: replaceWildcardCharacter2 } = wildcardMatchers[usage]) {
|
|
21032
21031
|
let subpattern = "";
|
|
21033
21032
|
let hasWrittenComponent = false;
|
|
21034
21033
|
const components = getNormalizedPathComponents(spec, basePath);
|
|
@@ -21248,7 +21247,8 @@ function usesExtensionsOnImports({ imports }, hasExtension2 = or(hasJSFileExtens
|
|
|
21248
21247
|
return firstDefined(imports, ({ text }) => pathIsRelative(text) && !fileExtensionIsOneOf(text, extensionsNotSupportingExtensionlessResolution) ? hasExtension2(text) : void 0) || false;
|
|
21249
21248
|
}
|
|
21250
21249
|
function getModuleSpecifierEndingPreference(preference, resolutionMode, compilerOptions, sourceFile) {
|
|
21251
|
-
|
|
21250
|
+
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
21251
|
+
if (preference === "js" || resolutionMode === 99 /* ESNext */ && 3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */) {
|
|
21252
21252
|
if (!shouldAllowImportingTsExtension(compilerOptions)) {
|
|
21253
21253
|
return 2 /* JsExtension */;
|
|
21254
21254
|
}
|
|
@@ -38868,7 +38868,8 @@ var moduleOptionDeclaration = {
|
|
|
38868
38868
|
es2022: 7 /* ES2022 */,
|
|
38869
38869
|
esnext: 99 /* ESNext */,
|
|
38870
38870
|
node16: 100 /* Node16 */,
|
|
38871
|
-
nodenext: 199 /* NodeNext
|
|
38871
|
+
nodenext: 199 /* NodeNext */,
|
|
38872
|
+
preserve: 200 /* Preserve */
|
|
38872
38873
|
})),
|
|
38873
38874
|
affectsSourceFile: true,
|
|
38874
38875
|
affectsModuleResolution: true,
|
|
@@ -42576,20 +42577,7 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
|
|
|
42576
42577
|
} else {
|
|
42577
42578
|
let moduleResolution = compilerOptions.moduleResolution;
|
|
42578
42579
|
if (moduleResolution === void 0) {
|
|
42579
|
-
|
|
42580
|
-
case 1 /* CommonJS */:
|
|
42581
|
-
moduleResolution = 2 /* Node10 */;
|
|
42582
|
-
break;
|
|
42583
|
-
case 100 /* Node16 */:
|
|
42584
|
-
moduleResolution = 3 /* Node16 */;
|
|
42585
|
-
break;
|
|
42586
|
-
case 199 /* NodeNext */:
|
|
42587
|
-
moduleResolution = 99 /* NodeNext */;
|
|
42588
|
-
break;
|
|
42589
|
-
default:
|
|
42590
|
-
moduleResolution = 1 /* Classic */;
|
|
42591
|
-
break;
|
|
42592
|
-
}
|
|
42580
|
+
moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
42593
42581
|
if (traceEnabled) {
|
|
42594
42582
|
trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]);
|
|
42595
42583
|
}
|
|
@@ -46466,7 +46454,7 @@ function createBinder() {
|
|
|
46466
46454
|
} else if (isJsonSourceFile(file)) {
|
|
46467
46455
|
bindSourceFileAsExternalModule();
|
|
46468
46456
|
const originalSymbol = file.symbol;
|
|
46469
|
-
declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */,
|
|
46457
|
+
declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, -1 /* All */);
|
|
46470
46458
|
file.symbol = originalSymbol;
|
|
46471
46459
|
}
|
|
46472
46460
|
}
|
|
@@ -46478,7 +46466,7 @@ function createBinder() {
|
|
|
46478
46466
|
bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node));
|
|
46479
46467
|
} else {
|
|
46480
46468
|
const flags = exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */;
|
|
46481
|
-
const symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags,
|
|
46469
|
+
const symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, -1 /* All */);
|
|
46482
46470
|
if (node.isExportEquals) {
|
|
46483
46471
|
setValueDeclaration(symbol, node);
|
|
46484
46472
|
}
|
|
@@ -46931,7 +46919,7 @@ function createBinder() {
|
|
|
46931
46919
|
}
|
|
46932
46920
|
if (!isBindingPattern(node.name)) {
|
|
46933
46921
|
const possibleVariableDecl = node.kind === 260 /* VariableDeclaration */ ? node : node.parent.parent;
|
|
46934
|
-
if (isInJSFile(node) &&
|
|
46922
|
+
if (isInJSFile(node) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 32 /* Export */)) {
|
|
46935
46923
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
46936
46924
|
} else if (isBlockOrCatchScoped(node)) {
|
|
46937
46925
|
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
|
|
@@ -47505,7 +47493,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
47505
47493
|
(reason) => {
|
|
47506
47494
|
if (reason.kind !== 3 /* Import */ || reason.file !== importingSourceFile.path)
|
|
47507
47495
|
return void 0;
|
|
47508
|
-
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index))
|
|
47496
|
+
if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions))
|
|
47509
47497
|
return void 0;
|
|
47510
47498
|
const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
|
|
47511
47499
|
return preferences.relativePreference !== 1 /* NonRelative */ || !pathIsRelative(specifier) ? specifier : void 0;
|
|
@@ -48367,7 +48355,7 @@ function createTypeChecker(host) {
|
|
|
48367
48355
|
var requestedExternalEmitHelpers;
|
|
48368
48356
|
var externalHelpersModule;
|
|
48369
48357
|
var Symbol47 = objectAllocator.getSymbolConstructor();
|
|
48370
|
-
var
|
|
48358
|
+
var Type28 = objectAllocator.getTypeConstructor();
|
|
48371
48359
|
var Signature14 = objectAllocator.getSignatureConstructor();
|
|
48372
48360
|
var typeCount = 0;
|
|
48373
48361
|
var symbolCount = 0;
|
|
@@ -49098,14 +49086,6 @@ function createTypeChecker(host) {
|
|
|
49098
49086
|
emptyArray,
|
|
49099
49087
|
emptyArray
|
|
49100
49088
|
);
|
|
49101
|
-
var resolvingApparentMappedType = createAnonymousType(
|
|
49102
|
-
/*symbol*/
|
|
49103
|
-
void 0,
|
|
49104
|
-
emptySymbols,
|
|
49105
|
-
emptyArray,
|
|
49106
|
-
emptyArray,
|
|
49107
|
-
emptyArray
|
|
49108
|
-
);
|
|
49109
49089
|
var markerSuperType = createTypeParameter();
|
|
49110
49090
|
var markerSubType = createTypeParameter();
|
|
49111
49091
|
markerSubType.constraint = markerSuperType;
|
|
@@ -49513,7 +49493,7 @@ function createTypeChecker(host) {
|
|
|
49513
49493
|
symbol.links.checkFlags = checkFlags || 0 /* None */;
|
|
49514
49494
|
return symbol;
|
|
49515
49495
|
}
|
|
49516
|
-
function
|
|
49496
|
+
function createParameter2(name, type) {
|
|
49517
49497
|
const symbol = createSymbol(1 /* FunctionScopedVariable */, name);
|
|
49518
49498
|
symbol.links.type = type;
|
|
49519
49499
|
return symbol;
|
|
@@ -50761,7 +50741,7 @@ function createTypeChecker(host) {
|
|
|
50761
50741
|
return isExportAssignment(node) && !node.isExportEquals || hasSyntacticModifier(node, 2048 /* Default */) || isExportSpecifier(node) || isNamespaceExport(node);
|
|
50762
50742
|
}
|
|
50763
50743
|
function getUsageModeForExpression(usage) {
|
|
50764
|
-
return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
|
50744
|
+
return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : void 0;
|
|
50765
50745
|
}
|
|
50766
50746
|
function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
|
|
50767
50747
|
return usageMode === 99 /* ESNext */ && targetMode === 1 /* CommonJS */;
|
|
@@ -50772,7 +50752,7 @@ function createTypeChecker(host) {
|
|
|
50772
50752
|
}
|
|
50773
50753
|
function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
|
|
50774
50754
|
const usageMode = file && getUsageModeForExpression(usage);
|
|
50775
|
-
if (file && usageMode !== void 0) {
|
|
50755
|
+
if (file && usageMode !== void 0 && 100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) {
|
|
50776
50756
|
const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat);
|
|
50777
50757
|
if (usageMode === 99 /* ESNext */ || result) {
|
|
50778
50758
|
return result;
|
|
@@ -51305,7 +51285,7 @@ function createTypeChecker(host) {
|
|
|
51305
51285
|
break;
|
|
51306
51286
|
}
|
|
51307
51287
|
if (target === unknownSymbol) {
|
|
51308
|
-
return
|
|
51288
|
+
return -1 /* All */;
|
|
51309
51289
|
}
|
|
51310
51290
|
if (target === symbol || (seenSymbols == null ? void 0 : seenSymbols.has(target))) {
|
|
51311
51291
|
break;
|
|
@@ -51666,8 +51646,12 @@ function createTypeChecker(host) {
|
|
|
51666
51646
|
return ambientModule;
|
|
51667
51647
|
}
|
|
51668
51648
|
const currentSourceFile = getSourceFileOfNode(location);
|
|
51669
|
-
const contextSpecifier = isStringLiteralLike(location) ? location : ((_a =
|
|
51670
|
-
|
|
51649
|
+
const contextSpecifier = isStringLiteralLike(location) ? location : ((_a = isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : void 0) == null ? void 0 : _a.name) || ((_b = isLiteralImportTypeNode(location) ? location : void 0) == null ? void 0 : _b.argument.literal) || (isVariableDeclaration(location) && location.initializer && isRequireCall(
|
|
51650
|
+
location.initializer,
|
|
51651
|
+
/*requireStringLiteralLikeArgument*/
|
|
51652
|
+
true
|
|
51653
|
+
) ? location.initializer.arguments[0] : void 0) || ((_c = findAncestor(location, isImportCall)) == null ? void 0 : _c.arguments[0]) || ((_d = findAncestor(location, isImportDeclaration)) == null ? void 0 : _d.moduleSpecifier) || ((_e = findAncestor(location, isExternalModuleImportEqualsDeclaration)) == null ? void 0 : _e.moduleReference.expression) || ((_f = findAncestor(location, isExportDeclaration)) == null ? void 0 : _f.moduleSpecifier);
|
|
51654
|
+
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
|
|
51671
51655
|
const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions);
|
|
51672
51656
|
const resolvedModule = (_g = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _g.resolvedModule;
|
|
51673
51657
|
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile);
|
|
@@ -52291,7 +52275,7 @@ function createTypeChecker(host) {
|
|
|
52291
52275
|
}
|
|
52292
52276
|
function createType(flags) {
|
|
52293
52277
|
var _a;
|
|
52294
|
-
const result = new
|
|
52278
|
+
const result = new Type28(checker, flags);
|
|
52295
52279
|
typeCount++;
|
|
52296
52280
|
result.id = typeCount;
|
|
52297
52281
|
(_a = tracing) == null ? void 0 : _a.recordType(result);
|
|
@@ -52303,7 +52287,7 @@ function createTypeChecker(host) {
|
|
|
52303
52287
|
return result;
|
|
52304
52288
|
}
|
|
52305
52289
|
function createOriginType(flags) {
|
|
52306
|
-
return new
|
|
52290
|
+
return new Type28(checker, flags);
|
|
52307
52291
|
}
|
|
52308
52292
|
function createIntrinsicType(kind, intrinsicName, objectFlags = 0 /* None */, debugIntrinsicName) {
|
|
52309
52293
|
checkIntrinsicName(intrinsicName, debugIntrinsicName);
|
|
@@ -54821,7 +54805,7 @@ function createTypeChecker(host) {
|
|
|
54821
54805
|
}
|
|
54822
54806
|
const sym = resolveEntityName(
|
|
54823
54807
|
leftmost,
|
|
54824
|
-
|
|
54808
|
+
-1 /* All */,
|
|
54825
54809
|
/*ignoreErrors*/
|
|
54826
54810
|
true,
|
|
54827
54811
|
/*dontResolveAlias*/
|
|
@@ -54831,13 +54815,13 @@ function createTypeChecker(host) {
|
|
|
54831
54815
|
if (isSymbolAccessible(
|
|
54832
54816
|
sym,
|
|
54833
54817
|
context.enclosingDeclaration,
|
|
54834
|
-
|
|
54818
|
+
-1 /* All */,
|
|
54835
54819
|
/*shouldComputeAliasesToMakeVisible*/
|
|
54836
54820
|
false
|
|
54837
54821
|
).accessibility !== 0 /* Accessible */) {
|
|
54838
54822
|
introducesError = true;
|
|
54839
54823
|
} else {
|
|
54840
|
-
context.tracker.trackSymbol(sym, context.enclosingDeclaration,
|
|
54824
|
+
context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
|
|
54841
54825
|
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
54842
54826
|
}
|
|
54843
54827
|
if (isIdentifier(node)) {
|
|
@@ -55949,7 +55933,7 @@ function createTypeChecker(host) {
|
|
|
55949
55933
|
isLocalImport ? symbolToName(
|
|
55950
55934
|
target,
|
|
55951
55935
|
context,
|
|
55952
|
-
|
|
55936
|
+
-1 /* All */,
|
|
55953
55937
|
/*expectsIdentifier*/
|
|
55954
55938
|
false
|
|
55955
55939
|
) : factory.createExternalModuleReference(factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))
|
|
@@ -56108,7 +56092,7 @@ function createTypeChecker(host) {
|
|
|
56108
56092
|
const first2 = expr && isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : void 0;
|
|
56109
56093
|
const referenced = first2 && resolveEntityName(
|
|
56110
56094
|
first2,
|
|
56111
|
-
|
|
56095
|
+
-1 /* All */,
|
|
56112
56096
|
/*ignoreErrors*/
|
|
56113
56097
|
true,
|
|
56114
56098
|
/*dontResolveAlias*/
|
|
@@ -56125,7 +56109,7 @@ function createTypeChecker(host) {
|
|
|
56125
56109
|
/*modifiers*/
|
|
56126
56110
|
void 0,
|
|
56127
56111
|
isExportEquals,
|
|
56128
|
-
symbolToExpression(target, context,
|
|
56112
|
+
symbolToExpression(target, context, -1 /* All */)
|
|
56129
56113
|
));
|
|
56130
56114
|
} else {
|
|
56131
56115
|
if (first2 === expr && first2) {
|
|
@@ -56144,7 +56128,7 @@ function createTypeChecker(host) {
|
|
|
56144
56128
|
symbolToName(
|
|
56145
56129
|
target,
|
|
56146
56130
|
context,
|
|
56147
|
-
|
|
56131
|
+
-1 /* All */,
|
|
56148
56132
|
/*expectsIdentifier*/
|
|
56149
56133
|
false
|
|
56150
56134
|
)
|
|
@@ -60057,30 +60041,14 @@ function createTypeChecker(host) {
|
|
|
60057
60041
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
60058
60042
|
}
|
|
60059
60043
|
function getApparentTypeOfMappedType(type) {
|
|
60060
|
-
|
|
60061
|
-
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
60062
|
-
return type.resolvedApparentType = type;
|
|
60063
|
-
}
|
|
60064
|
-
return type.resolvedApparentType;
|
|
60065
|
-
}
|
|
60066
|
-
type.resolvedApparentType = resolvingApparentMappedType;
|
|
60067
|
-
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
60044
|
+
return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
|
|
60068
60045
|
}
|
|
60069
60046
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
60070
|
-
const
|
|
60071
|
-
|
|
60072
|
-
|
|
60073
|
-
let constraint;
|
|
60074
|
-
if (!type.target) {
|
|
60075
|
-
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
60076
|
-
} else {
|
|
60077
|
-
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
60078
|
-
if (modifiersConstraint) {
|
|
60079
|
-
constraint = getApparentType(modifiersConstraint);
|
|
60080
|
-
}
|
|
60081
|
-
}
|
|
60047
|
+
const typeVariable = getHomomorphicTypeVariable(type);
|
|
60048
|
+
if (typeVariable && !type.declaration.nameType) {
|
|
60049
|
+
const constraint = getConstraintOfTypeParameter(typeVariable);
|
|
60082
60050
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
60083
|
-
return instantiateType(
|
|
60051
|
+
return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
|
|
60084
60052
|
}
|
|
60085
60053
|
}
|
|
60086
60054
|
return type;
|
|
@@ -61404,7 +61372,7 @@ function createTypeChecker(host) {
|
|
|
61404
61372
|
if (constraint) {
|
|
61405
61373
|
constraints = append(constraints, constraint);
|
|
61406
61374
|
}
|
|
61407
|
-
} else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && node === parent2.type) {
|
|
61375
|
+
} else if (type.flags & 262144 /* TypeParameter */ && parent2.kind === 200 /* MappedType */ && !parent2.nameType && node === parent2.type) {
|
|
61408
61376
|
const mappedType = getTypeFromTypeNode(parent2);
|
|
61409
61377
|
if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
|
|
61410
61378
|
const typeParameter = getHomomorphicTypeVariable(mappedType);
|
|
@@ -64464,11 +64432,8 @@ function createTypeChecker(host) {
|
|
|
64464
64432
|
if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) {
|
|
64465
64433
|
return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
|
|
64466
64434
|
}
|
|
64467
|
-
if (isGenericTupleType(t)) {
|
|
64468
|
-
return instantiateMappedGenericTupleType(t, type, typeVariable, mapper);
|
|
64469
|
-
}
|
|
64470
64435
|
if (isTupleType(t)) {
|
|
64471
|
-
return instantiateMappedTupleType(t, type,
|
|
64436
|
+
return instantiateMappedTupleType(t, type, typeVariable, mapper);
|
|
64472
64437
|
}
|
|
64473
64438
|
}
|
|
64474
64439
|
return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
|
|
@@ -64485,17 +64450,18 @@ function createTypeChecker(host) {
|
|
|
64485
64450
|
function getModifiedReadonlyState(state, modifiers) {
|
|
64486
64451
|
return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state;
|
|
64487
64452
|
}
|
|
64488
|
-
function
|
|
64453
|
+
function instantiateMappedTupleType(tupleType, mappedType, typeVariable, mapper) {
|
|
64489
64454
|
const elementFlags = tupleType.target.elementFlags;
|
|
64490
|
-
const
|
|
64491
|
-
|
|
64492
|
-
|
|
64493
|
-
|
|
64494
|
-
|
|
64495
|
-
return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
|
|
64455
|
+
const fixedLength = tupleType.target.fixedLength;
|
|
64456
|
+
const fixedMapper = fixedLength ? prependTypeMapping(typeVariable, tupleType, mapper) : mapper;
|
|
64457
|
+
const newElementTypes = map(getElementTypes(tupleType), (type, i) => {
|
|
64458
|
+
const flags = elementFlags[i];
|
|
64459
|
+
return i < fixedLength ? instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(flags & 2 /* Optional */), fixedMapper) : flags & 8 /* Variadic */ ? instantiateType(mappedType, prependTypeMapping(typeVariable, type, mapper)) : getElementTypeOfArrayType(instantiateType(mappedType, prependTypeMapping(typeVariable, createArrayType(type), mapper))) ?? unknownType;
|
|
64496
64460
|
});
|
|
64461
|
+
const modifiers = getMappedTypeModifiers(mappedType);
|
|
64462
|
+
const newElementFlags = modifiers & 4 /* IncludeOptional */ ? map(elementFlags, (f) => f & 1 /* Required */ ? 2 /* Optional */ : f) : modifiers & 8 /* ExcludeOptional */ ? map(elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : elementFlags;
|
|
64497
64463
|
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
|
|
64498
|
-
return
|
|
64464
|
+
return contains(newElementTypes, errorType) ? errorType : createTupleType(newElementTypes, newElementFlags, newReadonly, tupleType.target.labeledElementDeclarations);
|
|
64499
64465
|
}
|
|
64500
64466
|
function instantiateMappedArrayType(arrayType, mappedType, mapper) {
|
|
64501
64467
|
const elementType = instantiateMappedTypeTemplate(
|
|
@@ -64507,14 +64473,6 @@ function createTypeChecker(host) {
|
|
|
64507
64473
|
);
|
|
64508
64474
|
return isErrorType(elementType) ? errorType : createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
|
|
64509
64475
|
}
|
|
64510
|
-
function instantiateMappedTupleType(tupleType, mappedType, mapper) {
|
|
64511
|
-
const elementFlags = tupleType.target.elementFlags;
|
|
64512
|
-
const elementTypes = map(getElementTypes(tupleType), (_, i) => instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper));
|
|
64513
|
-
const modifiers = getMappedTypeModifiers(mappedType);
|
|
64514
|
-
const newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? map(elementFlags, (f) => f & 1 /* Required */ ? 2 /* Optional */ : f) : modifiers & 8 /* ExcludeOptional */ ? map(elementFlags, (f) => f & 2 /* Optional */ ? 1 /* Required */ : f) : elementFlags;
|
|
64515
|
-
const newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
|
|
64516
|
-
return contains(elementTypes, errorType) ? errorType : createTupleType(elementTypes, newTupleModifiers, newReadonly, tupleType.target.labeledElementDeclarations);
|
|
64517
|
-
}
|
|
64518
64476
|
function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
|
|
64519
64477
|
const templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
|
|
64520
64478
|
const propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
|
|
@@ -65286,7 +65244,8 @@ function createTypeChecker(host) {
|
|
|
65286
65244
|
if (isOmittedExpression(elem))
|
|
65287
65245
|
continue;
|
|
65288
65246
|
const nameType = getNumberLiteralType(i);
|
|
65289
|
-
|
|
65247
|
+
const checkNode = getEffectiveCheckNode(elem);
|
|
65248
|
+
yield { errorNode: checkNode, innerExpression: checkNode, nameType };
|
|
65290
65249
|
}
|
|
65291
65250
|
}
|
|
65292
65251
|
function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
|
|
@@ -74792,7 +74751,12 @@ function createTypeChecker(host) {
|
|
|
74792
74751
|
}
|
|
74793
74752
|
const isClassic = getEmitModuleResolutionKind(compilerOptions) === 1 /* Classic */;
|
|
74794
74753
|
const errorMessage = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
|
|
74795
|
-
const
|
|
74754
|
+
const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0;
|
|
74755
|
+
const specifier = file == null ? void 0 : file.imports[jsxImportIndex];
|
|
74756
|
+
if (specifier) {
|
|
74757
|
+
Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`);
|
|
74758
|
+
}
|
|
74759
|
+
const mod = resolveExternalModule(specifier || location, runtimeImportSpecifier, errorMessage, location);
|
|
74796
74760
|
const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : void 0;
|
|
74797
74761
|
if (links) {
|
|
74798
74762
|
links.jsxImplicitImportContainer = result || false;
|
|
@@ -75035,7 +74999,7 @@ function createTypeChecker(host) {
|
|
|
75035
74999
|
);
|
|
75036
75000
|
}
|
|
75037
75001
|
if (jsxFactorySym) {
|
|
75038
|
-
jsxFactorySym.isReferenced =
|
|
75002
|
+
jsxFactorySym.isReferenced = -1 /* All */;
|
|
75039
75003
|
if (canCollectSymbolAliasAccessabilityData && jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
|
|
75040
75004
|
markAliasSymbolAsReferenced(jsxFactorySym);
|
|
75041
75005
|
}
|
|
@@ -75875,7 +75839,7 @@ function createTypeChecker(host) {
|
|
|
75875
75839
|
return;
|
|
75876
75840
|
}
|
|
75877
75841
|
}
|
|
75878
|
-
(getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced =
|
|
75842
|
+
(getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = -1 /* All */;
|
|
75879
75843
|
}
|
|
75880
75844
|
function isSelfTypeAccess(name, parent2) {
|
|
75881
75845
|
return name.kind === 110 /* ThisKeyword */ || !!parent2 && isEntityNameExpression(name) && parent2 === getResolvedSymbol(getFirstIdentifier(name));
|
|
@@ -76438,6 +76402,10 @@ function createTypeChecker(host) {
|
|
|
76438
76402
|
return false;
|
|
76439
76403
|
}
|
|
76440
76404
|
}
|
|
76405
|
+
function getEffectiveCheckNode(argument) {
|
|
76406
|
+
argument = skipParentheses(argument);
|
|
76407
|
+
return isSatisfiesExpression(argument) ? skipParentheses(argument.expression) : argument;
|
|
76408
|
+
}
|
|
76441
76409
|
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain) {
|
|
76442
76410
|
const errorOutputContainer = { errors: void 0, skipLogging: true };
|
|
76443
76411
|
if (isJsxOpeningLikeElement(node)) {
|
|
@@ -76473,7 +76441,8 @@ function createTypeChecker(host) {
|
|
|
76473
76441
|
checkMode
|
|
76474
76442
|
);
|
|
76475
76443
|
const checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
|
|
76476
|
-
|
|
76444
|
+
const effectiveCheckArgumentNode = getEffectiveCheckNode(arg);
|
|
76445
|
+
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors2 ? effectiveCheckArgumentNode : void 0, effectiveCheckArgumentNode, headMessage, containingMessageChain, errorOutputContainer)) {
|
|
76477
76446
|
Debug.assert(!reportErrors2 || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
|
|
76478
76447
|
maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
|
|
76479
76448
|
return errorOutputContainer.errors || emptyArray;
|
|
@@ -76491,7 +76460,7 @@ function createTypeChecker(host) {
|
|
|
76491
76460
|
checkMode
|
|
76492
76461
|
);
|
|
76493
76462
|
const restArgCount = args.length - argCount;
|
|
76494
|
-
const errorNode = !reportErrors2 ? void 0 : restArgCount === 0 ? node : restArgCount === 1 ? args[argCount] : setTextRangePosEnd(createSyntheticExpression(node, spreadType), args[argCount].pos, args[args.length - 1].end);
|
|
76463
|
+
const errorNode = !reportErrors2 ? void 0 : restArgCount === 0 ? node : restArgCount === 1 ? getEffectiveCheckNode(args[argCount]) : setTextRangePosEnd(createSyntheticExpression(node, spreadType), args[argCount].pos, args[args.length - 1].end);
|
|
76495
76464
|
if (!checkTypeRelatedTo(
|
|
76496
76465
|
spreadType,
|
|
76497
76466
|
restType,
|
|
@@ -76976,8 +76945,8 @@ function createTypeChecker(host) {
|
|
|
76976
76945
|
const oldCandidateForArgumentArityError = candidateForArgumentArityError;
|
|
76977
76946
|
const oldCandidateForTypeArgumentError = candidateForTypeArgumentError;
|
|
76978
76947
|
const failedSignatureDeclarations = ((_b = (_a = failed.declaration) == null ? void 0 : _a.symbol) == null ? void 0 : _b.declarations) || emptyArray;
|
|
76979
|
-
const
|
|
76980
|
-
const implDecl =
|
|
76948
|
+
const isOverload2 = failedSignatureDeclarations.length > 1;
|
|
76949
|
+
const implDecl = isOverload2 ? find(failedSignatureDeclarations, (d) => isFunctionLikeDeclaration(d) && nodeIsPresent(d.body)) : void 0;
|
|
76981
76950
|
if (implDecl) {
|
|
76982
76951
|
const candidate = getSignatureFromDeclaration(implDecl);
|
|
76983
76952
|
const isSingleNonGenericCandidate2 = !candidate.typeParameters;
|
|
@@ -77833,7 +77802,7 @@ function createTypeChecker(host) {
|
|
|
77833
77802
|
return anyType;
|
|
77834
77803
|
}
|
|
77835
77804
|
}
|
|
77836
|
-
if (isInJSFile(node) &&
|
|
77805
|
+
if (isInJSFile(node) && isCommonJsRequire(node)) {
|
|
77837
77806
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
77838
77807
|
}
|
|
77839
77808
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -78685,8 +78654,8 @@ function createTypeChecker(host) {
|
|
|
78685
78654
|
), [thisType, valueType]);
|
|
78686
78655
|
}
|
|
78687
78656
|
function createClassFieldDecoratorInitializerMutatorType(thisType, valueType) {
|
|
78688
|
-
const thisParam =
|
|
78689
|
-
const valueParam =
|
|
78657
|
+
const thisParam = createParameter2("this", thisType);
|
|
78658
|
+
const valueParam = createParameter2("value", valueType);
|
|
78690
78659
|
return createFunctionType(
|
|
78691
78660
|
/*typeParameters*/
|
|
78692
78661
|
void 0,
|
|
@@ -78699,8 +78668,8 @@ function createTypeChecker(host) {
|
|
|
78699
78668
|
);
|
|
78700
78669
|
}
|
|
78701
78670
|
function createESDecoratorCallSignature(targetType, contextType, nonOptionalReturnType) {
|
|
78702
|
-
const targetParam =
|
|
78703
|
-
const contextParam =
|
|
78671
|
+
const targetParam = createParameter2("target", targetType);
|
|
78672
|
+
const contextParam = createParameter2("context", contextType);
|
|
78704
78673
|
const returnType = getUnionType([nonOptionalReturnType, voidType]);
|
|
78705
78674
|
return createCallSignature(
|
|
78706
78675
|
/*typeParameters*/
|
|
@@ -78765,7 +78734,7 @@ function createTypeChecker(host) {
|
|
|
78765
78734
|
case 231 /* ClassExpression */: {
|
|
78766
78735
|
const node = parent2;
|
|
78767
78736
|
const targetType = getTypeOfSymbol(getSymbolOfDeclaration(node));
|
|
78768
|
-
const targetParam =
|
|
78737
|
+
const targetParam = createParameter2("target", targetType);
|
|
78769
78738
|
links.decoratorSignature = createCallSignature(
|
|
78770
78739
|
/*typeParameters*/
|
|
78771
78740
|
void 0,
|
|
@@ -78789,9 +78758,9 @@ function createTypeChecker(host) {
|
|
|
78789
78758
|
const targetType = isConstructorDeclaration(node.parent) ? getTypeOfSymbol(getSymbolOfDeclaration(node.parent.parent)) : getParentTypeOfClassElement(node.parent);
|
|
78790
78759
|
const keyType = isConstructorDeclaration(node.parent) ? undefinedType : getClassElementPropertyKeyType(node.parent);
|
|
78791
78760
|
const indexType = getNumberLiteralType(index);
|
|
78792
|
-
const targetParam =
|
|
78793
|
-
const keyParam =
|
|
78794
|
-
const indexParam =
|
|
78761
|
+
const targetParam = createParameter2("target", targetType);
|
|
78762
|
+
const keyParam = createParameter2("propertyKey", keyType);
|
|
78763
|
+
const indexParam = createParameter2("parameterIndex", indexType);
|
|
78795
78764
|
links.decoratorSignature = createCallSignature(
|
|
78796
78765
|
/*typeParameters*/
|
|
78797
78766
|
void 0,
|
|
@@ -78810,14 +78779,14 @@ function createTypeChecker(host) {
|
|
|
78810
78779
|
if (!isClassLike(node.parent))
|
|
78811
78780
|
break;
|
|
78812
78781
|
const targetType = getParentTypeOfClassElement(node);
|
|
78813
|
-
const targetParam =
|
|
78782
|
+
const targetParam = createParameter2("target", targetType);
|
|
78814
78783
|
const keyType = getClassElementPropertyKeyType(node);
|
|
78815
|
-
const keyParam =
|
|
78784
|
+
const keyParam = createParameter2("propertyKey", keyType);
|
|
78816
78785
|
const returnType = isPropertyDeclaration(node) ? voidType : createTypedPropertyDescriptorType(getTypeOfNode(node));
|
|
78817
78786
|
const hasPropDesc = languageVersion !== 0 /* ES3 */ && (!isPropertyDeclaration(parent2) || hasAccessorModifier(parent2));
|
|
78818
78787
|
if (hasPropDesc) {
|
|
78819
78788
|
const descriptorType = createTypedPropertyDescriptorType(getTypeOfNode(node));
|
|
78820
|
-
const descriptorParam =
|
|
78789
|
+
const descriptorParam = createParameter2("descriptor", descriptorType);
|
|
78821
78790
|
links.decoratorSignature = createCallSignature(
|
|
78822
78791
|
/*typeParameters*/
|
|
78823
78792
|
void 0,
|
|
@@ -79313,17 +79282,18 @@ function createTypeChecker(host) {
|
|
|
79313
79282
|
const exprType = checkExpression(node.body);
|
|
79314
79283
|
const returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
|
|
79315
79284
|
if (returnOrPromisedType) {
|
|
79285
|
+
const effectiveCheckNode = getEffectiveCheckNode(node.body);
|
|
79316
79286
|
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
79317
79287
|
const awaitedType = checkAwaitedType(
|
|
79318
79288
|
exprType,
|
|
79319
79289
|
/*withAlias*/
|
|
79320
79290
|
false,
|
|
79321
|
-
|
|
79291
|
+
effectiveCheckNode,
|
|
79322
79292
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
79323
79293
|
);
|
|
79324
|
-
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType,
|
|
79294
|
+
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
79325
79295
|
} else {
|
|
79326
|
-
checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType,
|
|
79296
|
+
checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
79327
79297
|
}
|
|
79328
79298
|
}
|
|
79329
79299
|
}
|
|
@@ -79485,13 +79455,14 @@ function createTypeChecker(host) {
|
|
|
79485
79455
|
}
|
|
79486
79456
|
case 7 /* ES2022 */:
|
|
79487
79457
|
case 99 /* ESNext */:
|
|
79458
|
+
case 200 /* Preserve */:
|
|
79488
79459
|
case 4 /* System */:
|
|
79489
79460
|
if (languageVersion >= 4 /* ES2017 */) {
|
|
79490
79461
|
break;
|
|
79491
79462
|
}
|
|
79492
79463
|
default:
|
|
79493
79464
|
span ?? (span = getSpanOfTokenAtPosition(sourceFile, node.pos));
|
|
79494
|
-
const message = isAwaitExpression(node) ? Diagnostics.
|
|
79465
|
+
const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher : Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher;
|
|
79495
79466
|
diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message));
|
|
79496
79467
|
hasError = true;
|
|
79497
79468
|
break;
|
|
@@ -81739,11 +81710,10 @@ function createTypeChecker(host) {
|
|
|
81739
81710
|
checkSourceElement(node.elementType);
|
|
81740
81711
|
}
|
|
81741
81712
|
function checkTupleType(node) {
|
|
81742
|
-
const elementTypes = node.elements;
|
|
81743
81713
|
let seenOptionalElement = false;
|
|
81744
81714
|
let seenRestElement = false;
|
|
81745
|
-
for (const e of
|
|
81746
|
-
|
|
81715
|
+
for (const e of node.elements) {
|
|
81716
|
+
let flags = getTupleElementFlags(e);
|
|
81747
81717
|
if (flags & 8 /* Variadic */) {
|
|
81748
81718
|
const type = getTypeFromTypeNode(e.type);
|
|
81749
81719
|
if (!isArrayLikeType(type)) {
|
|
@@ -81751,9 +81721,10 @@ function createTypeChecker(host) {
|
|
|
81751
81721
|
break;
|
|
81752
81722
|
}
|
|
81753
81723
|
if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) {
|
|
81754
|
-
|
|
81724
|
+
flags |= 4 /* Rest */;
|
|
81755
81725
|
}
|
|
81756
|
-
}
|
|
81726
|
+
}
|
|
81727
|
+
if (flags & 4 /* Rest */) {
|
|
81757
81728
|
if (seenRestElement) {
|
|
81758
81729
|
grammarErrorOnNode(e, Diagnostics.A_rest_element_cannot_follow_another_rest_element);
|
|
81759
81730
|
break;
|
|
@@ -81765,7 +81736,7 @@ function createTypeChecker(host) {
|
|
|
81765
81736
|
break;
|
|
81766
81737
|
}
|
|
81767
81738
|
seenOptionalElement = true;
|
|
81768
|
-
} else if (seenOptionalElement) {
|
|
81739
|
+
} else if (flags & 1 /* Required */ && seenOptionalElement) {
|
|
81769
81740
|
grammarErrorOnNode(e, Diagnostics.A_required_element_cannot_follow_an_optional_element);
|
|
81770
81741
|
break;
|
|
81771
81742
|
}
|
|
@@ -82518,7 +82489,7 @@ function createTypeChecker(host) {
|
|
|
82518
82489
|
);
|
|
82519
82490
|
}
|
|
82520
82491
|
function createSetterFunctionType(type) {
|
|
82521
|
-
const valueParam =
|
|
82492
|
+
const valueParam = createParameter2("value", type);
|
|
82522
82493
|
return createFunctionType(
|
|
82523
82494
|
/*typeParameters*/
|
|
82524
82495
|
void 0,
|
|
@@ -86006,8 +85977,8 @@ function createTypeChecker(host) {
|
|
|
86006
85977
|
return;
|
|
86007
85978
|
}
|
|
86008
85979
|
const mode = moduleKind === 199 /* NodeNext */ && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier);
|
|
86009
|
-
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */) {
|
|
86010
|
-
const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.
|
|
85980
|
+
if (mode !== 99 /* ESNext */ && moduleKind !== 99 /* ESNext */ && moduleKind !== 200 /* Preserve */) {
|
|
85981
|
+
const message = isImportAttributes2 ? moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === 199 /* NodeNext */ ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve;
|
|
86011
85982
|
return grammarErrorOnNode(node, message);
|
|
86012
85983
|
}
|
|
86013
85984
|
if (isImportDeclaration(declaration) ? (_a = declaration.importClause) == null ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) {
|
|
@@ -86079,7 +86050,7 @@ function createTypeChecker(host) {
|
|
|
86079
86050
|
grammarErrorOnNode(node, Diagnostics.An_import_alias_cannot_use_import_type);
|
|
86080
86051
|
}
|
|
86081
86052
|
} else {
|
|
86082
|
-
if (moduleKind >= 5 /* ES2015 */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
86053
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && getSourceFileOfNode(node).impliedNodeFormat === void 0 && !node.isTypeOnly && !(node.flags & 33554432 /* Ambient */)) {
|
|
86083
86054
|
grammarErrorOnNode(node, 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);
|
|
86084
86055
|
}
|
|
86085
86056
|
}
|
|
@@ -86240,7 +86211,7 @@ function createTypeChecker(host) {
|
|
|
86240
86211
|
const id = node.expression;
|
|
86241
86212
|
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(
|
|
86242
86213
|
id,
|
|
86243
|
-
|
|
86214
|
+
-1 /* All */,
|
|
86244
86215
|
/*ignoreErrors*/
|
|
86245
86216
|
true,
|
|
86246
86217
|
/*dontResolveAlias*/
|
|
@@ -86314,7 +86285,7 @@ function createTypeChecker(host) {
|
|
|
86314
86285
|
grammarErrorOnNode(node.expression, Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
86315
86286
|
}
|
|
86316
86287
|
if (node.isExportEquals) {
|
|
86317
|
-
if (moduleKind >= 5 /* ES2015 */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
|
|
86288
|
+
if (moduleKind >= 5 /* ES2015 */ && moduleKind !== 200 /* Preserve */ && (node.flags & 33554432 /* Ambient */ && getSourceFileOfNode(node).impliedNodeFormat === 99 /* ESNext */ || !(node.flags & 33554432 /* Ambient */) && getSourceFileOfNode(node).impliedNodeFormat !== 1 /* CommonJS */)) {
|
|
86318
86289
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
86319
86290
|
} else if (moduleKind === 4 /* System */ && !(node.flags & 33554432 /* Ambient */)) {
|
|
86320
86291
|
grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
|
|
@@ -87306,7 +87277,7 @@ function createTypeChecker(host) {
|
|
|
87306
87277
|
return void 0;
|
|
87307
87278
|
case 11 /* StringLiteral */:
|
|
87308
87279
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
87309
|
-
if (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node || (node.parent.kind === 272 /* ImportDeclaration */ || node.parent.kind === 278 /* ExportDeclaration */) && node.parent.moduleSpecifier === node || (isInJSFile(node) &&
|
|
87280
|
+
if (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node || (node.parent.kind === 272 /* ImportDeclaration */ || node.parent.kind === 278 /* ExportDeclaration */) && node.parent.moduleSpecifier === node || (isInJSFile(node) && isRequireCall(
|
|
87310
87281
|
node.parent,
|
|
87311
87282
|
/*requireStringLiteralLikeArgument*/
|
|
87312
87283
|
false
|
|
@@ -89368,7 +89339,7 @@ function createTypeChecker(host) {
|
|
|
89368
89339
|
}
|
|
89369
89340
|
default:
|
|
89370
89341
|
diagnostics.add(
|
|
89371
|
-
createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.
|
|
89342
|
+
createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher)
|
|
89372
89343
|
);
|
|
89373
89344
|
break;
|
|
89374
89345
|
}
|
|
@@ -112884,7 +112855,7 @@ function transformECMAScriptModule(context) {
|
|
|
112884
112855
|
setTextRange(factory2.createNodeArray(insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements)
|
|
112885
112856
|
);
|
|
112886
112857
|
}
|
|
112887
|
-
if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) {
|
|
112858
|
+
if (!isExternalModule(node) || getEmitModuleKind(compilerOptions) === 200 /* Preserve */ || some(result.statements, isExternalModuleIndicator)) {
|
|
112888
112859
|
return result;
|
|
112889
112860
|
}
|
|
112890
112861
|
return factory2.updateSourceFile(
|
|
@@ -112927,6 +112898,14 @@ function transformECMAScriptModule(context) {
|
|
|
112927
112898
|
if (moduleName) {
|
|
112928
112899
|
args.push(moduleName);
|
|
112929
112900
|
}
|
|
112901
|
+
if (getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
|
112902
|
+
return factory2.createCallExpression(
|
|
112903
|
+
factory2.createIdentifier("require"),
|
|
112904
|
+
/*typeArguments*/
|
|
112905
|
+
void 0,
|
|
112906
|
+
args
|
|
112907
|
+
);
|
|
112908
|
+
}
|
|
112930
112909
|
if (!importRequireStatements) {
|
|
112931
112910
|
const createRequireName = factory2.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
112932
112911
|
const importStatement = factory2.createImportDeclaration(
|
|
@@ -113041,7 +113020,25 @@ function transformECMAScriptModule(context) {
|
|
|
113041
113020
|
return statements;
|
|
113042
113021
|
}
|
|
113043
113022
|
function visitExportAssignment(node) {
|
|
113044
|
-
|
|
113023
|
+
if (node.isExportEquals) {
|
|
113024
|
+
if (getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
|
113025
|
+
const statement = setOriginalNode(
|
|
113026
|
+
factory2.createExpressionStatement(
|
|
113027
|
+
factory2.createAssignment(
|
|
113028
|
+
factory2.createPropertyAccessExpression(
|
|
113029
|
+
factory2.createIdentifier("module"),
|
|
113030
|
+
"exports"
|
|
113031
|
+
),
|
|
113032
|
+
node.expression
|
|
113033
|
+
)
|
|
113034
|
+
),
|
|
113035
|
+
node
|
|
113036
|
+
);
|
|
113037
|
+
return statement;
|
|
113038
|
+
}
|
|
113039
|
+
return void 0;
|
|
113040
|
+
}
|
|
113041
|
+
return node;
|
|
113045
113042
|
}
|
|
113046
113043
|
function visitExportDeclaration(node) {
|
|
113047
113044
|
if (compilerOptions.module !== void 0 && compilerOptions.module > 5 /* ES2015 */) {
|
|
@@ -113502,7 +113499,7 @@ function transformDeclarations(context) {
|
|
|
113502
113499
|
}
|
|
113503
113500
|
}
|
|
113504
113501
|
function trackReferencedAmbientModule(node, symbol) {
|
|
113505
|
-
const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol,
|
|
113502
|
+
const directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, -1 /* All */);
|
|
113506
113503
|
if (length(directives)) {
|
|
113507
113504
|
return recordTypeReferenceDirectivesIfNecessary(directives);
|
|
113508
113505
|
}
|
|
@@ -115168,6 +115165,7 @@ function getModuleTransformer(moduleKind) {
|
|
|
115168
115165
|
case 7 /* ES2022 */:
|
|
115169
115166
|
case 6 /* ES2020 */:
|
|
115170
115167
|
case 5 /* ES2015 */:
|
|
115168
|
+
case 200 /* Preserve */:
|
|
115171
115169
|
return transformECMAScriptModule;
|
|
115172
115170
|
case 4 /* System */:
|
|
115173
115171
|
return transformSystemModule;
|
|
@@ -121991,8 +121989,8 @@ function flattenDiagnosticMessageText(diag2, newLine, indent3 = 0) {
|
|
|
121991
121989
|
function getModeForFileReference(ref, containingFileMode) {
|
|
121992
121990
|
return (isString(ref) ? containingFileMode : ref.resolutionMode) || containingFileMode;
|
|
121993
121991
|
}
|
|
121994
|
-
function getModeForResolutionAtIndex(file, index) {
|
|
121995
|
-
return
|
|
121992
|
+
function getModeForResolutionAtIndex(file, index, compilerOptions) {
|
|
121993
|
+
return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions);
|
|
121996
121994
|
}
|
|
121997
121995
|
function isExclusivelyTypeOnlyImportOrExport(decl) {
|
|
121998
121996
|
var _a;
|
|
@@ -122004,7 +122002,10 @@ function isExclusivelyTypeOnlyImportOrExport(decl) {
|
|
|
122004
122002
|
}
|
|
122005
122003
|
return false;
|
|
122006
122004
|
}
|
|
122007
|
-
function getModeForUsageLocation(file, usage) {
|
|
122005
|
+
function getModeForUsageLocation(file, usage, compilerOptions) {
|
|
122006
|
+
return getModeForUsageLocationWorker(file, usage, compilerOptions);
|
|
122007
|
+
}
|
|
122008
|
+
function getModeForUsageLocationWorker(file, usage, compilerOptions) {
|
|
122008
122009
|
var _a;
|
|
122009
122010
|
if (isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent)) {
|
|
122010
122011
|
const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent);
|
|
@@ -122021,6 +122022,13 @@ function getModeForUsageLocation(file, usage) {
|
|
|
122021
122022
|
return override;
|
|
122022
122023
|
}
|
|
122023
122024
|
}
|
|
122025
|
+
if (compilerOptions && getEmitModuleKind(compilerOptions) === 200 /* Preserve */) {
|
|
122026
|
+
return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(
|
|
122027
|
+
usage.parent,
|
|
122028
|
+
/*requireStringLiteralLikeArgument*/
|
|
122029
|
+
false
|
|
122030
|
+
) ? 1 /* CommonJS */ : 99 /* ESNext */;
|
|
122031
|
+
}
|
|
122024
122032
|
if (file.impliedNodeFormat === void 0)
|
|
122025
122033
|
return void 0;
|
|
122026
122034
|
if (file.impliedNodeFormat !== 99 /* ESNext */) {
|
|
@@ -122066,7 +122074,7 @@ function getModuleResolutionName(literal) {
|
|
|
122066
122074
|
}
|
|
122067
122075
|
var moduleResolutionNameAndModeGetter = {
|
|
122068
122076
|
getName: getModuleResolutionName,
|
|
122069
|
-
getMode: (entry, file) => getModeForUsageLocation(file, entry)
|
|
122077
|
+
getMode: (entry, file, compilerOptions) => getModeForUsageLocation(file, entry, compilerOptions)
|
|
122070
122078
|
};
|
|
122071
122079
|
function createModuleResolutionLoader(containingFile, redirectedReference, options, host, cache) {
|
|
122072
122080
|
return {
|
|
@@ -122111,7 +122119,7 @@ function loadWithModeAwareCache(entries, containingFile, redirectedReference, op
|
|
|
122111
122119
|
const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache);
|
|
122112
122120
|
for (const entry of entries) {
|
|
122113
122121
|
const name = loader.nameAndMode.getName(entry);
|
|
122114
|
-
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
|
122122
|
+
const mode = loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options);
|
|
122115
122123
|
const key = createModeAwareCacheKey(name, mode);
|
|
122116
122124
|
let result = cache.get(key);
|
|
122117
122125
|
if (!result) {
|
|
@@ -122197,7 +122205,7 @@ function getReferencedFileLocation(program, ref) {
|
|
|
122197
122205
|
switch (kind) {
|
|
122198
122206
|
case 3 /* Import */:
|
|
122199
122207
|
const importLiteral = getModuleNameStringLiteralAt(file, index);
|
|
122200
|
-
packageId = (_b = (_a = program.getResolvedModule(file, importLiteral.text,
|
|
122208
|
+
packageId = (_b = (_a = program.getResolvedModule(file, importLiteral.text, program.getModeForUsageLocation(file, importLiteral))) == null ? void 0 : _a.resolvedModule) == null ? void 0 : _b.packageId;
|
|
122201
122209
|
if (importLiteral.pos === -1)
|
|
122202
122210
|
return { file, packageId, text: importLiteral.text };
|
|
122203
122211
|
pos = skipTrivia(file.text, importLiteral.pos);
|
|
@@ -122730,6 +122738,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122730
122738
|
getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions,
|
|
122731
122739
|
isSourceFileFromExternalLibrary,
|
|
122732
122740
|
isSourceFileDefaultLibrary,
|
|
122741
|
+
getModeForUsageLocation: getModeForUsageLocation2,
|
|
122742
|
+
getModeForResolutionAtIndex: getModeForResolutionAtIndex2,
|
|
122733
122743
|
getSourceFileFromReference,
|
|
122734
122744
|
getLibFileFromReference,
|
|
122735
122745
|
sourceFileToPackageName,
|
|
@@ -122739,6 +122749,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122739
122749
|
resolvedTypeReferenceDirectiveNames,
|
|
122740
122750
|
resolvedLibReferences,
|
|
122741
122751
|
getResolvedModule,
|
|
122752
|
+
getResolvedModuleFromModuleSpecifier,
|
|
122742
122753
|
getResolvedTypeReferenceDirective,
|
|
122743
122754
|
forEachResolvedModule,
|
|
122744
122755
|
forEachResolvedTypeReferenceDirective,
|
|
@@ -122789,6 +122800,11 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122789
122800
|
var _a2;
|
|
122790
122801
|
return (_a2 = resolvedModules == null ? void 0 : resolvedModules.get(file.path)) == null ? void 0 : _a2.get(moduleName, mode);
|
|
122791
122802
|
}
|
|
122803
|
+
function getResolvedModuleFromModuleSpecifier(moduleSpecifier) {
|
|
122804
|
+
const sourceFile = getSourceFileOfNode(moduleSpecifier);
|
|
122805
|
+
Debug.assertIsDefined(sourceFile, "`moduleSpecifier` must have a `SourceFile` ancestor. Use `program.getResolvedModule` instead to provide the containing file and resolution mode.");
|
|
122806
|
+
return getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation2(sourceFile, moduleSpecifier));
|
|
122807
|
+
}
|
|
122792
122808
|
function getResolvedTypeReferenceDirective(file, typeDirectiveName, mode) {
|
|
122793
122809
|
var _a2;
|
|
122794
122810
|
return (_a2 = resolvedTypeReferenceDirectiveNames == null ? void 0 : resolvedTypeReferenceDirectiveNames.get(file.path)) == null ? void 0 : _a2.get(typeDirectiveName, mode);
|
|
@@ -122961,8 +122977,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122961
122977
|
for (let i = 0; i < moduleNames.length; i++) {
|
|
122962
122978
|
const moduleName = moduleNames[i];
|
|
122963
122979
|
if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) {
|
|
122964
|
-
const
|
|
122965
|
-
const oldResolution = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, mode);
|
|
122980
|
+
const oldResolution = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName));
|
|
122966
122981
|
if (oldResolution == null ? void 0 : oldResolution.resolvedModule) {
|
|
122967
122982
|
if (isTraceEnabled(options, host)) {
|
|
122968
122983
|
trace(
|
|
@@ -123010,7 +123025,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123010
123025
|
return result;
|
|
123011
123026
|
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
|
|
123012
123027
|
var _a2;
|
|
123013
|
-
const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text,
|
|
123028
|
+
const resolutionToFile = (_a2 = oldProgram == null ? void 0 : oldProgram.getResolvedModule(file, moduleName.text, getModeForUsageLocation2(file, moduleName))) == null ? void 0 : _a2.resolvedModule;
|
|
123014
123029
|
const resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
|
|
123015
123030
|
if (resolutionToFile && resolvedFile) {
|
|
123016
123031
|
return false;
|
|
@@ -123228,11 +123243,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123228
123243
|
(resolvedModulesProcessing ?? (resolvedModulesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, resolutions);
|
|
123229
123244
|
const resolutionsChanged = hasChangesInResolutions(
|
|
123230
123245
|
moduleNames,
|
|
123231
|
-
newSourceFile,
|
|
123232
123246
|
resolutions,
|
|
123233
|
-
(name
|
|
123234
|
-
moduleResolutionIsEqualTo
|
|
123235
|
-
moduleResolutionNameAndModeGetter
|
|
123247
|
+
(name) => oldProgram.getResolvedModule(newSourceFile, name.text, getModeForUsageLocation2(newSourceFile, name)),
|
|
123248
|
+
moduleResolutionIsEqualTo
|
|
123236
123249
|
);
|
|
123237
123250
|
if (resolutionsChanged)
|
|
123238
123251
|
structureIsReused = 1 /* SafeModules */;
|
|
@@ -123241,11 +123254,9 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123241
123254
|
(resolvedTypeReferenceDirectiveNamesProcessing ?? (resolvedTypeReferenceDirectiveNamesProcessing = /* @__PURE__ */ new Map())).set(newSourceFile.path, typeReferenceResolutions);
|
|
123242
123255
|
const typeReferenceResolutionsChanged = hasChangesInResolutions(
|
|
123243
123256
|
typesReferenceDirectives,
|
|
123244
|
-
newSourceFile,
|
|
123245
123257
|
typeReferenceResolutions,
|
|
123246
|
-
(name
|
|
123247
|
-
typeDirectiveIsEqualTo
|
|
123248
|
-
typeReferenceResolutionNameAndModeGetter
|
|
123258
|
+
(name) => oldProgram.getResolvedTypeReferenceDirective(newSourceFile, getTypeReferenceResolutionName(name), getModeForFileReference(name, newSourceFile.impliedNodeFormat)),
|
|
123259
|
+
typeDirectiveIsEqualTo
|
|
123249
123260
|
);
|
|
123250
123261
|
if (typeReferenceResolutionsChanged)
|
|
123251
123262
|
structureIsReused = 1 /* SafeModules */;
|
|
@@ -123912,8 +123923,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123912
123923
|
false
|
|
123913
123924
|
);
|
|
123914
123925
|
}
|
|
123915
|
-
|
|
123916
|
-
if (file.flags & 4194304 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
|
|
123926
|
+
if (file.flags & 4194304 /* PossiblyContainsDynamicImport */ || isJavaScriptFile) {
|
|
123917
123927
|
collectDynamicImportOrRequireCalls(file);
|
|
123918
123928
|
}
|
|
123919
123929
|
file.imports = imports || emptyArray;
|
|
@@ -123962,7 +123972,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
123962
123972
|
const r = /import|require/g;
|
|
123963
123973
|
while (r.exec(file2.text) !== null) {
|
|
123964
123974
|
const node = getNodeAtPosition(file2, r.lastIndex);
|
|
123965
|
-
if (
|
|
123975
|
+
if (isJavaScriptFile && isRequireCall(
|
|
123966
123976
|
node,
|
|
123967
123977
|
/*requireStringLiteralLikeArgument*/
|
|
123968
123978
|
true
|
|
@@ -124517,13 +124527,13 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124517
124527
|
const moduleNames = getModuleNames(file);
|
|
124518
124528
|
const resolutions = (resolvedModulesProcessing == null ? void 0 : resolvedModulesProcessing.get(file.path)) || resolveModuleNamesReusingOldState(moduleNames, file);
|
|
124519
124529
|
Debug.assert(resolutions.length === moduleNames.length);
|
|
124520
|
-
const optionsForFile = (
|
|
124530
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
124521
124531
|
const resolutionsInFile = createModeAwareCache();
|
|
124522
124532
|
(resolvedModules ?? (resolvedModules = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
|
|
124523
124533
|
for (let index = 0; index < moduleNames.length; index++) {
|
|
124524
124534
|
const resolution = resolutions[index].resolvedModule;
|
|
124525
124535
|
const moduleName = moduleNames[index].text;
|
|
124526
|
-
const mode =
|
|
124536
|
+
const mode = getModeForUsageLocationWorker(file, moduleNames[index], optionsForFile);
|
|
124527
124537
|
resolutionsInFile.set(moduleName, mode, resolutions[index]);
|
|
124528
124538
|
addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode);
|
|
124529
124539
|
if (!resolution) {
|
|
@@ -124803,7 +124813,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124803
124813
|
if (getEmitModuleResolutionKind(options) === 1 /* Classic */) {
|
|
124804
124814
|
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic, "resolveJsonModule");
|
|
124805
124815
|
} else if (!hasJsonModuleEmitEnabled(options)) {
|
|
124806
|
-
createDiagnosticForOptionName(Diagnostics.
|
|
124816
|
+
createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd, "resolveJsonModule", "module");
|
|
124807
124817
|
}
|
|
124808
124818
|
}
|
|
124809
124819
|
if (options.outDir || // there is --outDir specified
|
|
@@ -124867,7 +124877,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124867
124877
|
}
|
|
124868
124878
|
}
|
|
124869
124879
|
if (options.preserveValueImports && getEmitModuleKind(options) < 5 /* ES2015 */) {
|
|
124870
|
-
createDiagnosticForOptionName(Diagnostics.
|
|
124880
|
+
createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "preserveValueImports");
|
|
124871
124881
|
}
|
|
124872
124882
|
const moduleKind = getEmitModuleKind(options);
|
|
124873
124883
|
if (options.verbatimModuleSyntax) {
|
|
@@ -124894,8 +124904,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
124894
124904
|
if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
124895
124905
|
createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions");
|
|
124896
124906
|
}
|
|
124897
|
-
if (moduleResolution === 100 /* Bundler */ && !emitModuleKindIsNonNodeESM(moduleKind)) {
|
|
124898
|
-
createOptionValueDiagnostic("moduleResolution", Diagnostics.
|
|
124907
|
+
if (moduleResolution === 100 /* Bundler */ && !emitModuleKindIsNonNodeESM(moduleKind) && moduleKind !== 200 /* Preserve */) {
|
|
124908
|
+
createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "bundler");
|
|
124899
124909
|
}
|
|
124900
124910
|
if (ModuleKind[moduleKind] && (100 /* Node16 */ <= moduleKind && moduleKind <= 199 /* NodeNext */) && !(3 /* Node16 */ <= moduleResolution && moduleResolution <= 99 /* NodeNext */)) {
|
|
124901
124911
|
const moduleKindName = ModuleKind[moduleKind];
|
|
@@ -125402,6 +125412,14 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
125402
125412
|
}
|
|
125403
125413
|
return symlinks;
|
|
125404
125414
|
}
|
|
125415
|
+
function getModeForUsageLocation2(file, usage) {
|
|
125416
|
+
var _a2;
|
|
125417
|
+
const optionsForFile = ((_a2 = getRedirectReferenceForResolution(file)) == null ? void 0 : _a2.commandLine.options) || options;
|
|
125418
|
+
return getModeForUsageLocationWorker(file, usage, optionsForFile);
|
|
125419
|
+
}
|
|
125420
|
+
function getModeForResolutionAtIndex2(file, index) {
|
|
125421
|
+
return getModeForUsageLocation2(file, getModuleNameStringLiteralAt(file, index));
|
|
125422
|
+
}
|
|
125405
125423
|
}
|
|
125406
125424
|
function updateHostForUseSourceOfProjectReferenceRedirect(host) {
|
|
125407
125425
|
let setOfDeclarationDirectories;
|
|
@@ -127867,7 +127885,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
127867
127885
|
const seenNamesInFile = createModeAwareCache();
|
|
127868
127886
|
for (const entry of entries) {
|
|
127869
127887
|
const name = loader.nameAndMode.getName(entry);
|
|
127870
|
-
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
|
127888
|
+
const mode = loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options);
|
|
127871
127889
|
let resolution = resolutionsInFile.get(name, mode);
|
|
127872
127890
|
if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
|
|
127873
127891
|
hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
|
|
@@ -127908,7 +127926,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
127908
127926
|
reusedNames == null ? void 0 : reusedNames.forEach(
|
|
127909
127927
|
(entry) => seenNamesInFile.set(
|
|
127910
127928
|
loader.nameAndMode.getName(entry),
|
|
127911
|
-
loader.nameAndMode.getMode(entry, containingSourceFile),
|
|
127929
|
+
loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options),
|
|
127912
127930
|
true
|
|
127913
127931
|
)
|
|
127914
127932
|
);
|
|
@@ -135638,7 +135656,7 @@ function forEachExternalModuleToImportFrom(program, host, preferences, useAutoIm
|
|
|
135638
135656
|
var _a, _b;
|
|
135639
135657
|
const useCaseSensitiveFileNames2 = hostUsesCaseSensitiveFileNames(host);
|
|
135640
135658
|
const excludePatterns = preferences.autoImportFileExcludePatterns && mapDefined(preferences.autoImportFileExcludePatterns, (spec) => {
|
|
135641
|
-
const pattern =
|
|
135659
|
+
const pattern = getSubPatternFromSpec(spec, "", "exclude");
|
|
135642
135660
|
return pattern ? getRegexFromPattern(pattern, useCaseSensitiveFileNames2) : void 0;
|
|
135643
135661
|
});
|
|
135644
135662
|
forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), excludePatterns, host, (module2, file) => cb(
|
|
@@ -137469,8 +137487,8 @@ function getSourceFileToImport(importedModuleSymbol, importLiteral, importingSou
|
|
|
137469
137487
|
const newFileName = oldToNew(oldFileName);
|
|
137470
137488
|
return newFileName === void 0 ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true };
|
|
137471
137489
|
} else {
|
|
137472
|
-
const mode = getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
137473
|
-
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? program.
|
|
137490
|
+
const mode = program.getModeForUsageLocation(importingSourceFile, importLiteral);
|
|
137491
|
+
const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? program.getResolvedModuleFromModuleSpecifier(importLiteral) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode);
|
|
137474
137492
|
return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles());
|
|
137475
137493
|
}
|
|
137476
137494
|
}
|
|
@@ -138382,7 +138400,7 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
138382
138400
|
const name = importNameForConvertToDefaultImport(importNode);
|
|
138383
138401
|
if (!name)
|
|
138384
138402
|
continue;
|
|
138385
|
-
const module2 = (_a = program.
|
|
138403
|
+
const module2 = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
138386
138404
|
const resolvedFile = module2 && program.getSourceFile(module2.resolvedFileName);
|
|
138387
138405
|
if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
|
|
138388
138406
|
diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import));
|
|
@@ -139967,7 +139985,7 @@ function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allow
|
|
|
139967
139985
|
if (checker.resolveName(
|
|
139968
139986
|
exportName,
|
|
139969
139987
|
id,
|
|
139970
|
-
|
|
139988
|
+
-1 /* All */,
|
|
139971
139989
|
/*excludeGlobals*/
|
|
139972
139990
|
true
|
|
139973
139991
|
)) {
|
|
@@ -140030,7 +140048,7 @@ function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConve
|
|
|
140030
140048
|
const symbol = checker.resolveName(
|
|
140031
140049
|
preferredName,
|
|
140032
140050
|
id,
|
|
140033
|
-
|
|
140051
|
+
-1 /* All */,
|
|
140034
140052
|
/*excludeGlobals*/
|
|
140035
140053
|
true
|
|
140036
140054
|
);
|
|
@@ -140582,7 +140600,7 @@ function isDeclarationExported(declaration) {
|
|
|
140582
140600
|
function getReferenceNodes(declaration, checker, file) {
|
|
140583
140601
|
const references = [];
|
|
140584
140602
|
const cannotInline = ts_FindAllReferences_exports.Core.eachSymbolReferenceInFile(declaration.name, checker, file, (ref) => {
|
|
140585
|
-
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref)) {
|
|
140603
|
+
if (ts_FindAllReferences_exports.isWriteAccessForReference(ref) && !isShorthandPropertyAssignment(ref.parent)) {
|
|
140586
140604
|
return true;
|
|
140587
140605
|
}
|
|
140588
140606
|
if (isExportSpecifier(ref.parent) || isExportAssignment(ref.parent)) {
|
|
@@ -140610,6 +140628,9 @@ function getReplacementExpression(reference, replacement) {
|
|
|
140610
140628
|
if (isPropertyAccessExpression(parent2) && (isNumericLiteral(replacement) || isObjectLiteralExpression(replacement))) {
|
|
140611
140629
|
return factory.createParenthesizedExpression(replacement);
|
|
140612
140630
|
}
|
|
140631
|
+
if (isIdentifier(reference) && isShorthandPropertyAssignment(parent2)) {
|
|
140632
|
+
return factory.createPropertyAssignment(reference, replacement);
|
|
140633
|
+
}
|
|
140613
140634
|
return replacement;
|
|
140614
140635
|
}
|
|
140615
140636
|
|
|
@@ -140859,10 +140880,11 @@ function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsT
|
|
|
140859
140880
|
forEachImportInStatement(oldStatement, (i) => {
|
|
140860
140881
|
var _a;
|
|
140861
140882
|
const moduleSpecifier = moduleSpecifierFromImport(i);
|
|
140862
|
-
const
|
|
140883
|
+
const compilerOptions = program.getCompilerOptions();
|
|
140884
|
+
const resolved = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier);
|
|
140863
140885
|
const fileName = (_a = resolved == null ? void 0 : resolved.resolvedModule) == null ? void 0 : _a.resolvedFileName;
|
|
140864
140886
|
if (fileName && targetSourceFile) {
|
|
140865
|
-
const newModuleSpecifier = getModuleSpecifier(
|
|
140887
|
+
const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
|
|
140866
140888
|
append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
|
|
140867
140889
|
} else {
|
|
140868
140890
|
append(copiedOldImports, filterImport(i, factory.createStringLiteral(moduleSpecifierFromImport(i).text), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
|
|
@@ -140973,7 +140995,7 @@ function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, n
|
|
|
140973
140995
|
needUniqueName = needUniqueName || !!checker.resolveName(
|
|
140974
140996
|
preferredNewNamespaceName,
|
|
140975
140997
|
ref,
|
|
140976
|
-
|
|
140998
|
+
-1 /* All */,
|
|
140977
140999
|
/*excludeGlobals*/
|
|
140978
141000
|
true
|
|
140979
141001
|
);
|
|
@@ -146737,12 +146759,12 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
146737
146759
|
}
|
|
146738
146760
|
return [];
|
|
146739
146761
|
}
|
|
146740
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
146762
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes65, formatOptions, preferences = emptyOptions) {
|
|
146741
146763
|
synchronizeHostData();
|
|
146742
146764
|
const sourceFile = getValidSourceFile(fileName);
|
|
146743
146765
|
const span = createTextSpanFromBounds(start2, end);
|
|
146744
146766
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
146745
|
-
return flatMap(deduplicate(
|
|
146767
|
+
return flatMap(deduplicate(errorCodes65, equateValues, compareValues), (errorCode) => {
|
|
146746
146768
|
cancellationToken.throwIfCancellationRequested();
|
|
146747
146769
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
146748
146770
|
});
|
|
@@ -148450,10 +148472,10 @@ function getSupportedErrorCodes() {
|
|
|
148450
148472
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
148451
148473
|
}
|
|
148452
148474
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
148453
|
-
const { errorCodes:
|
|
148475
|
+
const { errorCodes: errorCodes65 } = registration;
|
|
148454
148476
|
let maybeFixableDiagnostics = 0;
|
|
148455
148477
|
for (const diag2 of diagnostics) {
|
|
148456
|
-
if (contains(
|
|
148478
|
+
if (contains(errorCodes65, diag2.code))
|
|
148457
148479
|
maybeFixableDiagnostics++;
|
|
148458
148480
|
if (maybeFixableDiagnostics > 1)
|
|
148459
148481
|
break;
|
|
@@ -148477,14 +148499,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
148477
148499
|
function createFileTextChanges(fileName, textChanges2) {
|
|
148478
148500
|
return { fileName, textChanges: textChanges2 };
|
|
148479
148501
|
}
|
|
148480
|
-
function codeFixAll(context,
|
|
148502
|
+
function codeFixAll(context, errorCodes65, use) {
|
|
148481
148503
|
const commands = [];
|
|
148482
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
148504
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes65, (diag2) => use(t, diag2, commands)));
|
|
148483
148505
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
148484
148506
|
}
|
|
148485
|
-
function eachDiagnostic(context,
|
|
148507
|
+
function eachDiagnostic(context, errorCodes65, cb) {
|
|
148486
148508
|
for (const diag2 of getDiagnostics(context)) {
|
|
148487
|
-
if (contains(
|
|
148509
|
+
if (contains(errorCodes65, diag2.code)) {
|
|
148488
148510
|
cb(diag2);
|
|
148489
148511
|
}
|
|
148490
148512
|
}
|
|
@@ -150308,7 +150330,7 @@ registerCodeFix({
|
|
|
150308
150330
|
function fixImportOfModuleExports(importingFile, exportingFile, program, changes, quotePreference) {
|
|
150309
150331
|
var _a;
|
|
150310
150332
|
for (const moduleSpecifier of importingFile.imports) {
|
|
150311
|
-
const imported = (_a = program.
|
|
150333
|
+
const imported = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
150312
150334
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
150313
150335
|
continue;
|
|
150314
150336
|
}
|
|
@@ -152225,6 +152247,7 @@ function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
|
|
|
152225
152247
|
case 7 /* ES2022 */:
|
|
152226
152248
|
case 99 /* ESNext */:
|
|
152227
152249
|
case 0 /* None */:
|
|
152250
|
+
case 200 /* Preserve */:
|
|
152228
152251
|
return 2 /* Namespace */;
|
|
152229
152252
|
case 100 /* Node16 */:
|
|
152230
152253
|
case 199 /* NodeNext */:
|
|
@@ -152456,7 +152479,7 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
152456
152479
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
152457
152480
|
if (!compilerOptions.allowImportingTsExtensions) {
|
|
152458
152481
|
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
152459
|
-
const resolvedModule = moduleSpecifier && ((_a = program.
|
|
152482
|
+
const resolvedModule = moduleSpecifier && ((_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule);
|
|
152460
152483
|
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
152461
152484
|
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
152462
152485
|
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
@@ -153133,15 +153156,10 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
153133
153156
|
const importDeclaration = findAncestor(token, isImportDeclaration);
|
|
153134
153157
|
if (importDeclaration === void 0)
|
|
153135
153158
|
return void 0;
|
|
153136
|
-
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier
|
|
153159
|
+
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier : void 0;
|
|
153137
153160
|
if (moduleSpecifier === void 0)
|
|
153138
153161
|
return void 0;
|
|
153139
|
-
const resolvedModule = (_a = program.
|
|
153140
|
-
sourceFile,
|
|
153141
|
-
moduleSpecifier,
|
|
153142
|
-
/*mode*/
|
|
153143
|
-
void 0
|
|
153144
|
-
)) == null ? void 0 : _a.resolvedModule;
|
|
153162
|
+
const resolvedModule = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
153145
153163
|
if (resolvedModule === void 0)
|
|
153146
153164
|
return void 0;
|
|
153147
153165
|
const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -153158,7 +153176,7 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
153158
153176
|
if (node === void 0)
|
|
153159
153177
|
return void 0;
|
|
153160
153178
|
const exportName = { node: token, isTypeOnly: isTypeDeclaration(node) };
|
|
153161
|
-
return { exportName, node, moduleSourceFile, moduleSpecifier };
|
|
153179
|
+
return { exportName, node, moduleSourceFile, moduleSpecifier: moduleSpecifier.text };
|
|
153162
153180
|
}
|
|
153163
153181
|
return void 0;
|
|
153164
153182
|
}
|
|
@@ -153352,7 +153370,7 @@ function getInfo8(sourceFile, pos, context, errorCode) {
|
|
|
153352
153370
|
} else if (isImportSpecifier(parent2) && parent2.name === node) {
|
|
153353
153371
|
Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)");
|
|
153354
153372
|
const importDeclaration = findAncestor(node, isImportDeclaration);
|
|
153355
|
-
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(
|
|
153373
|
+
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration);
|
|
153356
153374
|
if (resolvedSourceFile && resolvedSourceFile.symbol) {
|
|
153357
153375
|
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol);
|
|
153358
153376
|
}
|
|
@@ -153402,11 +153420,11 @@ function convertSemanticMeaningToSymbolFlags(meaning) {
|
|
|
153402
153420
|
}
|
|
153403
153421
|
return flags;
|
|
153404
153422
|
}
|
|
153405
|
-
function getResolvedSourceFileFromImportDeclaration(
|
|
153423
|
+
function getResolvedSourceFileFromImportDeclaration(context, importDeclaration) {
|
|
153406
153424
|
var _a;
|
|
153407
153425
|
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier))
|
|
153408
153426
|
return void 0;
|
|
153409
|
-
const resolvedModule = (_a = context.program.
|
|
153427
|
+
const resolvedModule = (_a = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
153410
153428
|
if (!resolvedModule)
|
|
153411
153429
|
return void 0;
|
|
153412
153430
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -154326,16 +154344,242 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
154326
154344
|
return token;
|
|
154327
154345
|
}
|
|
154328
154346
|
|
|
154347
|
+
// src/services/codefixes/fixAddMissingParam.ts
|
|
154348
|
+
var addMissingParamFixId = "addMissingParam";
|
|
154349
|
+
var addOptionalParamFixId = "addOptionalParam";
|
|
154350
|
+
var errorCodes29 = [Diagnostics.Expected_0_arguments_but_got_1.code];
|
|
154351
|
+
registerCodeFix({
|
|
154352
|
+
errorCodes: errorCodes29,
|
|
154353
|
+
fixIds: [addMissingParamFixId, addOptionalParamFixId],
|
|
154354
|
+
getCodeActions(context) {
|
|
154355
|
+
const info = getInfo11(context.sourceFile, context.program, context.span.start);
|
|
154356
|
+
if (info === void 0)
|
|
154357
|
+
return void 0;
|
|
154358
|
+
const { name, declarations, newParameters, newOptionalParameters } = info;
|
|
154359
|
+
const actions2 = [];
|
|
154360
|
+
if (length(newParameters)) {
|
|
154361
|
+
append(
|
|
154362
|
+
actions2,
|
|
154363
|
+
createCodeFixAction(
|
|
154364
|
+
addMissingParamFixId,
|
|
154365
|
+
ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, declarations, newParameters)),
|
|
154366
|
+
[length(newParameters) > 1 ? Diagnostics.Add_missing_parameters_to_0 : Diagnostics.Add_missing_parameter_to_0, name],
|
|
154367
|
+
addMissingParamFixId,
|
|
154368
|
+
Diagnostics.Add_all_missing_parameters
|
|
154369
|
+
)
|
|
154370
|
+
);
|
|
154371
|
+
}
|
|
154372
|
+
if (length(newOptionalParameters)) {
|
|
154373
|
+
append(
|
|
154374
|
+
actions2,
|
|
154375
|
+
createCodeFixAction(
|
|
154376
|
+
addOptionalParamFixId,
|
|
154377
|
+
ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, declarations, newOptionalParameters)),
|
|
154378
|
+
[length(newOptionalParameters) > 1 ? Diagnostics.Add_optional_parameters_to_0 : Diagnostics.Add_optional_parameter_to_0, name],
|
|
154379
|
+
addOptionalParamFixId,
|
|
154380
|
+
Diagnostics.Add_all_optional_parameters
|
|
154381
|
+
)
|
|
154382
|
+
);
|
|
154383
|
+
}
|
|
154384
|
+
return actions2;
|
|
154385
|
+
},
|
|
154386
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes29, (changes, diag2) => {
|
|
154387
|
+
const info = getInfo11(context.sourceFile, context.program, diag2.start);
|
|
154388
|
+
if (info) {
|
|
154389
|
+
const { declarations, newParameters, newOptionalParameters } = info;
|
|
154390
|
+
if (context.fixId === addMissingParamFixId) {
|
|
154391
|
+
doChange19(changes, context.sourceFile, declarations, newParameters);
|
|
154392
|
+
}
|
|
154393
|
+
if (context.fixId === addOptionalParamFixId) {
|
|
154394
|
+
doChange19(changes, context.sourceFile, declarations, newOptionalParameters);
|
|
154395
|
+
}
|
|
154396
|
+
}
|
|
154397
|
+
})
|
|
154398
|
+
});
|
|
154399
|
+
function getInfo11(sourceFile, program, pos) {
|
|
154400
|
+
const token = getTokenAtPosition(sourceFile, pos);
|
|
154401
|
+
const callExpression = findAncestor(token, isCallExpression);
|
|
154402
|
+
if (callExpression === void 0 || length(callExpression.arguments) === 0) {
|
|
154403
|
+
return void 0;
|
|
154404
|
+
}
|
|
154405
|
+
const checker = program.getTypeChecker();
|
|
154406
|
+
const type = checker.getTypeAtLocation(callExpression.expression);
|
|
154407
|
+
const convertibleSignatureDeclarations = filter(type.symbol.declarations, isConvertibleSignatureDeclaration);
|
|
154408
|
+
if (convertibleSignatureDeclarations === void 0) {
|
|
154409
|
+
return void 0;
|
|
154410
|
+
}
|
|
154411
|
+
const nonOverloadDeclaration = lastOrUndefined(convertibleSignatureDeclarations);
|
|
154412
|
+
if (nonOverloadDeclaration === void 0 || nonOverloadDeclaration.body === void 0 || isSourceFileFromLibrary(program, nonOverloadDeclaration.getSourceFile())) {
|
|
154413
|
+
return void 0;
|
|
154414
|
+
}
|
|
154415
|
+
const name = tryGetName2(nonOverloadDeclaration);
|
|
154416
|
+
if (name === void 0) {
|
|
154417
|
+
return void 0;
|
|
154418
|
+
}
|
|
154419
|
+
const newParameters = [];
|
|
154420
|
+
const newOptionalParameters = [];
|
|
154421
|
+
const parametersLength = length(nonOverloadDeclaration.parameters);
|
|
154422
|
+
const argumentsLength = length(callExpression.arguments);
|
|
154423
|
+
if (parametersLength > argumentsLength) {
|
|
154424
|
+
return void 0;
|
|
154425
|
+
}
|
|
154426
|
+
const declarations = [nonOverloadDeclaration, ...getOverloads(nonOverloadDeclaration, convertibleSignatureDeclarations)];
|
|
154427
|
+
for (let i = 0, pos2 = 0, paramIndex = 0; i < argumentsLength; i++) {
|
|
154428
|
+
const arg = callExpression.arguments[i];
|
|
154429
|
+
const expr = isAccessExpression(arg) ? getNameOfAccessExpression(arg) : arg;
|
|
154430
|
+
const type2 = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)));
|
|
154431
|
+
const parameter = pos2 < parametersLength ? nonOverloadDeclaration.parameters[pos2] : void 0;
|
|
154432
|
+
if (parameter && checker.isTypeAssignableTo(type2, checker.getTypeAtLocation(parameter))) {
|
|
154433
|
+
pos2++;
|
|
154434
|
+
continue;
|
|
154435
|
+
}
|
|
154436
|
+
const name2 = expr && isIdentifier(expr) ? expr.text : `p${paramIndex++}`;
|
|
154437
|
+
const typeNode = typeToTypeNode(checker, type2, nonOverloadDeclaration);
|
|
154438
|
+
append(newParameters, {
|
|
154439
|
+
pos: i,
|
|
154440
|
+
declaration: createParameter(
|
|
154441
|
+
name2,
|
|
154442
|
+
typeNode,
|
|
154443
|
+
/*questionToken*/
|
|
154444
|
+
void 0
|
|
154445
|
+
)
|
|
154446
|
+
});
|
|
154447
|
+
if (isOptionalPos(declarations, pos2)) {
|
|
154448
|
+
continue;
|
|
154449
|
+
}
|
|
154450
|
+
append(newOptionalParameters, {
|
|
154451
|
+
pos: i,
|
|
154452
|
+
declaration: createParameter(name2, typeNode, factory.createToken(58 /* QuestionToken */))
|
|
154453
|
+
});
|
|
154454
|
+
}
|
|
154455
|
+
return {
|
|
154456
|
+
newParameters,
|
|
154457
|
+
newOptionalParameters,
|
|
154458
|
+
name: declarationNameToString(name),
|
|
154459
|
+
declarations
|
|
154460
|
+
};
|
|
154461
|
+
}
|
|
154462
|
+
function tryGetName2(node) {
|
|
154463
|
+
const name = getNameOfDeclaration(node);
|
|
154464
|
+
if (name) {
|
|
154465
|
+
return name;
|
|
154466
|
+
}
|
|
154467
|
+
if (isVariableDeclaration(node.parent) && isIdentifier(node.parent.name) || isPropertyDeclaration(node.parent) || isParameter(node.parent)) {
|
|
154468
|
+
return node.parent.name;
|
|
154469
|
+
}
|
|
154470
|
+
}
|
|
154471
|
+
function typeToTypeNode(checker, type, enclosingDeclaration) {
|
|
154472
|
+
return checker.typeToTypeNode(checker.getWidenedType(type), enclosingDeclaration, 1 /* NoTruncation */) ?? factory.createKeywordTypeNode(159 /* UnknownKeyword */);
|
|
154473
|
+
}
|
|
154474
|
+
function doChange19(changes, sourceFile, declarations, newParameters) {
|
|
154475
|
+
forEach(declarations, (declaration) => {
|
|
154476
|
+
if (length(declaration.parameters)) {
|
|
154477
|
+
changes.replaceNodeRangeWithNodes(
|
|
154478
|
+
sourceFile,
|
|
154479
|
+
first(declaration.parameters),
|
|
154480
|
+
last(declaration.parameters),
|
|
154481
|
+
updateParameters(declaration, newParameters),
|
|
154482
|
+
{
|
|
154483
|
+
joiner: ", ",
|
|
154484
|
+
indentation: 0,
|
|
154485
|
+
leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.IncludeAll,
|
|
154486
|
+
trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.Include
|
|
154487
|
+
}
|
|
154488
|
+
);
|
|
154489
|
+
} else {
|
|
154490
|
+
forEach(updateParameters(declaration, newParameters), (parameter, index) => {
|
|
154491
|
+
if (length(declaration.parameters) === 0 && index === 0) {
|
|
154492
|
+
changes.insertNodeAt(sourceFile, declaration.parameters.end, parameter);
|
|
154493
|
+
} else {
|
|
154494
|
+
changes.insertNodeAtEndOfList(sourceFile, declaration.parameters, parameter);
|
|
154495
|
+
}
|
|
154496
|
+
});
|
|
154497
|
+
}
|
|
154498
|
+
});
|
|
154499
|
+
}
|
|
154500
|
+
function isConvertibleSignatureDeclaration(node) {
|
|
154501
|
+
switch (node.kind) {
|
|
154502
|
+
case 262 /* FunctionDeclaration */:
|
|
154503
|
+
case 218 /* FunctionExpression */:
|
|
154504
|
+
case 174 /* MethodDeclaration */:
|
|
154505
|
+
case 219 /* ArrowFunction */:
|
|
154506
|
+
return true;
|
|
154507
|
+
default:
|
|
154508
|
+
return false;
|
|
154509
|
+
}
|
|
154510
|
+
}
|
|
154511
|
+
function updateParameters(node, newParameters) {
|
|
154512
|
+
const parameters = map(node.parameters, (p) => factory.createParameterDeclaration(
|
|
154513
|
+
p.modifiers,
|
|
154514
|
+
p.dotDotDotToken,
|
|
154515
|
+
p.name,
|
|
154516
|
+
p.questionToken,
|
|
154517
|
+
p.type,
|
|
154518
|
+
p.initializer
|
|
154519
|
+
));
|
|
154520
|
+
for (const { pos, declaration } of newParameters) {
|
|
154521
|
+
const prev = pos > 0 ? parameters[pos - 1] : void 0;
|
|
154522
|
+
parameters.splice(
|
|
154523
|
+
pos,
|
|
154524
|
+
0,
|
|
154525
|
+
factory.updateParameterDeclaration(
|
|
154526
|
+
declaration,
|
|
154527
|
+
declaration.modifiers,
|
|
154528
|
+
declaration.dotDotDotToken,
|
|
154529
|
+
declaration.name,
|
|
154530
|
+
prev && prev.questionToken ? factory.createToken(58 /* QuestionToken */) : declaration.questionToken,
|
|
154531
|
+
declaration.type,
|
|
154532
|
+
declaration.initializer
|
|
154533
|
+
)
|
|
154534
|
+
);
|
|
154535
|
+
}
|
|
154536
|
+
return parameters;
|
|
154537
|
+
}
|
|
154538
|
+
function getOverloads(implementation, declarations) {
|
|
154539
|
+
const overloads = [];
|
|
154540
|
+
for (const declaration of declarations) {
|
|
154541
|
+
if (isOverload(declaration)) {
|
|
154542
|
+
if (length(declaration.parameters) === length(implementation.parameters)) {
|
|
154543
|
+
overloads.push(declaration);
|
|
154544
|
+
continue;
|
|
154545
|
+
}
|
|
154546
|
+
if (length(declaration.parameters) > length(implementation.parameters)) {
|
|
154547
|
+
return [];
|
|
154548
|
+
}
|
|
154549
|
+
}
|
|
154550
|
+
}
|
|
154551
|
+
return overloads;
|
|
154552
|
+
}
|
|
154553
|
+
function isOverload(declaration) {
|
|
154554
|
+
return isConvertibleSignatureDeclaration(declaration) && declaration.body === void 0;
|
|
154555
|
+
}
|
|
154556
|
+
function createParameter(name, type, questionToken) {
|
|
154557
|
+
return factory.createParameterDeclaration(
|
|
154558
|
+
/*modifiers*/
|
|
154559
|
+
void 0,
|
|
154560
|
+
/*dotDotDotToken*/
|
|
154561
|
+
void 0,
|
|
154562
|
+
name,
|
|
154563
|
+
questionToken,
|
|
154564
|
+
type,
|
|
154565
|
+
/*initializer*/
|
|
154566
|
+
void 0
|
|
154567
|
+
);
|
|
154568
|
+
}
|
|
154569
|
+
function isOptionalPos(declarations, pos) {
|
|
154570
|
+
return length(declarations) && some(declarations, (d) => pos < length(d.parameters) && !!d.parameters[pos] && d.parameters[pos].questionToken === void 0);
|
|
154571
|
+
}
|
|
154572
|
+
|
|
154329
154573
|
// src/services/codefixes/fixCannotFindModule.ts
|
|
154330
154574
|
var fixName2 = "fixCannotFindModule";
|
|
154331
154575
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
154332
154576
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
154333
|
-
var
|
|
154577
|
+
var errorCodes30 = [
|
|
154334
154578
|
errorCodeCannotFindModule,
|
|
154335
154579
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
154336
154580
|
];
|
|
154337
154581
|
registerCodeFix({
|
|
154338
|
-
errorCodes:
|
|
154582
|
+
errorCodes: errorCodes30,
|
|
154339
154583
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
154340
154584
|
const { host, sourceFile, span: { start: start2 } } = context;
|
|
154341
154585
|
const packageName = tryGetImportedPackageName(sourceFile, start2);
|
|
@@ -154354,7 +154598,7 @@ registerCodeFix({
|
|
|
154354
154598
|
},
|
|
154355
154599
|
fixIds: [fixIdInstallTypesPackage],
|
|
154356
154600
|
getAllCodeActions: (context) => {
|
|
154357
|
-
return codeFixAll(context,
|
|
154601
|
+
return codeFixAll(context, errorCodes30, (_changes, diag2, commands) => {
|
|
154358
154602
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
154359
154603
|
if (packageName === void 0)
|
|
154360
154604
|
return void 0;
|
|
@@ -154389,12 +154633,12 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
154389
154633
|
}
|
|
154390
154634
|
|
|
154391
154635
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
154392
|
-
var
|
|
154636
|
+
var errorCodes31 = [
|
|
154393
154637
|
Diagnostics.Non_abstract_class_0_does_not_implement_all_abstract_members_of_1.code
|
|
154394
154638
|
];
|
|
154395
154639
|
var fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
154396
154640
|
registerCodeFix({
|
|
154397
|
-
errorCodes:
|
|
154641
|
+
errorCodes: errorCodes31,
|
|
154398
154642
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
154399
154643
|
const { sourceFile, span } = context;
|
|
154400
154644
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
@@ -154403,7 +154647,7 @@ registerCodeFix({
|
|
|
154403
154647
|
fixIds: [fixId25],
|
|
154404
154648
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
154405
154649
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
154406
|
-
return codeFixAll(context,
|
|
154650
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
154407
154651
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
154408
154652
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
154409
154653
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -154431,34 +154675,34 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
154431
154675
|
|
|
154432
154676
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
154433
154677
|
var fixId26 = "classSuperMustPrecedeThisAccess";
|
|
154434
|
-
var
|
|
154678
|
+
var errorCodes32 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
154435
154679
|
registerCodeFix({
|
|
154436
|
-
errorCodes:
|
|
154680
|
+
errorCodes: errorCodes32,
|
|
154437
154681
|
getCodeActions(context) {
|
|
154438
154682
|
const { sourceFile, span } = context;
|
|
154439
154683
|
const nodes = getNodes(sourceFile, span.start);
|
|
154440
154684
|
if (!nodes)
|
|
154441
154685
|
return void 0;
|
|
154442
154686
|
const { constructor, superCall } = nodes;
|
|
154443
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154687
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, sourceFile, constructor, superCall));
|
|
154444
154688
|
return [createCodeFixAction(fixId26, changes, Diagnostics.Make_super_call_the_first_statement_in_the_constructor, fixId26, Diagnostics.Make_all_super_calls_the_first_statement_in_their_constructor)];
|
|
154445
154689
|
},
|
|
154446
154690
|
fixIds: [fixId26],
|
|
154447
154691
|
getAllCodeActions(context) {
|
|
154448
154692
|
const { sourceFile } = context;
|
|
154449
154693
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
154450
|
-
return codeFixAll(context,
|
|
154694
|
+
return codeFixAll(context, errorCodes32, (changes, diag2) => {
|
|
154451
154695
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
154452
154696
|
if (!nodes)
|
|
154453
154697
|
return;
|
|
154454
154698
|
const { constructor, superCall } = nodes;
|
|
154455
154699
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
154456
|
-
|
|
154700
|
+
doChange20(changes, sourceFile, constructor, superCall);
|
|
154457
154701
|
}
|
|
154458
154702
|
});
|
|
154459
154703
|
}
|
|
154460
154704
|
});
|
|
154461
|
-
function
|
|
154705
|
+
function doChange20(changes, sourceFile, constructor, superCall) {
|
|
154462
154706
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
154463
154707
|
changes.delete(sourceFile, superCall);
|
|
154464
154708
|
}
|
|
@@ -154476,24 +154720,24 @@ function findSuperCall(n) {
|
|
|
154476
154720
|
|
|
154477
154721
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
154478
154722
|
var fixId27 = "constructorForDerivedNeedSuperCall";
|
|
154479
|
-
var
|
|
154723
|
+
var errorCodes33 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
154480
154724
|
registerCodeFix({
|
|
154481
|
-
errorCodes:
|
|
154725
|
+
errorCodes: errorCodes33,
|
|
154482
154726
|
getCodeActions(context) {
|
|
154483
154727
|
const { sourceFile, span } = context;
|
|
154484
154728
|
const ctr = getNode(sourceFile, span.start);
|
|
154485
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154729
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, ctr));
|
|
154486
154730
|
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
154487
154731
|
},
|
|
154488
154732
|
fixIds: [fixId27],
|
|
154489
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154733
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes, diag2) => doChange21(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
154490
154734
|
});
|
|
154491
154735
|
function getNode(sourceFile, pos) {
|
|
154492
154736
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
154493
154737
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
154494
154738
|
return token.parent;
|
|
154495
154739
|
}
|
|
154496
|
-
function
|
|
154740
|
+
function doChange21(changes, sourceFile, ctr) {
|
|
154497
154741
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
154498
154742
|
factory.createSuper(),
|
|
154499
154743
|
/*typeArguments*/
|
|
@@ -154506,59 +154750,59 @@ function doChange20(changes, sourceFile, ctr) {
|
|
|
154506
154750
|
|
|
154507
154751
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
154508
154752
|
var fixID = "fixEnableJsxFlag";
|
|
154509
|
-
var
|
|
154753
|
+
var errorCodes34 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
154510
154754
|
registerCodeFix({
|
|
154511
|
-
errorCodes:
|
|
154755
|
+
errorCodes: errorCodes34,
|
|
154512
154756
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
154513
154757
|
const { configFile } = context.program.getCompilerOptions();
|
|
154514
154758
|
if (configFile === void 0) {
|
|
154515
154759
|
return void 0;
|
|
154516
154760
|
}
|
|
154517
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) =>
|
|
154761
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) => doChange22(changeTracker, configFile));
|
|
154518
154762
|
return [
|
|
154519
154763
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
154520
154764
|
];
|
|
154521
154765
|
},
|
|
154522
154766
|
fixIds: [fixID],
|
|
154523
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154767
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes34, (changes) => {
|
|
154524
154768
|
const { configFile } = context.program.getCompilerOptions();
|
|
154525
154769
|
if (configFile === void 0) {
|
|
154526
154770
|
return void 0;
|
|
154527
154771
|
}
|
|
154528
|
-
|
|
154772
|
+
doChange22(changes, configFile);
|
|
154529
154773
|
})
|
|
154530
154774
|
});
|
|
154531
|
-
function
|
|
154775
|
+
function doChange22(changeTracker, configFile) {
|
|
154532
154776
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
154533
154777
|
}
|
|
154534
154778
|
|
|
154535
154779
|
// src/services/codefixes/fixNaNEquality.ts
|
|
154536
154780
|
var fixId28 = "fixNaNEquality";
|
|
154537
|
-
var
|
|
154781
|
+
var errorCodes35 = [
|
|
154538
154782
|
Diagnostics.This_condition_will_always_return_0.code
|
|
154539
154783
|
];
|
|
154540
154784
|
registerCodeFix({
|
|
154541
|
-
errorCodes:
|
|
154785
|
+
errorCodes: errorCodes35,
|
|
154542
154786
|
getCodeActions(context) {
|
|
154543
154787
|
const { sourceFile, span, program } = context;
|
|
154544
|
-
const info =
|
|
154788
|
+
const info = getInfo12(program, sourceFile, span);
|
|
154545
154789
|
if (info === void 0)
|
|
154546
154790
|
return;
|
|
154547
154791
|
const { suggestion, expression, arg } = info;
|
|
154548
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154792
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, arg, expression));
|
|
154549
154793
|
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
154550
154794
|
},
|
|
154551
154795
|
fixIds: [fixId28],
|
|
154552
154796
|
getAllCodeActions: (context) => {
|
|
154553
|
-
return codeFixAll(context,
|
|
154554
|
-
const info =
|
|
154797
|
+
return codeFixAll(context, errorCodes35, (changes, diag2) => {
|
|
154798
|
+
const info = getInfo12(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
154555
154799
|
if (info) {
|
|
154556
|
-
|
|
154800
|
+
doChange23(changes, diag2.file, info.arg, info.expression);
|
|
154557
154801
|
}
|
|
154558
154802
|
});
|
|
154559
154803
|
}
|
|
154560
154804
|
});
|
|
154561
|
-
function
|
|
154805
|
+
function getInfo12(program, sourceFile, span) {
|
|
154562
154806
|
const diag2 = find(program.getSemanticDiagnostics(sourceFile), (diag3) => diag3.start === span.start && diag3.length === span.length);
|
|
154563
154807
|
if (diag2 === void 0 || diag2.relatedInformation === void 0)
|
|
154564
154808
|
return;
|
|
@@ -154573,7 +154817,7 @@ function getInfo11(program, sourceFile, span) {
|
|
|
154573
154817
|
}
|
|
154574
154818
|
return void 0;
|
|
154575
154819
|
}
|
|
154576
|
-
function
|
|
154820
|
+
function doChange23(changes, sourceFile, arg, expression) {
|
|
154577
154821
|
const callExpression = factory.createCallExpression(
|
|
154578
154822
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
154579
154823
|
/*typeArguments*/
|
|
@@ -154595,9 +154839,9 @@ function getSuggestion(messageText) {
|
|
|
154595
154839
|
// src/services/codefixes/fixModuleAndTargetOptions.ts
|
|
154596
154840
|
registerCodeFix({
|
|
154597
154841
|
errorCodes: [
|
|
154598
|
-
Diagnostics.
|
|
154599
|
-
Diagnostics.
|
|
154600
|
-
Diagnostics.
|
|
154842
|
+
Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code,
|
|
154843
|
+
Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code,
|
|
154844
|
+
Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code
|
|
154601
154845
|
],
|
|
154602
154846
|
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
|
|
154603
154847
|
const compilerOptions = context.program.getCompilerOptions();
|
|
@@ -154635,21 +154879,21 @@ registerCodeFix({
|
|
|
154635
154879
|
|
|
154636
154880
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
154637
154881
|
var fixId29 = "fixPropertyAssignment";
|
|
154638
|
-
var
|
|
154882
|
+
var errorCodes36 = [
|
|
154639
154883
|
Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code
|
|
154640
154884
|
];
|
|
154641
154885
|
registerCodeFix({
|
|
154642
|
-
errorCodes:
|
|
154886
|
+
errorCodes: errorCodes36,
|
|
154643
154887
|
fixIds: [fixId29],
|
|
154644
154888
|
getCodeActions(context) {
|
|
154645
154889
|
const { sourceFile, span } = context;
|
|
154646
154890
|
const property = getProperty2(sourceFile, span.start);
|
|
154647
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154891
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange24(t, context.sourceFile, property));
|
|
154648
154892
|
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
154649
154893
|
},
|
|
154650
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154894
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => doChange24(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
154651
154895
|
});
|
|
154652
|
-
function
|
|
154896
|
+
function doChange24(changes, sourceFile, node) {
|
|
154653
154897
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
154654
154898
|
}
|
|
154655
154899
|
function getProperty2(sourceFile, pos) {
|
|
@@ -154658,9 +154902,9 @@ function getProperty2(sourceFile, pos) {
|
|
|
154658
154902
|
|
|
154659
154903
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
154660
154904
|
var fixId30 = "extendsInterfaceBecomesImplements";
|
|
154661
|
-
var
|
|
154905
|
+
var errorCodes37 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
154662
154906
|
registerCodeFix({
|
|
154663
|
-
errorCodes:
|
|
154907
|
+
errorCodes: errorCodes37,
|
|
154664
154908
|
getCodeActions(context) {
|
|
154665
154909
|
const { sourceFile } = context;
|
|
154666
154910
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -154671,7 +154915,7 @@ registerCodeFix({
|
|
|
154671
154915
|
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
154672
154916
|
},
|
|
154673
154917
|
fixIds: [fixId30],
|
|
154674
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154918
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
154675
154919
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
154676
154920
|
if (nodes)
|
|
154677
154921
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -154701,36 +154945,36 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
154701
154945
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
154702
154946
|
var fixId31 = "forgottenThisPropertyAccess";
|
|
154703
154947
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
154704
|
-
var
|
|
154948
|
+
var errorCodes38 = [
|
|
154705
154949
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
154706
154950
|
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,
|
|
154707
154951
|
didYouMeanStaticMemberCode
|
|
154708
154952
|
];
|
|
154709
154953
|
registerCodeFix({
|
|
154710
|
-
errorCodes:
|
|
154954
|
+
errorCodes: errorCodes38,
|
|
154711
154955
|
getCodeActions(context) {
|
|
154712
154956
|
const { sourceFile } = context;
|
|
154713
|
-
const info =
|
|
154957
|
+
const info = getInfo13(sourceFile, context.span.start, context.errorCode);
|
|
154714
154958
|
if (!info) {
|
|
154715
154959
|
return void 0;
|
|
154716
154960
|
}
|
|
154717
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154961
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange25(t, sourceFile, info));
|
|
154718
154962
|
return [createCodeFixAction(fixId31, changes, [Diagnostics.Add_0_to_unresolved_variable, info.className || "this"], fixId31, Diagnostics.Add_qualifier_to_all_unresolved_variables_matching_a_member_name)];
|
|
154719
154963
|
},
|
|
154720
154964
|
fixIds: [fixId31],
|
|
154721
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154722
|
-
const info =
|
|
154965
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes38, (changes, diag2) => {
|
|
154966
|
+
const info = getInfo13(diag2.file, diag2.start, diag2.code);
|
|
154723
154967
|
if (info)
|
|
154724
|
-
|
|
154968
|
+
doChange25(changes, context.sourceFile, info);
|
|
154725
154969
|
})
|
|
154726
154970
|
});
|
|
154727
|
-
function
|
|
154971
|
+
function getInfo13(sourceFile, pos, diagCode) {
|
|
154728
154972
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
154729
154973
|
if (isIdentifier(node) || isPrivateIdentifier(node)) {
|
|
154730
154974
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
154731
154975
|
}
|
|
154732
154976
|
}
|
|
154733
|
-
function
|
|
154977
|
+
function doChange25(changes, sourceFile, { node, className }) {
|
|
154734
154978
|
suppressLeadingAndTrailingTrivia(node);
|
|
154735
154979
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
154736
154980
|
}
|
|
@@ -154738,16 +154982,16 @@ function doChange24(changes, sourceFile, { node, className }) {
|
|
|
154738
154982
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
154739
154983
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
154740
154984
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
154741
|
-
var
|
|
154985
|
+
var errorCodes39 = [
|
|
154742
154986
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
154743
154987
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
154744
154988
|
];
|
|
154745
154989
|
registerCodeFix({
|
|
154746
|
-
errorCodes:
|
|
154990
|
+
errorCodes: errorCodes39,
|
|
154747
154991
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
154748
154992
|
getCodeActions(context) {
|
|
154749
154993
|
const { sourceFile, preferences, span } = context;
|
|
154750
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154994
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(
|
|
154751
154995
|
t,
|
|
154752
154996
|
preferences,
|
|
154753
154997
|
sourceFile,
|
|
@@ -154755,7 +154999,7 @@ registerCodeFix({
|
|
|
154755
154999
|
/*useHtmlEntity*/
|
|
154756
155000
|
false
|
|
154757
155001
|
));
|
|
154758
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155002
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(
|
|
154759
155003
|
t,
|
|
154760
155004
|
preferences,
|
|
154761
155005
|
sourceFile,
|
|
@@ -154769,7 +155013,7 @@ registerCodeFix({
|
|
|
154769
155013
|
];
|
|
154770
155014
|
},
|
|
154771
155015
|
getAllCodeActions(context) {
|
|
154772
|
-
return codeFixAll(context,
|
|
155016
|
+
return codeFixAll(context, errorCodes39, (changes, diagnostic) => doChange26(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
154773
155017
|
}
|
|
154774
155018
|
});
|
|
154775
155019
|
var htmlEntity = {
|
|
@@ -154779,7 +155023,7 @@ var htmlEntity = {
|
|
|
154779
155023
|
function isValidCharacter(character) {
|
|
154780
155024
|
return hasProperty(htmlEntity, character);
|
|
154781
155025
|
}
|
|
154782
|
-
function
|
|
155026
|
+
function doChange26(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
154783
155027
|
const character = sourceFile.getText()[start2];
|
|
154784
155028
|
if (!isValidCharacter(character)) {
|
|
154785
155029
|
return;
|
|
@@ -154791,16 +155035,16 @@ function doChange25(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
|
154791
155035
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
154792
155036
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
154793
155037
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
154794
|
-
var
|
|
155038
|
+
var errorCodes40 = [
|
|
154795
155039
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
154796
155040
|
];
|
|
154797
155041
|
registerCodeFix({
|
|
154798
155042
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
154799
|
-
errorCodes:
|
|
155043
|
+
errorCodes: errorCodes40,
|
|
154800
155044
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
154801
155045
|
const { sourceFile, span } = context;
|
|
154802
155046
|
const actions2 = [];
|
|
154803
|
-
const info =
|
|
155047
|
+
const info = getInfo14(sourceFile, span.start);
|
|
154804
155048
|
if (info) {
|
|
154805
155049
|
append(actions2, getDeleteAction(context, info));
|
|
154806
155050
|
append(actions2, getRenameAction(context, info));
|
|
@@ -154811,8 +155055,8 @@ registerCodeFix({
|
|
|
154811
155055
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
154812
155056
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
154813
155057
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
154814
|
-
eachDiagnostic(context,
|
|
154815
|
-
const info =
|
|
155058
|
+
eachDiagnostic(context, errorCodes40, ({ file, start: start2 }) => {
|
|
155059
|
+
const info = getInfo14(file, start2);
|
|
154816
155060
|
if (info) {
|
|
154817
155061
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
154818
155062
|
}
|
|
@@ -154862,7 +155106,7 @@ function getRenameAction(context, { name, jsDocHost, signature, jsDocParameterTa
|
|
|
154862
155106
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) => changeTracker.replaceJSDocComment(sourceFile, jsDocHost, map(tags, (t) => t === jsDocParameterTag ? newJSDocParameterTag : t)));
|
|
154863
155107
|
return createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
154864
155108
|
}
|
|
154865
|
-
function
|
|
155109
|
+
function getInfo14(sourceFile, pos) {
|
|
154866
155110
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
154867
155111
|
if (token.parent && isJSDocParameterTag(token.parent) && isIdentifier(token.parent.name)) {
|
|
154868
155112
|
const jsDocParameterTag = token.parent;
|
|
@@ -154877,9 +155121,9 @@ function getInfo13(sourceFile, pos) {
|
|
|
154877
155121
|
|
|
154878
155122
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
154879
155123
|
var fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
154880
|
-
var
|
|
155124
|
+
var errorCodes41 = [Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled.code];
|
|
154881
155125
|
registerCodeFix({
|
|
154882
|
-
errorCodes:
|
|
155126
|
+
errorCodes: errorCodes41,
|
|
154883
155127
|
getCodeActions: (context) => {
|
|
154884
155128
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
154885
155129
|
if (!importDeclaration)
|
|
@@ -154934,7 +155178,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
154934
155178
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
154935
155179
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
154936
155180
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
154937
|
-
var
|
|
155181
|
+
var errorCodes42 = [
|
|
154938
155182
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
154939
155183
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
154940
155184
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -154944,7 +155188,7 @@ var errorCodes41 = [
|
|
|
154944
155188
|
Diagnostics.All_type_parameters_are_unused.code
|
|
154945
155189
|
];
|
|
154946
155190
|
registerCodeFix({
|
|
154947
|
-
errorCodes:
|
|
155191
|
+
errorCodes: errorCodes42,
|
|
154948
155192
|
getCodeActions(context) {
|
|
154949
155193
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
154950
155194
|
const checker = program.getTypeChecker();
|
|
@@ -155030,7 +155274,7 @@ registerCodeFix({
|
|
|
155030
155274
|
const { sourceFile, program, cancellationToken } = context;
|
|
155031
155275
|
const checker = program.getTypeChecker();
|
|
155032
155276
|
const sourceFiles = program.getSourceFiles();
|
|
155033
|
-
return codeFixAll(context,
|
|
155277
|
+
return codeFixAll(context, errorCodes42, (changes, diag2) => {
|
|
155034
155278
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
155035
155279
|
switch (context.fixId) {
|
|
155036
155280
|
case fixIdPrefix:
|
|
@@ -155266,20 +155510,20 @@ function mayDeleteExpression(node) {
|
|
|
155266
155510
|
|
|
155267
155511
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
155268
155512
|
var fixId33 = "fixUnreachableCode";
|
|
155269
|
-
var
|
|
155513
|
+
var errorCodes43 = [Diagnostics.Unreachable_code_detected.code];
|
|
155270
155514
|
registerCodeFix({
|
|
155271
|
-
errorCodes:
|
|
155515
|
+
errorCodes: errorCodes43,
|
|
155272
155516
|
getCodeActions(context) {
|
|
155273
155517
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
155274
155518
|
if (syntacticDiagnostics.length)
|
|
155275
155519
|
return;
|
|
155276
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155520
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
155277
155521
|
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
155278
155522
|
},
|
|
155279
155523
|
fixIds: [fixId33],
|
|
155280
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155524
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange27(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
155281
155525
|
});
|
|
155282
|
-
function
|
|
155526
|
+
function doChange27(changes, sourceFile, start2, length2, errorCode) {
|
|
155283
155527
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155284
155528
|
const statement = findAncestor(token, isStatement);
|
|
155285
155529
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -155330,17 +155574,17 @@ function lastWhere(a, pred) {
|
|
|
155330
155574
|
|
|
155331
155575
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
155332
155576
|
var fixId34 = "fixUnusedLabel";
|
|
155333
|
-
var
|
|
155577
|
+
var errorCodes44 = [Diagnostics.Unused_label.code];
|
|
155334
155578
|
registerCodeFix({
|
|
155335
|
-
errorCodes:
|
|
155579
|
+
errorCodes: errorCodes44,
|
|
155336
155580
|
getCodeActions(context) {
|
|
155337
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155581
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, context.sourceFile, context.span.start));
|
|
155338
155582
|
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
155339
155583
|
},
|
|
155340
155584
|
fixIds: [fixId34],
|
|
155341
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155585
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes44, (changes, diag2) => doChange28(changes, diag2.file, diag2.start))
|
|
155342
155586
|
});
|
|
155343
|
-
function
|
|
155587
|
+
function doChange28(changes, sourceFile, start2) {
|
|
155344
155588
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155345
155589
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
155346
155590
|
const pos = token.getStart(sourceFile);
|
|
@@ -155357,17 +155601,17 @@ function doChange27(changes, sourceFile, start2) {
|
|
|
155357
155601
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
155358
155602
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
155359
155603
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
155360
|
-
var
|
|
155604
|
+
var errorCodes45 = [
|
|
155361
155605
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
155362
155606
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
155363
155607
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
155364
155608
|
];
|
|
155365
155609
|
registerCodeFix({
|
|
155366
|
-
errorCodes:
|
|
155610
|
+
errorCodes: errorCodes45,
|
|
155367
155611
|
getCodeActions(context) {
|
|
155368
155612
|
const { sourceFile } = context;
|
|
155369
155613
|
const checker = context.program.getTypeChecker();
|
|
155370
|
-
const info =
|
|
155614
|
+
const info = getInfo15(sourceFile, context.span.start, checker);
|
|
155371
155615
|
if (!info)
|
|
155372
155616
|
return void 0;
|
|
155373
155617
|
const { typeNode, type } = info;
|
|
@@ -155378,7 +155622,7 @@ registerCodeFix({
|
|
|
155378
155622
|
}
|
|
155379
155623
|
return actions2;
|
|
155380
155624
|
function fix(type2, fixId52, fixAllDescription) {
|
|
155381
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155625
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
155382
155626
|
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
155383
155627
|
}
|
|
155384
155628
|
},
|
|
@@ -155386,17 +155630,17 @@ registerCodeFix({
|
|
|
155386
155630
|
getAllCodeActions(context) {
|
|
155387
155631
|
const { fixId: fixId52, program, sourceFile } = context;
|
|
155388
155632
|
const checker = program.getTypeChecker();
|
|
155389
|
-
return codeFixAll(context,
|
|
155390
|
-
const info =
|
|
155633
|
+
return codeFixAll(context, errorCodes45, (changes, err) => {
|
|
155634
|
+
const info = getInfo15(err.file, err.start, checker);
|
|
155391
155635
|
if (!info)
|
|
155392
155636
|
return;
|
|
155393
155637
|
const { typeNode, type } = info;
|
|
155394
155638
|
const fixedType = typeNode.kind === 321 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
155395
|
-
|
|
155639
|
+
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
155396
155640
|
});
|
|
155397
155641
|
}
|
|
155398
155642
|
});
|
|
155399
|
-
function
|
|
155643
|
+
function doChange29(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
155400
155644
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
155401
155645
|
newType,
|
|
155402
155646
|
/*enclosingDeclaration*/
|
|
@@ -155405,7 +155649,7 @@ function doChange28(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
|
155405
155649
|
void 0
|
|
155406
155650
|
));
|
|
155407
155651
|
}
|
|
155408
|
-
function
|
|
155652
|
+
function getInfo15(sourceFile, pos, checker) {
|
|
155409
155653
|
const decl = findAncestor(getTokenAtPosition(sourceFile, pos), isTypeContainer);
|
|
155410
155654
|
const typeNode = decl && decl.type;
|
|
155411
155655
|
return typeNode && { typeNode, type: getType(checker, typeNode) };
|
|
@@ -155448,27 +155692,27 @@ function getType(checker, node) {
|
|
|
155448
155692
|
|
|
155449
155693
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
155450
155694
|
var fixId35 = "fixMissingCallParentheses";
|
|
155451
|
-
var
|
|
155695
|
+
var errorCodes46 = [
|
|
155452
155696
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
155453
155697
|
];
|
|
155454
155698
|
registerCodeFix({
|
|
155455
|
-
errorCodes:
|
|
155699
|
+
errorCodes: errorCodes46,
|
|
155456
155700
|
fixIds: [fixId35],
|
|
155457
155701
|
getCodeActions(context) {
|
|
155458
155702
|
const { sourceFile, span } = context;
|
|
155459
155703
|
const callName = getCallName(sourceFile, span.start);
|
|
155460
155704
|
if (!callName)
|
|
155461
155705
|
return;
|
|
155462
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155706
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, context.sourceFile, callName));
|
|
155463
155707
|
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
155464
155708
|
},
|
|
155465
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155709
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
155466
155710
|
const callName = getCallName(diag2.file, diag2.start);
|
|
155467
155711
|
if (callName)
|
|
155468
|
-
|
|
155712
|
+
doChange30(changes, diag2.file, callName);
|
|
155469
155713
|
})
|
|
155470
155714
|
});
|
|
155471
|
-
function
|
|
155715
|
+
function doChange30(changes, sourceFile, name) {
|
|
155472
155716
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
155473
155717
|
}
|
|
155474
155718
|
function getCallName(sourceFile, start2) {
|
|
@@ -155488,30 +155732,30 @@ function getCallName(sourceFile, start2) {
|
|
|
155488
155732
|
|
|
155489
155733
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
155490
155734
|
var fixId36 = "fixAwaitInSyncFunction";
|
|
155491
|
-
var
|
|
155735
|
+
var errorCodes47 = [
|
|
155492
155736
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155493
155737
|
Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155494
155738
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155495
155739
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
155496
155740
|
];
|
|
155497
155741
|
registerCodeFix({
|
|
155498
|
-
errorCodes:
|
|
155742
|
+
errorCodes: errorCodes47,
|
|
155499
155743
|
getCodeActions(context) {
|
|
155500
155744
|
const { sourceFile, span } = context;
|
|
155501
155745
|
const nodes = getNodes3(sourceFile, span.start);
|
|
155502
155746
|
if (!nodes)
|
|
155503
155747
|
return void 0;
|
|
155504
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155748
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
|
|
155505
155749
|
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
155506
155750
|
},
|
|
155507
155751
|
fixIds: [fixId36],
|
|
155508
155752
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
155509
155753
|
const seen = /* @__PURE__ */ new Map();
|
|
155510
|
-
return codeFixAll(context,
|
|
155754
|
+
return codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
155511
155755
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
155512
155756
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
155513
155757
|
return;
|
|
155514
|
-
|
|
155758
|
+
doChange31(changes, context.sourceFile, nodes);
|
|
155515
155759
|
});
|
|
155516
155760
|
}
|
|
155517
155761
|
});
|
|
@@ -155550,7 +155794,7 @@ function getNodes3(sourceFile, start2) {
|
|
|
155550
155794
|
returnType: getReturnType(containingFunction)
|
|
155551
155795
|
};
|
|
155552
155796
|
}
|
|
155553
|
-
function
|
|
155797
|
+
function doChange31(changes, sourceFile, { insertBefore, returnType }) {
|
|
155554
155798
|
if (returnType) {
|
|
155555
155799
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
155556
155800
|
if (!entityName || entityName.kind !== 80 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -155561,22 +155805,22 @@ function doChange30(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
155561
155805
|
}
|
|
155562
155806
|
|
|
155563
155807
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
155564
|
-
var
|
|
155808
|
+
var errorCodes48 = [
|
|
155565
155809
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
155566
155810
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
155567
155811
|
];
|
|
155568
155812
|
var fixId37 = "fixPropertyOverrideAccessor";
|
|
155569
155813
|
registerCodeFix({
|
|
155570
|
-
errorCodes:
|
|
155814
|
+
errorCodes: errorCodes48,
|
|
155571
155815
|
getCodeActions(context) {
|
|
155572
|
-
const edits =
|
|
155816
|
+
const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
155573
155817
|
if (edits) {
|
|
155574
155818
|
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
155575
155819
|
}
|
|
155576
155820
|
},
|
|
155577
155821
|
fixIds: [fixId37],
|
|
155578
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155579
|
-
const edits =
|
|
155822
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes48, (changes, diag2) => {
|
|
155823
|
+
const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
155580
155824
|
if (edits) {
|
|
155581
155825
|
for (const edit of edits) {
|
|
155582
155826
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -155584,7 +155828,7 @@ registerCodeFix({
|
|
|
155584
155828
|
}
|
|
155585
155829
|
})
|
|
155586
155830
|
});
|
|
155587
|
-
function
|
|
155831
|
+
function doChange32(file, start2, length2, code, context) {
|
|
155588
155832
|
let startPosition;
|
|
155589
155833
|
let endPosition;
|
|
155590
155834
|
if (code === Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code) {
|
|
@@ -155614,7 +155858,7 @@ function doChange31(file, start2, length2, code, context) {
|
|
|
155614
155858
|
|
|
155615
155859
|
// src/services/codefixes/inferFromUsage.ts
|
|
155616
155860
|
var fixId38 = "inferFromUsage";
|
|
155617
|
-
var
|
|
155861
|
+
var errorCodes49 = [
|
|
155618
155862
|
// Variable declarations
|
|
155619
155863
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
155620
155864
|
// Variable uses
|
|
@@ -155648,13 +155892,13 @@ var errorCodes48 = [
|
|
|
155648
155892
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
155649
155893
|
];
|
|
155650
155894
|
registerCodeFix({
|
|
155651
|
-
errorCodes:
|
|
155895
|
+
errorCodes: errorCodes49,
|
|
155652
155896
|
getCodeActions(context) {
|
|
155653
155897
|
const { sourceFile, program, span: { start: start2 }, errorCode, cancellationToken, host, preferences } = context;
|
|
155654
155898
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155655
155899
|
let declaration;
|
|
155656
155900
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
155657
|
-
declaration =
|
|
155901
|
+
declaration = doChange33(
|
|
155658
155902
|
changes2,
|
|
155659
155903
|
sourceFile,
|
|
155660
155904
|
token,
|
|
@@ -155674,8 +155918,8 @@ registerCodeFix({
|
|
|
155674
155918
|
getAllCodeActions(context) {
|
|
155675
155919
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
155676
155920
|
const markSeen = nodeSeenTracker();
|
|
155677
|
-
return codeFixAll(context,
|
|
155678
|
-
|
|
155921
|
+
return codeFixAll(context, errorCodes49, (changes, err) => {
|
|
155922
|
+
doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
155679
155923
|
});
|
|
155680
155924
|
}
|
|
155681
155925
|
});
|
|
@@ -155714,7 +155958,7 @@ function mapSuggestionDiagnostic(errorCode) {
|
|
|
155714
155958
|
}
|
|
155715
155959
|
return errorCode;
|
|
155716
155960
|
}
|
|
155717
|
-
function
|
|
155961
|
+
function doChange33(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
155718
155962
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 80 /* Identifier */ && token.kind !== 26 /* DotDotDotToken */ && token.kind !== 110 /* ThisKeyword */) {
|
|
155719
155963
|
return void 0;
|
|
155720
155964
|
}
|
|
@@ -156614,21 +156858,21 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
156614
156858
|
|
|
156615
156859
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
156616
156860
|
var fixId39 = "fixReturnTypeInAsyncFunction";
|
|
156617
|
-
var
|
|
156861
|
+
var errorCodes50 = [
|
|
156618
156862
|
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code
|
|
156619
156863
|
];
|
|
156620
156864
|
registerCodeFix({
|
|
156621
|
-
errorCodes:
|
|
156865
|
+
errorCodes: errorCodes50,
|
|
156622
156866
|
fixIds: [fixId39],
|
|
156623
156867
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
156624
156868
|
const { sourceFile, program, span } = context;
|
|
156625
156869
|
const checker = program.getTypeChecker();
|
|
156626
|
-
const info =
|
|
156870
|
+
const info = getInfo16(sourceFile, program.getTypeChecker(), span.start);
|
|
156627
156871
|
if (!info) {
|
|
156628
156872
|
return void 0;
|
|
156629
156873
|
}
|
|
156630
156874
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
156631
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
156875
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
156632
156876
|
return [createCodeFixAction(
|
|
156633
156877
|
fixId39,
|
|
156634
156878
|
changes,
|
|
@@ -156637,14 +156881,14 @@ registerCodeFix({
|
|
|
156637
156881
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
156638
156882
|
)];
|
|
156639
156883
|
},
|
|
156640
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
156641
|
-
const info =
|
|
156884
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
156885
|
+
const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
156642
156886
|
if (info) {
|
|
156643
|
-
|
|
156887
|
+
doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
156644
156888
|
}
|
|
156645
156889
|
})
|
|
156646
156890
|
});
|
|
156647
|
-
function
|
|
156891
|
+
function getInfo16(sourceFile, checker, pos) {
|
|
156648
156892
|
if (isInJSFile(sourceFile)) {
|
|
156649
156893
|
return void 0;
|
|
156650
156894
|
}
|
|
@@ -156667,19 +156911,19 @@ function getInfo15(sourceFile, checker, pos) {
|
|
|
156667
156911
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
156668
156912
|
}
|
|
156669
156913
|
}
|
|
156670
|
-
function
|
|
156914
|
+
function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
156671
156915
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
156672
156916
|
}
|
|
156673
156917
|
|
|
156674
156918
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
156675
156919
|
var fixName4 = "disableJsDiagnostics";
|
|
156676
156920
|
var fixId40 = "disableJsDiagnostics";
|
|
156677
|
-
var
|
|
156921
|
+
var errorCodes51 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
156678
156922
|
const diag2 = Diagnostics[key];
|
|
156679
156923
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
156680
156924
|
});
|
|
156681
156925
|
registerCodeFix({
|
|
156682
|
-
errorCodes:
|
|
156926
|
+
errorCodes: errorCodes51,
|
|
156683
156927
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
156684
156928
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
156685
156929
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -156707,7 +156951,7 @@ registerCodeFix({
|
|
|
156707
156951
|
fixIds: [fixId40],
|
|
156708
156952
|
getAllCodeActions: (context) => {
|
|
156709
156953
|
const seenLines = /* @__PURE__ */ new Set();
|
|
156710
|
-
return codeFixAll(context,
|
|
156954
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
156711
156955
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
156712
156956
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
156713
156957
|
}
|
|
@@ -157706,11 +157950,11 @@ var fixName6 = "strictClassInitialization";
|
|
|
157706
157950
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
157707
157951
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
157708
157952
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
157709
|
-
var
|
|
157953
|
+
var errorCodes52 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
157710
157954
|
registerCodeFix({
|
|
157711
|
-
errorCodes:
|
|
157955
|
+
errorCodes: errorCodes52,
|
|
157712
157956
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
157713
|
-
const info =
|
|
157957
|
+
const info = getInfo17(context.sourceFile, context.span.start);
|
|
157714
157958
|
if (!info)
|
|
157715
157959
|
return;
|
|
157716
157960
|
const result = [];
|
|
@@ -157721,8 +157965,8 @@ registerCodeFix({
|
|
|
157721
157965
|
},
|
|
157722
157966
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
157723
157967
|
getAllCodeActions: (context) => {
|
|
157724
|
-
return codeFixAll(context,
|
|
157725
|
-
const info =
|
|
157968
|
+
return codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
157969
|
+
const info = getInfo17(diag2.file, diag2.start);
|
|
157726
157970
|
if (!info)
|
|
157727
157971
|
return;
|
|
157728
157972
|
switch (context.fixId) {
|
|
@@ -157745,7 +157989,7 @@ registerCodeFix({
|
|
|
157745
157989
|
});
|
|
157746
157990
|
}
|
|
157747
157991
|
});
|
|
157748
|
-
function
|
|
157992
|
+
function getInfo17(sourceFile, pos) {
|
|
157749
157993
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
157750
157994
|
if (isIdentifier(token) && isPropertyDeclaration(token.parent)) {
|
|
157751
157995
|
const type = getEffectiveTypeAnnotationNode(token.parent);
|
|
@@ -157852,26 +158096,26 @@ function getDefaultValueFromType(checker, type) {
|
|
|
157852
158096
|
|
|
157853
158097
|
// src/services/codefixes/requireInTs.ts
|
|
157854
158098
|
var fixId41 = "requireInTs";
|
|
157855
|
-
var
|
|
158099
|
+
var errorCodes53 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
157856
158100
|
registerCodeFix({
|
|
157857
|
-
errorCodes:
|
|
158101
|
+
errorCodes: errorCodes53,
|
|
157858
158102
|
getCodeActions(context) {
|
|
157859
|
-
const info =
|
|
158103
|
+
const info = getInfo18(context.sourceFile, context.program, context.span.start);
|
|
157860
158104
|
if (!info) {
|
|
157861
158105
|
return void 0;
|
|
157862
158106
|
}
|
|
157863
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158107
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
|
|
157864
158108
|
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
157865
158109
|
},
|
|
157866
158110
|
fixIds: [fixId41],
|
|
157867
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157868
|
-
const info =
|
|
158111
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
158112
|
+
const info = getInfo18(diag2.file, context.program, diag2.start);
|
|
157869
158113
|
if (info) {
|
|
157870
|
-
|
|
158114
|
+
doChange35(changes, context.sourceFile, info);
|
|
157871
158115
|
}
|
|
157872
158116
|
})
|
|
157873
158117
|
});
|
|
157874
|
-
function
|
|
158118
|
+
function doChange35(changes, sourceFile, info) {
|
|
157875
158119
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
157876
158120
|
changes.replaceNode(
|
|
157877
158121
|
sourceFile,
|
|
@@ -157898,7 +158142,7 @@ function doChange34(changes, sourceFile, info) {
|
|
|
157898
158142
|
)
|
|
157899
158143
|
);
|
|
157900
158144
|
}
|
|
157901
|
-
function
|
|
158145
|
+
function getInfo18(sourceFile, program, pos) {
|
|
157902
158146
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
157903
158147
|
if (!isRequireCall(
|
|
157904
158148
|
parent2,
|
|
@@ -157940,25 +158184,25 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
157940
158184
|
|
|
157941
158185
|
// src/services/codefixes/useDefaultImport.ts
|
|
157942
158186
|
var fixId42 = "useDefaultImport";
|
|
157943
|
-
var
|
|
158187
|
+
var errorCodes54 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
157944
158188
|
registerCodeFix({
|
|
157945
|
-
errorCodes:
|
|
158189
|
+
errorCodes: errorCodes54,
|
|
157946
158190
|
getCodeActions(context) {
|
|
157947
158191
|
const { sourceFile, span: { start: start2 } } = context;
|
|
157948
|
-
const info =
|
|
158192
|
+
const info = getInfo19(sourceFile, start2);
|
|
157949
158193
|
if (!info)
|
|
157950
158194
|
return void 0;
|
|
157951
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158195
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(t, sourceFile, info, context.preferences));
|
|
157952
158196
|
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
157953
158197
|
},
|
|
157954
158198
|
fixIds: [fixId42],
|
|
157955
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157956
|
-
const info =
|
|
158199
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
|
|
158200
|
+
const info = getInfo19(diag2.file, diag2.start);
|
|
157957
158201
|
if (info)
|
|
157958
|
-
|
|
158202
|
+
doChange36(changes, diag2.file, info, context.preferences);
|
|
157959
158203
|
})
|
|
157960
158204
|
});
|
|
157961
|
-
function
|
|
158205
|
+
function getInfo19(sourceFile, pos) {
|
|
157962
158206
|
const name = getTokenAtPosition(sourceFile, pos);
|
|
157963
158207
|
if (!isIdentifier(name))
|
|
157964
158208
|
return void 0;
|
|
@@ -157970,7 +158214,7 @@ function getInfo18(sourceFile, pos) {
|
|
|
157970
158214
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
157971
158215
|
}
|
|
157972
158216
|
}
|
|
157973
|
-
function
|
|
158217
|
+
function doChange36(changes, sourceFile, info, preferences) {
|
|
157974
158218
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
157975
158219
|
info.name,
|
|
157976
158220
|
/*namedImports*/
|
|
@@ -157982,11 +158226,11 @@ function doChange35(changes, sourceFile, info, preferences) {
|
|
|
157982
158226
|
|
|
157983
158227
|
// src/services/codefixes/useBigintLiteral.ts
|
|
157984
158228
|
var fixId43 = "useBigintLiteral";
|
|
157985
|
-
var
|
|
158229
|
+
var errorCodes55 = [
|
|
157986
158230
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
157987
158231
|
];
|
|
157988
158232
|
registerCodeFix({
|
|
157989
|
-
errorCodes:
|
|
158233
|
+
errorCodes: errorCodes55,
|
|
157990
158234
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
157991
158235
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
157992
158236
|
if (changes.length > 0) {
|
|
@@ -157995,7 +158239,7 @@ registerCodeFix({
|
|
|
157995
158239
|
},
|
|
157996
158240
|
fixIds: [fixId43],
|
|
157997
158241
|
getAllCodeActions: (context) => {
|
|
157998
|
-
return codeFixAll(context,
|
|
158242
|
+
return codeFixAll(context, errorCodes55, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
157999
158243
|
}
|
|
158000
158244
|
});
|
|
158001
158245
|
function makeChange9(changeTracker, sourceFile, span) {
|
|
@@ -158010,17 +158254,17 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
158010
158254
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
158011
158255
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
158012
158256
|
var fixId44 = fixIdAddMissingTypeof;
|
|
158013
|
-
var
|
|
158257
|
+
var errorCodes56 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
|
158014
158258
|
registerCodeFix({
|
|
158015
|
-
errorCodes:
|
|
158259
|
+
errorCodes: errorCodes56,
|
|
158016
158260
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
158017
158261
|
const { sourceFile, span } = context;
|
|
158018
158262
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
158019
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158263
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
|
|
158020
158264
|
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
158021
158265
|
},
|
|
158022
158266
|
fixIds: [fixId44],
|
|
158023
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158267
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
158024
158268
|
});
|
|
158025
158269
|
function getImportTypeNode(sourceFile, pos) {
|
|
158026
158270
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -158028,7 +158272,7 @@ function getImportTypeNode(sourceFile, pos) {
|
|
|
158028
158272
|
Debug.assert(token.parent.kind === 205 /* ImportType */, "Token parent should be an ImportType");
|
|
158029
158273
|
return token.parent;
|
|
158030
158274
|
}
|
|
158031
|
-
function
|
|
158275
|
+
function doChange37(changes, sourceFile, importType) {
|
|
158032
158276
|
const newTypeNode = factory.updateImportTypeNode(
|
|
158033
158277
|
importType,
|
|
158034
158278
|
importType.argument,
|
|
@@ -158043,23 +158287,23 @@ function doChange36(changes, sourceFile, importType) {
|
|
|
158043
158287
|
|
|
158044
158288
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
158045
158289
|
var fixID2 = "wrapJsxInFragment";
|
|
158046
|
-
var
|
|
158290
|
+
var errorCodes57 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
158047
158291
|
registerCodeFix({
|
|
158048
|
-
errorCodes:
|
|
158292
|
+
errorCodes: errorCodes57,
|
|
158049
158293
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
158050
158294
|
const { sourceFile, span } = context;
|
|
158051
158295
|
const node = findNodeToFix(sourceFile, span.start);
|
|
158052
158296
|
if (!node)
|
|
158053
158297
|
return void 0;
|
|
158054
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158298
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange38(t, sourceFile, node));
|
|
158055
158299
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
158056
158300
|
},
|
|
158057
158301
|
fixIds: [fixID2],
|
|
158058
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158302
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
158059
158303
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
158060
158304
|
if (!node)
|
|
158061
158305
|
return void 0;
|
|
158062
|
-
|
|
158306
|
+
doChange38(changes, context.sourceFile, node);
|
|
158063
158307
|
})
|
|
158064
158308
|
});
|
|
158065
158309
|
function findNodeToFix(sourceFile, pos) {
|
|
@@ -158075,7 +158319,7 @@ function findNodeToFix(sourceFile, pos) {
|
|
|
158075
158319
|
return void 0;
|
|
158076
158320
|
return binaryExpr;
|
|
158077
158321
|
}
|
|
158078
|
-
function
|
|
158322
|
+
function doChange38(changeTracker, sf, node) {
|
|
158079
158323
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
158080
158324
|
if (jsx)
|
|
158081
158325
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -158101,26 +158345,26 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
158101
158345
|
|
|
158102
158346
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
158103
158347
|
var fixId45 = "fixConvertToMappedObjectType";
|
|
158104
|
-
var
|
|
158348
|
+
var errorCodes58 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
158105
158349
|
registerCodeFix({
|
|
158106
|
-
errorCodes:
|
|
158350
|
+
errorCodes: errorCodes58,
|
|
158107
158351
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
158108
158352
|
const { sourceFile, span } = context;
|
|
158109
|
-
const info =
|
|
158353
|
+
const info = getInfo20(sourceFile, span.start);
|
|
158110
158354
|
if (!info)
|
|
158111
158355
|
return void 0;
|
|
158112
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158356
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
158113
158357
|
const name = idText(info.container.name);
|
|
158114
158358
|
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
158115
158359
|
},
|
|
158116
158360
|
fixIds: [fixId45],
|
|
158117
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158118
|
-
const info =
|
|
158361
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => {
|
|
158362
|
+
const info = getInfo20(diag2.file, diag2.start);
|
|
158119
158363
|
if (info)
|
|
158120
|
-
|
|
158364
|
+
doChange39(changes, diag2.file, info);
|
|
158121
158365
|
})
|
|
158122
158366
|
});
|
|
158123
|
-
function
|
|
158367
|
+
function getInfo20(sourceFile, pos) {
|
|
158124
158368
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
158125
158369
|
const indexSignature = tryCast(token.parent.parent, isIndexSignatureDeclaration);
|
|
158126
158370
|
if (!indexSignature)
|
|
@@ -158133,7 +158377,7 @@ function getInfo19(sourceFile, pos) {
|
|
|
158133
158377
|
function createTypeAliasFromInterface(declaration, type) {
|
|
158134
158378
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
158135
158379
|
}
|
|
158136
|
-
function
|
|
158380
|
+
function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
158137
158381
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
158138
158382
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
158139
158383
|
const parameter = first(indexSignature.parameters);
|
|
@@ -158163,11 +158407,11 @@ function doChange38(changes, sourceFile, { indexSignature, container }) {
|
|
|
158163
158407
|
|
|
158164
158408
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
158165
158409
|
var fixId46 = "removeAccidentalCallParentheses";
|
|
158166
|
-
var
|
|
158410
|
+
var errorCodes59 = [
|
|
158167
158411
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
158168
158412
|
];
|
|
158169
158413
|
registerCodeFix({
|
|
158170
|
-
errorCodes:
|
|
158414
|
+
errorCodes: errorCodes59,
|
|
158171
158415
|
getCodeActions(context) {
|
|
158172
158416
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
158173
158417
|
if (!callExpression) {
|
|
@@ -158183,11 +158427,11 @@ registerCodeFix({
|
|
|
158183
158427
|
|
|
158184
158428
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
158185
158429
|
var fixId47 = "removeUnnecessaryAwait";
|
|
158186
|
-
var
|
|
158430
|
+
var errorCodes60 = [
|
|
158187
158431
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
158188
158432
|
];
|
|
158189
158433
|
registerCodeFix({
|
|
158190
|
-
errorCodes:
|
|
158434
|
+
errorCodes: errorCodes60,
|
|
158191
158435
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
158192
158436
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
158193
158437
|
if (changes.length > 0) {
|
|
@@ -158196,7 +158440,7 @@ registerCodeFix({
|
|
|
158196
158440
|
},
|
|
158197
158441
|
fixIds: [fixId47],
|
|
158198
158442
|
getAllCodeActions: (context) => {
|
|
158199
|
-
return codeFixAll(context,
|
|
158443
|
+
return codeFixAll(context, errorCodes60, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
158200
158444
|
}
|
|
158201
158445
|
});
|
|
158202
158446
|
function makeChange10(changeTracker, sourceFile, span) {
|
|
@@ -158224,10 +158468,10 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
158224
158468
|
}
|
|
158225
158469
|
|
|
158226
158470
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
158227
|
-
var
|
|
158471
|
+
var errorCodes61 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
158228
158472
|
var fixId48 = "splitTypeOnlyImport";
|
|
158229
158473
|
registerCodeFix({
|
|
158230
|
-
errorCodes:
|
|
158474
|
+
errorCodes: errorCodes61,
|
|
158231
158475
|
fixIds: [fixId48],
|
|
158232
158476
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
158233
158477
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
@@ -158237,7 +158481,7 @@ registerCodeFix({
|
|
|
158237
158481
|
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
158238
158482
|
}
|
|
158239
158483
|
},
|
|
158240
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158484
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes61, (changes, error2) => {
|
|
158241
158485
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
158242
158486
|
})
|
|
158243
158487
|
});
|
|
@@ -158287,26 +158531,26 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
158287
158531
|
|
|
158288
158532
|
// src/services/codefixes/convertConstToLet.ts
|
|
158289
158533
|
var fixId49 = "fixConvertConstToLet";
|
|
158290
|
-
var
|
|
158534
|
+
var errorCodes62 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
158291
158535
|
registerCodeFix({
|
|
158292
|
-
errorCodes:
|
|
158536
|
+
errorCodes: errorCodes62,
|
|
158293
158537
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
158294
158538
|
const { sourceFile, span, program } = context;
|
|
158295
|
-
const info =
|
|
158539
|
+
const info = getInfo21(sourceFile, span.start, program);
|
|
158296
158540
|
if (info === void 0)
|
|
158297
158541
|
return;
|
|
158298
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158542
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
158299
158543
|
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
158300
158544
|
},
|
|
158301
158545
|
getAllCodeActions: (context) => {
|
|
158302
158546
|
const { program } = context;
|
|
158303
158547
|
const seen = /* @__PURE__ */ new Map();
|
|
158304
158548
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
158305
|
-
eachDiagnostic(context,
|
|
158306
|
-
const info =
|
|
158549
|
+
eachDiagnostic(context, errorCodes62, (diag2) => {
|
|
158550
|
+
const info = getInfo21(diag2.file, diag2.start, program);
|
|
158307
158551
|
if (info) {
|
|
158308
158552
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
158309
|
-
return
|
|
158553
|
+
return doChange40(changes, diag2.file, info.token);
|
|
158310
158554
|
}
|
|
158311
158555
|
}
|
|
158312
158556
|
return void 0;
|
|
@@ -158315,7 +158559,7 @@ registerCodeFix({
|
|
|
158315
158559
|
},
|
|
158316
158560
|
fixIds: [fixId49]
|
|
158317
158561
|
});
|
|
158318
|
-
function
|
|
158562
|
+
function getInfo21(sourceFile, pos, program) {
|
|
158319
158563
|
var _a;
|
|
158320
158564
|
const checker = program.getTypeChecker();
|
|
158321
158565
|
const symbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, pos));
|
|
@@ -158329,22 +158573,22 @@ function getInfo20(sourceFile, pos, program) {
|
|
|
158329
158573
|
return;
|
|
158330
158574
|
return { symbol, token: constToken };
|
|
158331
158575
|
}
|
|
158332
|
-
function
|
|
158576
|
+
function doChange40(changes, sourceFile, token) {
|
|
158333
158577
|
changes.replaceNode(sourceFile, token, factory.createToken(121 /* LetKeyword */));
|
|
158334
158578
|
}
|
|
158335
158579
|
|
|
158336
158580
|
// src/services/codefixes/fixExpectedComma.ts
|
|
158337
158581
|
var fixId50 = "fixExpectedComma";
|
|
158338
158582
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
158339
|
-
var
|
|
158583
|
+
var errorCodes63 = [expectedErrorCode];
|
|
158340
158584
|
registerCodeFix({
|
|
158341
|
-
errorCodes:
|
|
158585
|
+
errorCodes: errorCodes63,
|
|
158342
158586
|
getCodeActions(context) {
|
|
158343
158587
|
const { sourceFile } = context;
|
|
158344
|
-
const info =
|
|
158588
|
+
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
158345
158589
|
if (!info)
|
|
158346
158590
|
return void 0;
|
|
158347
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158591
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
158348
158592
|
return [createCodeFixAction(
|
|
158349
158593
|
fixId50,
|
|
158350
158594
|
changes,
|
|
@@ -158354,17 +158598,17 @@ registerCodeFix({
|
|
|
158354
158598
|
)];
|
|
158355
158599
|
},
|
|
158356
158600
|
fixIds: [fixId50],
|
|
158357
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158358
|
-
const info =
|
|
158601
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes63, (changes, diag2) => {
|
|
158602
|
+
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
158359
158603
|
if (info)
|
|
158360
|
-
|
|
158604
|
+
doChange41(changes, context.sourceFile, info);
|
|
158361
158605
|
})
|
|
158362
158606
|
});
|
|
158363
|
-
function
|
|
158607
|
+
function getInfo22(sourceFile, pos, _) {
|
|
158364
158608
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
158365
158609
|
return node.kind === 27 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
158366
158610
|
}
|
|
158367
|
-
function
|
|
158611
|
+
function doChange41(changes, sourceFile, { node }) {
|
|
158368
158612
|
const newNode = factory.createToken(28 /* CommaToken */);
|
|
158369
158613
|
changes.replaceNode(sourceFile, node, newNode);
|
|
158370
158614
|
}
|
|
@@ -158372,12 +158616,12 @@ function doChange40(changes, sourceFile, { node }) {
|
|
|
158372
158616
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
158373
158617
|
var fixName7 = "addVoidToPromise";
|
|
158374
158618
|
var fixId51 = "addVoidToPromise";
|
|
158375
|
-
var
|
|
158619
|
+
var errorCodes64 = [
|
|
158376
158620
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
158377
158621
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
158378
158622
|
];
|
|
158379
158623
|
registerCodeFix({
|
|
158380
|
-
errorCodes:
|
|
158624
|
+
errorCodes: errorCodes64,
|
|
158381
158625
|
fixIds: [fixId51],
|
|
158382
158626
|
getCodeActions(context) {
|
|
158383
158627
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
@@ -158386,7 +158630,7 @@ registerCodeFix({
|
|
|
158386
158630
|
}
|
|
158387
158631
|
},
|
|
158388
158632
|
getAllCodeActions(context) {
|
|
158389
|
-
return codeFixAll(context,
|
|
158633
|
+
return codeFixAll(context, errorCodes64, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
158390
158634
|
}
|
|
158391
158635
|
});
|
|
158392
158636
|
function makeChange11(changes, sourceFile, span, program, seen) {
|
|
@@ -160188,7 +160432,7 @@ function getCompletionEntryDetails(program, log, sourceFile, position, entryId,
|
|
|
160188
160432
|
const { name, source, data } = entryId;
|
|
160189
160433
|
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
|
160190
160434
|
if (isInString(sourceFile, position, previousToken)) {
|
|
160191
|
-
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken,
|
|
160435
|
+
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, program, host, cancellationToken, preferences);
|
|
160192
160436
|
}
|
|
160193
160437
|
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
|
|
160194
160438
|
switch (symbolCompletion.type) {
|
|
@@ -160419,7 +160663,7 @@ function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) {
|
|
|
160419
160663
|
symbol,
|
|
160420
160664
|
enclosingDeclaration,
|
|
160421
160665
|
/*meaning*/
|
|
160422
|
-
|
|
160666
|
+
-1 /* All */,
|
|
160423
160667
|
/*useOnlyExternalAliasing*/
|
|
160424
160668
|
false
|
|
160425
160669
|
);
|
|
@@ -162378,7 +162622,7 @@ function getStringLiteralCompletions(sourceFile, position, contextToken, options
|
|
|
162378
162622
|
if (isInString(sourceFile, position, contextToken)) {
|
|
162379
162623
|
if (!contextToken || !isStringLiteralLike(contextToken))
|
|
162380
162624
|
return void 0;
|
|
162381
|
-
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program
|
|
162625
|
+
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences);
|
|
162382
162626
|
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences, position, includeSymbol);
|
|
162383
162627
|
}
|
|
162384
162628
|
}
|
|
@@ -162448,11 +162692,11 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|
|
162448
162692
|
return Debug.assertNever(completion);
|
|
162449
162693
|
}
|
|
162450
162694
|
}
|
|
162451
|
-
function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken,
|
|
162695
|
+
function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, program, host, cancellationToken, preferences) {
|
|
162452
162696
|
if (!contextToken || !isStringLiteralLike(contextToken))
|
|
162453
162697
|
return void 0;
|
|
162454
|
-
const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
162455
|
-
return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile,
|
|
162698
|
+
const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences);
|
|
162699
|
+
return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, program.getTypeChecker(), cancellationToken);
|
|
162456
162700
|
}
|
|
162457
162701
|
function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) {
|
|
162458
162702
|
switch (completion.kind) {
|
|
@@ -162510,13 +162754,14 @@ function kindModifiersFromExtension(extension) {
|
|
|
162510
162754
|
return Debug.assertNever(extension);
|
|
162511
162755
|
}
|
|
162512
162756
|
}
|
|
162513
|
-
function getStringLiteralCompletionEntries(sourceFile, node, position,
|
|
162757
|
+
function getStringLiteralCompletionEntries(sourceFile, node, position, program, host, preferences) {
|
|
162758
|
+
const typeChecker = program.getTypeChecker();
|
|
162514
162759
|
const parent2 = walkUpParentheses(node.parent);
|
|
162515
162760
|
switch (parent2.kind) {
|
|
162516
162761
|
case 201 /* LiteralType */: {
|
|
162517
162762
|
const grandParent = walkUpParentheses(parent2.parent);
|
|
162518
162763
|
if (grandParent.kind === 205 /* ImportType */) {
|
|
162519
|
-
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162764
|
+
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
|
162520
162765
|
}
|
|
162521
162766
|
return fromUnionableLiteralType(grandParent);
|
|
162522
162767
|
}
|
|
@@ -162542,7 +162787,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
|
|
|
162542
162787
|
case 272 /* ImportDeclaration */:
|
|
162543
162788
|
case 278 /* ExportDeclaration */:
|
|
162544
162789
|
case 283 /* ExternalModuleReference */:
|
|
162545
|
-
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162790
|
+
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
|
162546
162791
|
case 296 /* CaseClause */:
|
|
162547
162792
|
const tracker = newCaseClauseTracker(typeChecker, parent2.parent.clauses);
|
|
162548
162793
|
const contextualTypes = fromContextualType();
|
|
@@ -162672,14 +162917,16 @@ function addReplacementSpans(text, textStart, names) {
|
|
|
162672
162917
|
const wholeSpan = text.length === 0 ? void 0 : createTextSpan(textStart, text.length);
|
|
162673
162918
|
return names.map(({ name, kind, extension }) => name.includes(directorySeparator) || name.includes(altDirectorySeparator) ? { name, kind, extension, span: wholeSpan } : { name, kind, extension, span });
|
|
162674
162919
|
}
|
|
162675
|
-
function getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162676
|
-
return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node,
|
|
162920
|
+
function getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) {
|
|
162921
|
+
return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, program, host, preferences));
|
|
162677
162922
|
}
|
|
162678
|
-
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node,
|
|
162923
|
+
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, program, host, preferences) {
|
|
162679
162924
|
const literalValue = normalizeSlashes(node.text);
|
|
162680
|
-
const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : void 0;
|
|
162925
|
+
const mode = isStringLiteralLike(node) ? program.getModeForUsageLocation(sourceFile, node) : void 0;
|
|
162681
162926
|
const scriptPath = sourceFile.path;
|
|
162682
162927
|
const scriptDirectory = getDirectoryPath(scriptPath);
|
|
162928
|
+
const compilerOptions = program.getCompilerOptions();
|
|
162929
|
+
const typeChecker = program.getTypeChecker();
|
|
162683
162930
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
|
162684
162931
|
return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, extensionOptions, typeChecker);
|
|
162685
162932
|
}
|
|
@@ -164286,7 +164533,7 @@ var Core;
|
|
|
164286
164533
|
if (!options.implementations && isStringLiteralLike(node)) {
|
|
164287
164534
|
if (isModuleSpecifierLike(node)) {
|
|
164288
164535
|
const fileIncludeReasons = program.getFileIncludeReasons();
|
|
164289
|
-
const referencedFileName = (_b = (_a = program.
|
|
164536
|
+
const referencedFileName = (_b = (_a = program.getResolvedModuleFromModuleSpecifier(node)) == null ? void 0 : _a.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
164290
164537
|
const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : void 0;
|
|
164291
164538
|
if (referencedFile) {
|
|
164292
164539
|
return [{ definition: { type: 4 /* String */, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
|
|
@@ -165791,7 +166038,7 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
|
|
|
165791
166038
|
}
|
|
165792
166039
|
}
|
|
165793
166040
|
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
|
165794
|
-
const ref = (_a = program.
|
|
166041
|
+
const ref = (_a = program.getResolvedModuleFromModuleSpecifier(fallbackNode)) == null ? void 0 : _a.resolvedModule;
|
|
165795
166042
|
if (ref) {
|
|
165796
166043
|
return [{
|
|
165797
166044
|
name: fallbackNode.text,
|
|
@@ -165906,7 +166153,7 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
165906
166153
|
if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) {
|
|
165907
166154
|
const node = getTouchingToken(sourceFile, position);
|
|
165908
166155
|
let resolution;
|
|
165909
|
-
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.
|
|
166156
|
+
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node))) {
|
|
165910
166157
|
const verifiedFileName = (_b = resolution.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
165911
166158
|
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
|
165912
166159
|
return {
|
|
@@ -175092,6 +175339,7 @@ __export(ts_exports2, {
|
|
|
175092
175339
|
getStaticPropertiesAndClassStaticBlock: () => getStaticPropertiesAndClassStaticBlock,
|
|
175093
175340
|
getStrictOptionValue: () => getStrictOptionValue,
|
|
175094
175341
|
getStringComparer: () => getStringComparer,
|
|
175342
|
+
getSubPatternFromSpec: () => getSubPatternFromSpec,
|
|
175095
175343
|
getSuperCallFromStatement: () => getSuperCallFromStatement,
|
|
175096
175344
|
getSuperContainer: () => getSuperContainer,
|
|
175097
175345
|
getSupportedCodeFixes: () => getSupportedCodeFixes,
|
|
@@ -176178,7 +176426,6 @@ __export(ts_exports2, {
|
|
|
176178
176426
|
setValueDeclaration: () => setValueDeclaration,
|
|
176179
176427
|
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
|
|
176180
176428
|
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
|
|
176181
|
-
shouldResolveJsRequire: () => shouldResolveJsRequire,
|
|
176182
176429
|
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
|
|
176183
176430
|
showModuleSpecifier: () => showModuleSpecifier,
|
|
176184
176431
|
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
|
|
@@ -176341,7 +176588,6 @@ __export(ts_exports2, {
|
|
|
176341
176588
|
typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
|
|
176342
176589
|
typeKeywords: () => typeKeywords,
|
|
176343
176590
|
typeParameterNamePart: () => typeParameterNamePart,
|
|
176344
|
-
typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
|
|
176345
176591
|
typeToDisplayParts: () => typeToDisplayParts,
|
|
176346
176592
|
unchangedPollThresholds: () => unchangedPollThresholds,
|
|
176347
176593
|
unchangedTextChangeRange: () => unchangedTextChangeRange,
|
|
@@ -177414,11 +177660,18 @@ var ModuleKind2 = /* @__PURE__ */ ((ModuleKind3) => {
|
|
|
177414
177660
|
ModuleKind3["ES6"] = "ES6";
|
|
177415
177661
|
ModuleKind3["ES2015"] = "ES2015";
|
|
177416
177662
|
ModuleKind3["ESNext"] = "ESNext";
|
|
177663
|
+
ModuleKind3["Node16"] = "Node16";
|
|
177664
|
+
ModuleKind3["NodeNext"] = "NodeNext";
|
|
177665
|
+
ModuleKind3["Preserve"] = "Preserve";
|
|
177417
177666
|
return ModuleKind3;
|
|
177418
177667
|
})(ModuleKind2 || {});
|
|
177419
177668
|
var ModuleResolutionKind2 = /* @__PURE__ */ ((ModuleResolutionKind3) => {
|
|
177420
177669
|
ModuleResolutionKind3["Classic"] = "Classic";
|
|
177421
177670
|
ModuleResolutionKind3["Node"] = "Node";
|
|
177671
|
+
ModuleResolutionKind3["Node10"] = "Node10";
|
|
177672
|
+
ModuleResolutionKind3["Node16"] = "Node16";
|
|
177673
|
+
ModuleResolutionKind3["NodeNext"] = "NodeNext";
|
|
177674
|
+
ModuleResolutionKind3["Bundler"] = "Bundler";
|
|
177422
177675
|
return ModuleResolutionKind3;
|
|
177423
177676
|
})(ModuleResolutionKind2 || {});
|
|
177424
177677
|
var NewLineKind2 = /* @__PURE__ */ ((NewLineKind3) => {
|
|
@@ -189893,6 +190146,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189893
190146
|
getStaticPropertiesAndClassStaticBlock,
|
|
189894
190147
|
getStrictOptionValue,
|
|
189895
190148
|
getStringComparer,
|
|
190149
|
+
getSubPatternFromSpec,
|
|
189896
190150
|
getSuperCallFromStatement,
|
|
189897
190151
|
getSuperContainer,
|
|
189898
190152
|
getSupportedCodeFixes,
|
|
@@ -190979,7 +191233,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
190979
191233
|
setValueDeclaration,
|
|
190980
191234
|
shouldAllowImportingTsExtension,
|
|
190981
191235
|
shouldPreserveConstEnums,
|
|
190982
|
-
shouldResolveJsRequire,
|
|
190983
191236
|
shouldUseUriStyleNodeCoreModules,
|
|
190984
191237
|
showModuleSpecifier,
|
|
190985
191238
|
signatureHasLiteralTypes,
|
|
@@ -191142,7 +191395,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
191142
191395
|
typeDirectiveIsEqualTo,
|
|
191143
191396
|
typeKeywords,
|
|
191144
191397
|
typeParameterNamePart,
|
|
191145
|
-
typeReferenceResolutionNameAndModeGetter,
|
|
191146
191398
|
typeToDisplayParts,
|
|
191147
191399
|
unchangedPollThresholds,
|
|
191148
191400
|
unchangedTextChangeRange,
|