typescript 5.4.0-dev.20240119 → 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 +683 -434
- package/lib/typescript.d.ts +51 -11
- package/lib/typescript.js +726 -467
- 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
|
);
|
|
@@ -140862,10 +140880,11 @@ function getTargetFileImportsAndAddExportInOldFile(oldFile, targetFile, importsT
|
|
|
140862
140880
|
forEachImportInStatement(oldStatement, (i) => {
|
|
140863
140881
|
var _a;
|
|
140864
140882
|
const moduleSpecifier = moduleSpecifierFromImport(i);
|
|
140865
|
-
const
|
|
140883
|
+
const compilerOptions = program.getCompilerOptions();
|
|
140884
|
+
const resolved = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier);
|
|
140866
140885
|
const fileName = (_a = resolved == null ? void 0 : resolved.resolvedModule) == null ? void 0 : _a.resolvedFileName;
|
|
140867
140886
|
if (fileName && targetSourceFile) {
|
|
140868
|
-
const newModuleSpecifier = getModuleSpecifier(
|
|
140887
|
+
const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host));
|
|
140869
140888
|
append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
|
|
140870
140889
|
} else {
|
|
140871
140890
|
append(copiedOldImports, filterImport(i, factory.createStringLiteral(moduleSpecifierFromImport(i).text), (name) => importsToCopy.has(checker.getSymbolAtLocation(name))));
|
|
@@ -140976,7 +140995,7 @@ function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, n
|
|
|
140976
140995
|
needUniqueName = needUniqueName || !!checker.resolveName(
|
|
140977
140996
|
preferredNewNamespaceName,
|
|
140978
140997
|
ref,
|
|
140979
|
-
|
|
140998
|
+
-1 /* All */,
|
|
140980
140999
|
/*excludeGlobals*/
|
|
140981
141000
|
true
|
|
140982
141001
|
);
|
|
@@ -146740,12 +146759,12 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
146740
146759
|
}
|
|
146741
146760
|
return [];
|
|
146742
146761
|
}
|
|
146743
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
146762
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes65, formatOptions, preferences = emptyOptions) {
|
|
146744
146763
|
synchronizeHostData();
|
|
146745
146764
|
const sourceFile = getValidSourceFile(fileName);
|
|
146746
146765
|
const span = createTextSpanFromBounds(start2, end);
|
|
146747
146766
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
146748
|
-
return flatMap(deduplicate(
|
|
146767
|
+
return flatMap(deduplicate(errorCodes65, equateValues, compareValues), (errorCode) => {
|
|
146749
146768
|
cancellationToken.throwIfCancellationRequested();
|
|
146750
146769
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
146751
146770
|
});
|
|
@@ -148453,10 +148472,10 @@ function getSupportedErrorCodes() {
|
|
|
148453
148472
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
148454
148473
|
}
|
|
148455
148474
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
148456
|
-
const { errorCodes:
|
|
148475
|
+
const { errorCodes: errorCodes65 } = registration;
|
|
148457
148476
|
let maybeFixableDiagnostics = 0;
|
|
148458
148477
|
for (const diag2 of diagnostics) {
|
|
148459
|
-
if (contains(
|
|
148478
|
+
if (contains(errorCodes65, diag2.code))
|
|
148460
148479
|
maybeFixableDiagnostics++;
|
|
148461
148480
|
if (maybeFixableDiagnostics > 1)
|
|
148462
148481
|
break;
|
|
@@ -148480,14 +148499,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
148480
148499
|
function createFileTextChanges(fileName, textChanges2) {
|
|
148481
148500
|
return { fileName, textChanges: textChanges2 };
|
|
148482
148501
|
}
|
|
148483
|
-
function codeFixAll(context,
|
|
148502
|
+
function codeFixAll(context, errorCodes65, use) {
|
|
148484
148503
|
const commands = [];
|
|
148485
|
-
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)));
|
|
148486
148505
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
148487
148506
|
}
|
|
148488
|
-
function eachDiagnostic(context,
|
|
148507
|
+
function eachDiagnostic(context, errorCodes65, cb) {
|
|
148489
148508
|
for (const diag2 of getDiagnostics(context)) {
|
|
148490
|
-
if (contains(
|
|
148509
|
+
if (contains(errorCodes65, diag2.code)) {
|
|
148491
148510
|
cb(diag2);
|
|
148492
148511
|
}
|
|
148493
148512
|
}
|
|
@@ -150311,7 +150330,7 @@ registerCodeFix({
|
|
|
150311
150330
|
function fixImportOfModuleExports(importingFile, exportingFile, program, changes, quotePreference) {
|
|
150312
150331
|
var _a;
|
|
150313
150332
|
for (const moduleSpecifier of importingFile.imports) {
|
|
150314
|
-
const imported = (_a = program.
|
|
150333
|
+
const imported = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
150315
150334
|
if (!imported || imported.resolvedFileName !== exportingFile.fileName) {
|
|
150316
150335
|
continue;
|
|
150317
150336
|
}
|
|
@@ -152228,6 +152247,7 @@ function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) {
|
|
|
152228
152247
|
case 7 /* ES2022 */:
|
|
152229
152248
|
case 99 /* ESNext */:
|
|
152230
152249
|
case 0 /* None */:
|
|
152250
|
+
case 200 /* Preserve */:
|
|
152231
152251
|
return 2 /* Namespace */;
|
|
152232
152252
|
case 100 /* Node16 */:
|
|
152233
152253
|
case 199 /* NodeNext */:
|
|
@@ -152459,7 +152479,7 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
152459
152479
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
152460
152480
|
if (!compilerOptions.allowImportingTsExtensions) {
|
|
152461
152481
|
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
152462
|
-
const resolvedModule = moduleSpecifier && ((_a = program.
|
|
152482
|
+
const resolvedModule = moduleSpecifier && ((_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule);
|
|
152463
152483
|
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
152464
152484
|
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
152465
152485
|
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
@@ -153136,15 +153156,10 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
153136
153156
|
const importDeclaration = findAncestor(token, isImportDeclaration);
|
|
153137
153157
|
if (importDeclaration === void 0)
|
|
153138
153158
|
return void 0;
|
|
153139
|
-
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier
|
|
153159
|
+
const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier : void 0;
|
|
153140
153160
|
if (moduleSpecifier === void 0)
|
|
153141
153161
|
return void 0;
|
|
153142
|
-
const resolvedModule = (_a = program.
|
|
153143
|
-
sourceFile,
|
|
153144
|
-
moduleSpecifier,
|
|
153145
|
-
/*mode*/
|
|
153146
|
-
void 0
|
|
153147
|
-
)) == null ? void 0 : _a.resolvedModule;
|
|
153162
|
+
const resolvedModule = (_a = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
153148
153163
|
if (resolvedModule === void 0)
|
|
153149
153164
|
return void 0;
|
|
153150
153165
|
const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -153161,7 +153176,7 @@ function getInfo7(sourceFile, pos, program) {
|
|
|
153161
153176
|
if (node === void 0)
|
|
153162
153177
|
return void 0;
|
|
153163
153178
|
const exportName = { node: token, isTypeOnly: isTypeDeclaration(node) };
|
|
153164
|
-
return { exportName, node, moduleSourceFile, moduleSpecifier };
|
|
153179
|
+
return { exportName, node, moduleSourceFile, moduleSpecifier: moduleSpecifier.text };
|
|
153165
153180
|
}
|
|
153166
153181
|
return void 0;
|
|
153167
153182
|
}
|
|
@@ -153355,7 +153370,7 @@ function getInfo8(sourceFile, pos, context, errorCode) {
|
|
|
153355
153370
|
} else if (isImportSpecifier(parent2) && parent2.name === node) {
|
|
153356
153371
|
Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)");
|
|
153357
153372
|
const importDeclaration = findAncestor(node, isImportDeclaration);
|
|
153358
|
-
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(
|
|
153373
|
+
const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration);
|
|
153359
153374
|
if (resolvedSourceFile && resolvedSourceFile.symbol) {
|
|
153360
153375
|
suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol);
|
|
153361
153376
|
}
|
|
@@ -153405,11 +153420,11 @@ function convertSemanticMeaningToSymbolFlags(meaning) {
|
|
|
153405
153420
|
}
|
|
153406
153421
|
return flags;
|
|
153407
153422
|
}
|
|
153408
|
-
function getResolvedSourceFileFromImportDeclaration(
|
|
153423
|
+
function getResolvedSourceFileFromImportDeclaration(context, importDeclaration) {
|
|
153409
153424
|
var _a;
|
|
153410
153425
|
if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier))
|
|
153411
153426
|
return void 0;
|
|
153412
|
-
const resolvedModule = (_a = context.program.
|
|
153427
|
+
const resolvedModule = (_a = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier)) == null ? void 0 : _a.resolvedModule;
|
|
153413
153428
|
if (!resolvedModule)
|
|
153414
153429
|
return void 0;
|
|
153415
153430
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
@@ -154329,16 +154344,242 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
154329
154344
|
return token;
|
|
154330
154345
|
}
|
|
154331
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
|
+
|
|
154332
154573
|
// src/services/codefixes/fixCannotFindModule.ts
|
|
154333
154574
|
var fixName2 = "fixCannotFindModule";
|
|
154334
154575
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
154335
154576
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
154336
|
-
var
|
|
154577
|
+
var errorCodes30 = [
|
|
154337
154578
|
errorCodeCannotFindModule,
|
|
154338
154579
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
154339
154580
|
];
|
|
154340
154581
|
registerCodeFix({
|
|
154341
|
-
errorCodes:
|
|
154582
|
+
errorCodes: errorCodes30,
|
|
154342
154583
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
154343
154584
|
const { host, sourceFile, span: { start: start2 } } = context;
|
|
154344
154585
|
const packageName = tryGetImportedPackageName(sourceFile, start2);
|
|
@@ -154357,7 +154598,7 @@ registerCodeFix({
|
|
|
154357
154598
|
},
|
|
154358
154599
|
fixIds: [fixIdInstallTypesPackage],
|
|
154359
154600
|
getAllCodeActions: (context) => {
|
|
154360
|
-
return codeFixAll(context,
|
|
154601
|
+
return codeFixAll(context, errorCodes30, (_changes, diag2, commands) => {
|
|
154361
154602
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
154362
154603
|
if (packageName === void 0)
|
|
154363
154604
|
return void 0;
|
|
@@ -154392,12 +154633,12 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
154392
154633
|
}
|
|
154393
154634
|
|
|
154394
154635
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
154395
|
-
var
|
|
154636
|
+
var errorCodes31 = [
|
|
154396
154637
|
Diagnostics.Non_abstract_class_0_does_not_implement_all_abstract_members_of_1.code
|
|
154397
154638
|
];
|
|
154398
154639
|
var fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
154399
154640
|
registerCodeFix({
|
|
154400
|
-
errorCodes:
|
|
154641
|
+
errorCodes: errorCodes31,
|
|
154401
154642
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
154402
154643
|
const { sourceFile, span } = context;
|
|
154403
154644
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
@@ -154406,7 +154647,7 @@ registerCodeFix({
|
|
|
154406
154647
|
fixIds: [fixId25],
|
|
154407
154648
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
154408
154649
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
154409
|
-
return codeFixAll(context,
|
|
154650
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
154410
154651
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
154411
154652
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
154412
154653
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -154434,34 +154675,34 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
154434
154675
|
|
|
154435
154676
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
154436
154677
|
var fixId26 = "classSuperMustPrecedeThisAccess";
|
|
154437
|
-
var
|
|
154678
|
+
var errorCodes32 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
154438
154679
|
registerCodeFix({
|
|
154439
|
-
errorCodes:
|
|
154680
|
+
errorCodes: errorCodes32,
|
|
154440
154681
|
getCodeActions(context) {
|
|
154441
154682
|
const { sourceFile, span } = context;
|
|
154442
154683
|
const nodes = getNodes(sourceFile, span.start);
|
|
154443
154684
|
if (!nodes)
|
|
154444
154685
|
return void 0;
|
|
154445
154686
|
const { constructor, superCall } = nodes;
|
|
154446
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154687
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, sourceFile, constructor, superCall));
|
|
154447
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)];
|
|
154448
154689
|
},
|
|
154449
154690
|
fixIds: [fixId26],
|
|
154450
154691
|
getAllCodeActions(context) {
|
|
154451
154692
|
const { sourceFile } = context;
|
|
154452
154693
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
154453
|
-
return codeFixAll(context,
|
|
154694
|
+
return codeFixAll(context, errorCodes32, (changes, diag2) => {
|
|
154454
154695
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
154455
154696
|
if (!nodes)
|
|
154456
154697
|
return;
|
|
154457
154698
|
const { constructor, superCall } = nodes;
|
|
154458
154699
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
154459
|
-
|
|
154700
|
+
doChange20(changes, sourceFile, constructor, superCall);
|
|
154460
154701
|
}
|
|
154461
154702
|
});
|
|
154462
154703
|
}
|
|
154463
154704
|
});
|
|
154464
|
-
function
|
|
154705
|
+
function doChange20(changes, sourceFile, constructor, superCall) {
|
|
154465
154706
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
154466
154707
|
changes.delete(sourceFile, superCall);
|
|
154467
154708
|
}
|
|
@@ -154479,24 +154720,24 @@ function findSuperCall(n) {
|
|
|
154479
154720
|
|
|
154480
154721
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
154481
154722
|
var fixId27 = "constructorForDerivedNeedSuperCall";
|
|
154482
|
-
var
|
|
154723
|
+
var errorCodes33 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
154483
154724
|
registerCodeFix({
|
|
154484
|
-
errorCodes:
|
|
154725
|
+
errorCodes: errorCodes33,
|
|
154485
154726
|
getCodeActions(context) {
|
|
154486
154727
|
const { sourceFile, span } = context;
|
|
154487
154728
|
const ctr = getNode(sourceFile, span.start);
|
|
154488
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154729
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, ctr));
|
|
154489
154730
|
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
154490
154731
|
},
|
|
154491
154732
|
fixIds: [fixId27],
|
|
154492
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154733
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes, diag2) => doChange21(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
154493
154734
|
});
|
|
154494
154735
|
function getNode(sourceFile, pos) {
|
|
154495
154736
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
154496
154737
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
154497
154738
|
return token.parent;
|
|
154498
154739
|
}
|
|
154499
|
-
function
|
|
154740
|
+
function doChange21(changes, sourceFile, ctr) {
|
|
154500
154741
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
154501
154742
|
factory.createSuper(),
|
|
154502
154743
|
/*typeArguments*/
|
|
@@ -154509,59 +154750,59 @@ function doChange20(changes, sourceFile, ctr) {
|
|
|
154509
154750
|
|
|
154510
154751
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
154511
154752
|
var fixID = "fixEnableJsxFlag";
|
|
154512
|
-
var
|
|
154753
|
+
var errorCodes34 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
154513
154754
|
registerCodeFix({
|
|
154514
|
-
errorCodes:
|
|
154755
|
+
errorCodes: errorCodes34,
|
|
154515
154756
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
154516
154757
|
const { configFile } = context.program.getCompilerOptions();
|
|
154517
154758
|
if (configFile === void 0) {
|
|
154518
154759
|
return void 0;
|
|
154519
154760
|
}
|
|
154520
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) =>
|
|
154761
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) => doChange22(changeTracker, configFile));
|
|
154521
154762
|
return [
|
|
154522
154763
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
154523
154764
|
];
|
|
154524
154765
|
},
|
|
154525
154766
|
fixIds: [fixID],
|
|
154526
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154767
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes34, (changes) => {
|
|
154527
154768
|
const { configFile } = context.program.getCompilerOptions();
|
|
154528
154769
|
if (configFile === void 0) {
|
|
154529
154770
|
return void 0;
|
|
154530
154771
|
}
|
|
154531
|
-
|
|
154772
|
+
doChange22(changes, configFile);
|
|
154532
154773
|
})
|
|
154533
154774
|
});
|
|
154534
|
-
function
|
|
154775
|
+
function doChange22(changeTracker, configFile) {
|
|
154535
154776
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
154536
154777
|
}
|
|
154537
154778
|
|
|
154538
154779
|
// src/services/codefixes/fixNaNEquality.ts
|
|
154539
154780
|
var fixId28 = "fixNaNEquality";
|
|
154540
|
-
var
|
|
154781
|
+
var errorCodes35 = [
|
|
154541
154782
|
Diagnostics.This_condition_will_always_return_0.code
|
|
154542
154783
|
];
|
|
154543
154784
|
registerCodeFix({
|
|
154544
|
-
errorCodes:
|
|
154785
|
+
errorCodes: errorCodes35,
|
|
154545
154786
|
getCodeActions(context) {
|
|
154546
154787
|
const { sourceFile, span, program } = context;
|
|
154547
|
-
const info =
|
|
154788
|
+
const info = getInfo12(program, sourceFile, span);
|
|
154548
154789
|
if (info === void 0)
|
|
154549
154790
|
return;
|
|
154550
154791
|
const { suggestion, expression, arg } = info;
|
|
154551
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154792
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, arg, expression));
|
|
154552
154793
|
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
154553
154794
|
},
|
|
154554
154795
|
fixIds: [fixId28],
|
|
154555
154796
|
getAllCodeActions: (context) => {
|
|
154556
|
-
return codeFixAll(context,
|
|
154557
|
-
const info =
|
|
154797
|
+
return codeFixAll(context, errorCodes35, (changes, diag2) => {
|
|
154798
|
+
const info = getInfo12(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
154558
154799
|
if (info) {
|
|
154559
|
-
|
|
154800
|
+
doChange23(changes, diag2.file, info.arg, info.expression);
|
|
154560
154801
|
}
|
|
154561
154802
|
});
|
|
154562
154803
|
}
|
|
154563
154804
|
});
|
|
154564
|
-
function
|
|
154805
|
+
function getInfo12(program, sourceFile, span) {
|
|
154565
154806
|
const diag2 = find(program.getSemanticDiagnostics(sourceFile), (diag3) => diag3.start === span.start && diag3.length === span.length);
|
|
154566
154807
|
if (diag2 === void 0 || diag2.relatedInformation === void 0)
|
|
154567
154808
|
return;
|
|
@@ -154576,7 +154817,7 @@ function getInfo11(program, sourceFile, span) {
|
|
|
154576
154817
|
}
|
|
154577
154818
|
return void 0;
|
|
154578
154819
|
}
|
|
154579
|
-
function
|
|
154820
|
+
function doChange23(changes, sourceFile, arg, expression) {
|
|
154580
154821
|
const callExpression = factory.createCallExpression(
|
|
154581
154822
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
154582
154823
|
/*typeArguments*/
|
|
@@ -154598,9 +154839,9 @@ function getSuggestion(messageText) {
|
|
|
154598
154839
|
// src/services/codefixes/fixModuleAndTargetOptions.ts
|
|
154599
154840
|
registerCodeFix({
|
|
154600
154841
|
errorCodes: [
|
|
154601
|
-
Diagnostics.
|
|
154602
|
-
Diagnostics.
|
|
154603
|
-
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
|
|
154604
154845
|
],
|
|
154605
154846
|
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
|
|
154606
154847
|
const compilerOptions = context.program.getCompilerOptions();
|
|
@@ -154638,21 +154879,21 @@ registerCodeFix({
|
|
|
154638
154879
|
|
|
154639
154880
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
154640
154881
|
var fixId29 = "fixPropertyAssignment";
|
|
154641
|
-
var
|
|
154882
|
+
var errorCodes36 = [
|
|
154642
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
|
|
154643
154884
|
];
|
|
154644
154885
|
registerCodeFix({
|
|
154645
|
-
errorCodes:
|
|
154886
|
+
errorCodes: errorCodes36,
|
|
154646
154887
|
fixIds: [fixId29],
|
|
154647
154888
|
getCodeActions(context) {
|
|
154648
154889
|
const { sourceFile, span } = context;
|
|
154649
154890
|
const property = getProperty2(sourceFile, span.start);
|
|
154650
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154891
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange24(t, context.sourceFile, property));
|
|
154651
154892
|
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
154652
154893
|
},
|
|
154653
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154894
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => doChange24(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
154654
154895
|
});
|
|
154655
|
-
function
|
|
154896
|
+
function doChange24(changes, sourceFile, node) {
|
|
154656
154897
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
154657
154898
|
}
|
|
154658
154899
|
function getProperty2(sourceFile, pos) {
|
|
@@ -154661,9 +154902,9 @@ function getProperty2(sourceFile, pos) {
|
|
|
154661
154902
|
|
|
154662
154903
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
154663
154904
|
var fixId30 = "extendsInterfaceBecomesImplements";
|
|
154664
|
-
var
|
|
154905
|
+
var errorCodes37 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
154665
154906
|
registerCodeFix({
|
|
154666
|
-
errorCodes:
|
|
154907
|
+
errorCodes: errorCodes37,
|
|
154667
154908
|
getCodeActions(context) {
|
|
154668
154909
|
const { sourceFile } = context;
|
|
154669
154910
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -154674,7 +154915,7 @@ registerCodeFix({
|
|
|
154674
154915
|
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
154675
154916
|
},
|
|
154676
154917
|
fixIds: [fixId30],
|
|
154677
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154918
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
154678
154919
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
154679
154920
|
if (nodes)
|
|
154680
154921
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -154704,36 +154945,36 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
154704
154945
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
154705
154946
|
var fixId31 = "forgottenThisPropertyAccess";
|
|
154706
154947
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
154707
|
-
var
|
|
154948
|
+
var errorCodes38 = [
|
|
154708
154949
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
154709
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,
|
|
154710
154951
|
didYouMeanStaticMemberCode
|
|
154711
154952
|
];
|
|
154712
154953
|
registerCodeFix({
|
|
154713
|
-
errorCodes:
|
|
154954
|
+
errorCodes: errorCodes38,
|
|
154714
154955
|
getCodeActions(context) {
|
|
154715
154956
|
const { sourceFile } = context;
|
|
154716
|
-
const info =
|
|
154957
|
+
const info = getInfo13(sourceFile, context.span.start, context.errorCode);
|
|
154717
154958
|
if (!info) {
|
|
154718
154959
|
return void 0;
|
|
154719
154960
|
}
|
|
154720
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154961
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange25(t, sourceFile, info));
|
|
154721
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)];
|
|
154722
154963
|
},
|
|
154723
154964
|
fixIds: [fixId31],
|
|
154724
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154725
|
-
const info =
|
|
154965
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes38, (changes, diag2) => {
|
|
154966
|
+
const info = getInfo13(diag2.file, diag2.start, diag2.code);
|
|
154726
154967
|
if (info)
|
|
154727
|
-
|
|
154968
|
+
doChange25(changes, context.sourceFile, info);
|
|
154728
154969
|
})
|
|
154729
154970
|
});
|
|
154730
|
-
function
|
|
154971
|
+
function getInfo13(sourceFile, pos, diagCode) {
|
|
154731
154972
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
154732
154973
|
if (isIdentifier(node) || isPrivateIdentifier(node)) {
|
|
154733
154974
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
154734
154975
|
}
|
|
154735
154976
|
}
|
|
154736
|
-
function
|
|
154977
|
+
function doChange25(changes, sourceFile, { node, className }) {
|
|
154737
154978
|
suppressLeadingAndTrailingTrivia(node);
|
|
154738
154979
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
154739
154980
|
}
|
|
@@ -154741,16 +154982,16 @@ function doChange24(changes, sourceFile, { node, className }) {
|
|
|
154741
154982
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
154742
154983
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
154743
154984
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
154744
|
-
var
|
|
154985
|
+
var errorCodes39 = [
|
|
154745
154986
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
154746
154987
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
154747
154988
|
];
|
|
154748
154989
|
registerCodeFix({
|
|
154749
|
-
errorCodes:
|
|
154990
|
+
errorCodes: errorCodes39,
|
|
154750
154991
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
154751
154992
|
getCodeActions(context) {
|
|
154752
154993
|
const { sourceFile, preferences, span } = context;
|
|
154753
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
154994
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(
|
|
154754
154995
|
t,
|
|
154755
154996
|
preferences,
|
|
154756
154997
|
sourceFile,
|
|
@@ -154758,7 +154999,7 @@ registerCodeFix({
|
|
|
154758
154999
|
/*useHtmlEntity*/
|
|
154759
155000
|
false
|
|
154760
155001
|
));
|
|
154761
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155002
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(
|
|
154762
155003
|
t,
|
|
154763
155004
|
preferences,
|
|
154764
155005
|
sourceFile,
|
|
@@ -154772,7 +155013,7 @@ registerCodeFix({
|
|
|
154772
155013
|
];
|
|
154773
155014
|
},
|
|
154774
155015
|
getAllCodeActions(context) {
|
|
154775
|
-
return codeFixAll(context,
|
|
155016
|
+
return codeFixAll(context, errorCodes39, (changes, diagnostic) => doChange26(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
154776
155017
|
}
|
|
154777
155018
|
});
|
|
154778
155019
|
var htmlEntity = {
|
|
@@ -154782,7 +155023,7 @@ var htmlEntity = {
|
|
|
154782
155023
|
function isValidCharacter(character) {
|
|
154783
155024
|
return hasProperty(htmlEntity, character);
|
|
154784
155025
|
}
|
|
154785
|
-
function
|
|
155026
|
+
function doChange26(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
154786
155027
|
const character = sourceFile.getText()[start2];
|
|
154787
155028
|
if (!isValidCharacter(character)) {
|
|
154788
155029
|
return;
|
|
@@ -154794,16 +155035,16 @@ function doChange25(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
|
154794
155035
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
154795
155036
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
154796
155037
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
154797
|
-
var
|
|
155038
|
+
var errorCodes40 = [
|
|
154798
155039
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
154799
155040
|
];
|
|
154800
155041
|
registerCodeFix({
|
|
154801
155042
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
154802
|
-
errorCodes:
|
|
155043
|
+
errorCodes: errorCodes40,
|
|
154803
155044
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
154804
155045
|
const { sourceFile, span } = context;
|
|
154805
155046
|
const actions2 = [];
|
|
154806
|
-
const info =
|
|
155047
|
+
const info = getInfo14(sourceFile, span.start);
|
|
154807
155048
|
if (info) {
|
|
154808
155049
|
append(actions2, getDeleteAction(context, info));
|
|
154809
155050
|
append(actions2, getRenameAction(context, info));
|
|
@@ -154814,8 +155055,8 @@ registerCodeFix({
|
|
|
154814
155055
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
154815
155056
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
154816
155057
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
154817
|
-
eachDiagnostic(context,
|
|
154818
|
-
const info =
|
|
155058
|
+
eachDiagnostic(context, errorCodes40, ({ file, start: start2 }) => {
|
|
155059
|
+
const info = getInfo14(file, start2);
|
|
154819
155060
|
if (info) {
|
|
154820
155061
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
154821
155062
|
}
|
|
@@ -154865,7 +155106,7 @@ function getRenameAction(context, { name, jsDocHost, signature, jsDocParameterTa
|
|
|
154865
155106
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changeTracker) => changeTracker.replaceJSDocComment(sourceFile, jsDocHost, map(tags, (t) => t === jsDocParameterTag ? newJSDocParameterTag : t)));
|
|
154866
155107
|
return createCodeFixActionWithoutFixAll(renameUnmatchedParameter, changes, [Diagnostics.Rename_param_tag_name_0_to_1, name.getText(sourceFile), parameterName]);
|
|
154867
155108
|
}
|
|
154868
|
-
function
|
|
155109
|
+
function getInfo14(sourceFile, pos) {
|
|
154869
155110
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
154870
155111
|
if (token.parent && isJSDocParameterTag(token.parent) && isIdentifier(token.parent.name)) {
|
|
154871
155112
|
const jsDocParameterTag = token.parent;
|
|
@@ -154880,9 +155121,9 @@ function getInfo13(sourceFile, pos) {
|
|
|
154880
155121
|
|
|
154881
155122
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
154882
155123
|
var fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
154883
|
-
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];
|
|
154884
155125
|
registerCodeFix({
|
|
154885
|
-
errorCodes:
|
|
155126
|
+
errorCodes: errorCodes41,
|
|
154886
155127
|
getCodeActions: (context) => {
|
|
154887
155128
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
154888
155129
|
if (!importDeclaration)
|
|
@@ -154937,7 +155178,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
154937
155178
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
154938
155179
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
154939
155180
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
154940
|
-
var
|
|
155181
|
+
var errorCodes42 = [
|
|
154941
155182
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
154942
155183
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
154943
155184
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -154947,7 +155188,7 @@ var errorCodes41 = [
|
|
|
154947
155188
|
Diagnostics.All_type_parameters_are_unused.code
|
|
154948
155189
|
];
|
|
154949
155190
|
registerCodeFix({
|
|
154950
|
-
errorCodes:
|
|
155191
|
+
errorCodes: errorCodes42,
|
|
154951
155192
|
getCodeActions(context) {
|
|
154952
155193
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
154953
155194
|
const checker = program.getTypeChecker();
|
|
@@ -155033,7 +155274,7 @@ registerCodeFix({
|
|
|
155033
155274
|
const { sourceFile, program, cancellationToken } = context;
|
|
155034
155275
|
const checker = program.getTypeChecker();
|
|
155035
155276
|
const sourceFiles = program.getSourceFiles();
|
|
155036
|
-
return codeFixAll(context,
|
|
155277
|
+
return codeFixAll(context, errorCodes42, (changes, diag2) => {
|
|
155037
155278
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
155038
155279
|
switch (context.fixId) {
|
|
155039
155280
|
case fixIdPrefix:
|
|
@@ -155269,20 +155510,20 @@ function mayDeleteExpression(node) {
|
|
|
155269
155510
|
|
|
155270
155511
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
155271
155512
|
var fixId33 = "fixUnreachableCode";
|
|
155272
|
-
var
|
|
155513
|
+
var errorCodes43 = [Diagnostics.Unreachable_code_detected.code];
|
|
155273
155514
|
registerCodeFix({
|
|
155274
|
-
errorCodes:
|
|
155515
|
+
errorCodes: errorCodes43,
|
|
155275
155516
|
getCodeActions(context) {
|
|
155276
155517
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
155277
155518
|
if (syntacticDiagnostics.length)
|
|
155278
155519
|
return;
|
|
155279
|
-
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));
|
|
155280
155521
|
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
155281
155522
|
},
|
|
155282
155523
|
fixIds: [fixId33],
|
|
155283
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155524
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange27(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
155284
155525
|
});
|
|
155285
|
-
function
|
|
155526
|
+
function doChange27(changes, sourceFile, start2, length2, errorCode) {
|
|
155286
155527
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155287
155528
|
const statement = findAncestor(token, isStatement);
|
|
155288
155529
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -155333,17 +155574,17 @@ function lastWhere(a, pred) {
|
|
|
155333
155574
|
|
|
155334
155575
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
155335
155576
|
var fixId34 = "fixUnusedLabel";
|
|
155336
|
-
var
|
|
155577
|
+
var errorCodes44 = [Diagnostics.Unused_label.code];
|
|
155337
155578
|
registerCodeFix({
|
|
155338
|
-
errorCodes:
|
|
155579
|
+
errorCodes: errorCodes44,
|
|
155339
155580
|
getCodeActions(context) {
|
|
155340
|
-
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));
|
|
155341
155582
|
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
155342
155583
|
},
|
|
155343
155584
|
fixIds: [fixId34],
|
|
155344
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155585
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes44, (changes, diag2) => doChange28(changes, diag2.file, diag2.start))
|
|
155345
155586
|
});
|
|
155346
|
-
function
|
|
155587
|
+
function doChange28(changes, sourceFile, start2) {
|
|
155347
155588
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155348
155589
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
155349
155590
|
const pos = token.getStart(sourceFile);
|
|
@@ -155360,17 +155601,17 @@ function doChange27(changes, sourceFile, start2) {
|
|
|
155360
155601
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
155361
155602
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
155362
155603
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
155363
|
-
var
|
|
155604
|
+
var errorCodes45 = [
|
|
155364
155605
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
155365
155606
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
155366
155607
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
155367
155608
|
];
|
|
155368
155609
|
registerCodeFix({
|
|
155369
|
-
errorCodes:
|
|
155610
|
+
errorCodes: errorCodes45,
|
|
155370
155611
|
getCodeActions(context) {
|
|
155371
155612
|
const { sourceFile } = context;
|
|
155372
155613
|
const checker = context.program.getTypeChecker();
|
|
155373
|
-
const info =
|
|
155614
|
+
const info = getInfo15(sourceFile, context.span.start, checker);
|
|
155374
155615
|
if (!info)
|
|
155375
155616
|
return void 0;
|
|
155376
155617
|
const { typeNode, type } = info;
|
|
@@ -155381,7 +155622,7 @@ registerCodeFix({
|
|
|
155381
155622
|
}
|
|
155382
155623
|
return actions2;
|
|
155383
155624
|
function fix(type2, fixId52, fixAllDescription) {
|
|
155384
|
-
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));
|
|
155385
155626
|
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
155386
155627
|
}
|
|
155387
155628
|
},
|
|
@@ -155389,17 +155630,17 @@ registerCodeFix({
|
|
|
155389
155630
|
getAllCodeActions(context) {
|
|
155390
155631
|
const { fixId: fixId52, program, sourceFile } = context;
|
|
155391
155632
|
const checker = program.getTypeChecker();
|
|
155392
|
-
return codeFixAll(context,
|
|
155393
|
-
const info =
|
|
155633
|
+
return codeFixAll(context, errorCodes45, (changes, err) => {
|
|
155634
|
+
const info = getInfo15(err.file, err.start, checker);
|
|
155394
155635
|
if (!info)
|
|
155395
155636
|
return;
|
|
155396
155637
|
const { typeNode, type } = info;
|
|
155397
155638
|
const fixedType = typeNode.kind === 321 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
155398
|
-
|
|
155639
|
+
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
155399
155640
|
});
|
|
155400
155641
|
}
|
|
155401
155642
|
});
|
|
155402
|
-
function
|
|
155643
|
+
function doChange29(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
155403
155644
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
155404
155645
|
newType,
|
|
155405
155646
|
/*enclosingDeclaration*/
|
|
@@ -155408,7 +155649,7 @@ function doChange28(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
|
155408
155649
|
void 0
|
|
155409
155650
|
));
|
|
155410
155651
|
}
|
|
155411
|
-
function
|
|
155652
|
+
function getInfo15(sourceFile, pos, checker) {
|
|
155412
155653
|
const decl = findAncestor(getTokenAtPosition(sourceFile, pos), isTypeContainer);
|
|
155413
155654
|
const typeNode = decl && decl.type;
|
|
155414
155655
|
return typeNode && { typeNode, type: getType(checker, typeNode) };
|
|
@@ -155451,27 +155692,27 @@ function getType(checker, node) {
|
|
|
155451
155692
|
|
|
155452
155693
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
155453
155694
|
var fixId35 = "fixMissingCallParentheses";
|
|
155454
|
-
var
|
|
155695
|
+
var errorCodes46 = [
|
|
155455
155696
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
155456
155697
|
];
|
|
155457
155698
|
registerCodeFix({
|
|
155458
|
-
errorCodes:
|
|
155699
|
+
errorCodes: errorCodes46,
|
|
155459
155700
|
fixIds: [fixId35],
|
|
155460
155701
|
getCodeActions(context) {
|
|
155461
155702
|
const { sourceFile, span } = context;
|
|
155462
155703
|
const callName = getCallName(sourceFile, span.start);
|
|
155463
155704
|
if (!callName)
|
|
155464
155705
|
return;
|
|
155465
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155706
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, context.sourceFile, callName));
|
|
155466
155707
|
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
155467
155708
|
},
|
|
155468
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155709
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
155469
155710
|
const callName = getCallName(diag2.file, diag2.start);
|
|
155470
155711
|
if (callName)
|
|
155471
|
-
|
|
155712
|
+
doChange30(changes, diag2.file, callName);
|
|
155472
155713
|
})
|
|
155473
155714
|
});
|
|
155474
|
-
function
|
|
155715
|
+
function doChange30(changes, sourceFile, name) {
|
|
155475
155716
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
155476
155717
|
}
|
|
155477
155718
|
function getCallName(sourceFile, start2) {
|
|
@@ -155491,30 +155732,30 @@ function getCallName(sourceFile, start2) {
|
|
|
155491
155732
|
|
|
155492
155733
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
155493
155734
|
var fixId36 = "fixAwaitInSyncFunction";
|
|
155494
|
-
var
|
|
155735
|
+
var errorCodes47 = [
|
|
155495
155736
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155496
155737
|
Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155497
155738
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
155498
155739
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
155499
155740
|
];
|
|
155500
155741
|
registerCodeFix({
|
|
155501
|
-
errorCodes:
|
|
155742
|
+
errorCodes: errorCodes47,
|
|
155502
155743
|
getCodeActions(context) {
|
|
155503
155744
|
const { sourceFile, span } = context;
|
|
155504
155745
|
const nodes = getNodes3(sourceFile, span.start);
|
|
155505
155746
|
if (!nodes)
|
|
155506
155747
|
return void 0;
|
|
155507
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
155748
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
|
|
155508
155749
|
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
155509
155750
|
},
|
|
155510
155751
|
fixIds: [fixId36],
|
|
155511
155752
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
155512
155753
|
const seen = /* @__PURE__ */ new Map();
|
|
155513
|
-
return codeFixAll(context,
|
|
155754
|
+
return codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
155514
155755
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
155515
155756
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
155516
155757
|
return;
|
|
155517
|
-
|
|
155758
|
+
doChange31(changes, context.sourceFile, nodes);
|
|
155518
155759
|
});
|
|
155519
155760
|
}
|
|
155520
155761
|
});
|
|
@@ -155553,7 +155794,7 @@ function getNodes3(sourceFile, start2) {
|
|
|
155553
155794
|
returnType: getReturnType(containingFunction)
|
|
155554
155795
|
};
|
|
155555
155796
|
}
|
|
155556
|
-
function
|
|
155797
|
+
function doChange31(changes, sourceFile, { insertBefore, returnType }) {
|
|
155557
155798
|
if (returnType) {
|
|
155558
155799
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
155559
155800
|
if (!entityName || entityName.kind !== 80 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -155564,22 +155805,22 @@ function doChange30(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
155564
155805
|
}
|
|
155565
155806
|
|
|
155566
155807
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
155567
|
-
var
|
|
155808
|
+
var errorCodes48 = [
|
|
155568
155809
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
155569
155810
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
155570
155811
|
];
|
|
155571
155812
|
var fixId37 = "fixPropertyOverrideAccessor";
|
|
155572
155813
|
registerCodeFix({
|
|
155573
|
-
errorCodes:
|
|
155814
|
+
errorCodes: errorCodes48,
|
|
155574
155815
|
getCodeActions(context) {
|
|
155575
|
-
const edits =
|
|
155816
|
+
const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
155576
155817
|
if (edits) {
|
|
155577
155818
|
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
155578
155819
|
}
|
|
155579
155820
|
},
|
|
155580
155821
|
fixIds: [fixId37],
|
|
155581
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155582
|
-
const edits =
|
|
155822
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes48, (changes, diag2) => {
|
|
155823
|
+
const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
155583
155824
|
if (edits) {
|
|
155584
155825
|
for (const edit of edits) {
|
|
155585
155826
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -155587,7 +155828,7 @@ registerCodeFix({
|
|
|
155587
155828
|
}
|
|
155588
155829
|
})
|
|
155589
155830
|
});
|
|
155590
|
-
function
|
|
155831
|
+
function doChange32(file, start2, length2, code, context) {
|
|
155591
155832
|
let startPosition;
|
|
155592
155833
|
let endPosition;
|
|
155593
155834
|
if (code === Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code) {
|
|
@@ -155617,7 +155858,7 @@ function doChange31(file, start2, length2, code, context) {
|
|
|
155617
155858
|
|
|
155618
155859
|
// src/services/codefixes/inferFromUsage.ts
|
|
155619
155860
|
var fixId38 = "inferFromUsage";
|
|
155620
|
-
var
|
|
155861
|
+
var errorCodes49 = [
|
|
155621
155862
|
// Variable declarations
|
|
155622
155863
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
155623
155864
|
// Variable uses
|
|
@@ -155651,13 +155892,13 @@ var errorCodes48 = [
|
|
|
155651
155892
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
155652
155893
|
];
|
|
155653
155894
|
registerCodeFix({
|
|
155654
|
-
errorCodes:
|
|
155895
|
+
errorCodes: errorCodes49,
|
|
155655
155896
|
getCodeActions(context) {
|
|
155656
155897
|
const { sourceFile, program, span: { start: start2 }, errorCode, cancellationToken, host, preferences } = context;
|
|
155657
155898
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
155658
155899
|
let declaration;
|
|
155659
155900
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
155660
|
-
declaration =
|
|
155901
|
+
declaration = doChange33(
|
|
155661
155902
|
changes2,
|
|
155662
155903
|
sourceFile,
|
|
155663
155904
|
token,
|
|
@@ -155677,8 +155918,8 @@ registerCodeFix({
|
|
|
155677
155918
|
getAllCodeActions(context) {
|
|
155678
155919
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
155679
155920
|
const markSeen = nodeSeenTracker();
|
|
155680
|
-
return codeFixAll(context,
|
|
155681
|
-
|
|
155921
|
+
return codeFixAll(context, errorCodes49, (changes, err) => {
|
|
155922
|
+
doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
155682
155923
|
});
|
|
155683
155924
|
}
|
|
155684
155925
|
});
|
|
@@ -155717,7 +155958,7 @@ function mapSuggestionDiagnostic(errorCode) {
|
|
|
155717
155958
|
}
|
|
155718
155959
|
return errorCode;
|
|
155719
155960
|
}
|
|
155720
|
-
function
|
|
155961
|
+
function doChange33(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
155721
155962
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 80 /* Identifier */ && token.kind !== 26 /* DotDotDotToken */ && token.kind !== 110 /* ThisKeyword */) {
|
|
155722
155963
|
return void 0;
|
|
155723
155964
|
}
|
|
@@ -156617,21 +156858,21 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
156617
156858
|
|
|
156618
156859
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
156619
156860
|
var fixId39 = "fixReturnTypeInAsyncFunction";
|
|
156620
|
-
var
|
|
156861
|
+
var errorCodes50 = [
|
|
156621
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
|
|
156622
156863
|
];
|
|
156623
156864
|
registerCodeFix({
|
|
156624
|
-
errorCodes:
|
|
156865
|
+
errorCodes: errorCodes50,
|
|
156625
156866
|
fixIds: [fixId39],
|
|
156626
156867
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
156627
156868
|
const { sourceFile, program, span } = context;
|
|
156628
156869
|
const checker = program.getTypeChecker();
|
|
156629
|
-
const info =
|
|
156870
|
+
const info = getInfo16(sourceFile, program.getTypeChecker(), span.start);
|
|
156630
156871
|
if (!info) {
|
|
156631
156872
|
return void 0;
|
|
156632
156873
|
}
|
|
156633
156874
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
156634
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
156875
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
156635
156876
|
return [createCodeFixAction(
|
|
156636
156877
|
fixId39,
|
|
156637
156878
|
changes,
|
|
@@ -156640,14 +156881,14 @@ registerCodeFix({
|
|
|
156640
156881
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
156641
156882
|
)];
|
|
156642
156883
|
},
|
|
156643
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
156644
|
-
const info =
|
|
156884
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
156885
|
+
const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
156645
156886
|
if (info) {
|
|
156646
|
-
|
|
156887
|
+
doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
156647
156888
|
}
|
|
156648
156889
|
})
|
|
156649
156890
|
});
|
|
156650
|
-
function
|
|
156891
|
+
function getInfo16(sourceFile, checker, pos) {
|
|
156651
156892
|
if (isInJSFile(sourceFile)) {
|
|
156652
156893
|
return void 0;
|
|
156653
156894
|
}
|
|
@@ -156670,19 +156911,19 @@ function getInfo15(sourceFile, checker, pos) {
|
|
|
156670
156911
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
156671
156912
|
}
|
|
156672
156913
|
}
|
|
156673
|
-
function
|
|
156914
|
+
function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
156674
156915
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
156675
156916
|
}
|
|
156676
156917
|
|
|
156677
156918
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
156678
156919
|
var fixName4 = "disableJsDiagnostics";
|
|
156679
156920
|
var fixId40 = "disableJsDiagnostics";
|
|
156680
|
-
var
|
|
156921
|
+
var errorCodes51 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
156681
156922
|
const diag2 = Diagnostics[key];
|
|
156682
156923
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
156683
156924
|
});
|
|
156684
156925
|
registerCodeFix({
|
|
156685
|
-
errorCodes:
|
|
156926
|
+
errorCodes: errorCodes51,
|
|
156686
156927
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
156687
156928
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
156688
156929
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -156710,7 +156951,7 @@ registerCodeFix({
|
|
|
156710
156951
|
fixIds: [fixId40],
|
|
156711
156952
|
getAllCodeActions: (context) => {
|
|
156712
156953
|
const seenLines = /* @__PURE__ */ new Set();
|
|
156713
|
-
return codeFixAll(context,
|
|
156954
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
156714
156955
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
156715
156956
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
156716
156957
|
}
|
|
@@ -157709,11 +157950,11 @@ var fixName6 = "strictClassInitialization";
|
|
|
157709
157950
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
157710
157951
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
157711
157952
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
157712
|
-
var
|
|
157953
|
+
var errorCodes52 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
157713
157954
|
registerCodeFix({
|
|
157714
|
-
errorCodes:
|
|
157955
|
+
errorCodes: errorCodes52,
|
|
157715
157956
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
157716
|
-
const info =
|
|
157957
|
+
const info = getInfo17(context.sourceFile, context.span.start);
|
|
157717
157958
|
if (!info)
|
|
157718
157959
|
return;
|
|
157719
157960
|
const result = [];
|
|
@@ -157724,8 +157965,8 @@ registerCodeFix({
|
|
|
157724
157965
|
},
|
|
157725
157966
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
157726
157967
|
getAllCodeActions: (context) => {
|
|
157727
|
-
return codeFixAll(context,
|
|
157728
|
-
const info =
|
|
157968
|
+
return codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
157969
|
+
const info = getInfo17(diag2.file, diag2.start);
|
|
157729
157970
|
if (!info)
|
|
157730
157971
|
return;
|
|
157731
157972
|
switch (context.fixId) {
|
|
@@ -157748,7 +157989,7 @@ registerCodeFix({
|
|
|
157748
157989
|
});
|
|
157749
157990
|
}
|
|
157750
157991
|
});
|
|
157751
|
-
function
|
|
157992
|
+
function getInfo17(sourceFile, pos) {
|
|
157752
157993
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
157753
157994
|
if (isIdentifier(token) && isPropertyDeclaration(token.parent)) {
|
|
157754
157995
|
const type = getEffectiveTypeAnnotationNode(token.parent);
|
|
@@ -157855,26 +158096,26 @@ function getDefaultValueFromType(checker, type) {
|
|
|
157855
158096
|
|
|
157856
158097
|
// src/services/codefixes/requireInTs.ts
|
|
157857
158098
|
var fixId41 = "requireInTs";
|
|
157858
|
-
var
|
|
158099
|
+
var errorCodes53 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
157859
158100
|
registerCodeFix({
|
|
157860
|
-
errorCodes:
|
|
158101
|
+
errorCodes: errorCodes53,
|
|
157861
158102
|
getCodeActions(context) {
|
|
157862
|
-
const info =
|
|
158103
|
+
const info = getInfo18(context.sourceFile, context.program, context.span.start);
|
|
157863
158104
|
if (!info) {
|
|
157864
158105
|
return void 0;
|
|
157865
158106
|
}
|
|
157866
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158107
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
|
|
157867
158108
|
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
157868
158109
|
},
|
|
157869
158110
|
fixIds: [fixId41],
|
|
157870
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157871
|
-
const info =
|
|
158111
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
158112
|
+
const info = getInfo18(diag2.file, context.program, diag2.start);
|
|
157872
158113
|
if (info) {
|
|
157873
|
-
|
|
158114
|
+
doChange35(changes, context.sourceFile, info);
|
|
157874
158115
|
}
|
|
157875
158116
|
})
|
|
157876
158117
|
});
|
|
157877
|
-
function
|
|
158118
|
+
function doChange35(changes, sourceFile, info) {
|
|
157878
158119
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
157879
158120
|
changes.replaceNode(
|
|
157880
158121
|
sourceFile,
|
|
@@ -157901,7 +158142,7 @@ function doChange34(changes, sourceFile, info) {
|
|
|
157901
158142
|
)
|
|
157902
158143
|
);
|
|
157903
158144
|
}
|
|
157904
|
-
function
|
|
158145
|
+
function getInfo18(sourceFile, program, pos) {
|
|
157905
158146
|
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
157906
158147
|
if (!isRequireCall(
|
|
157907
158148
|
parent2,
|
|
@@ -157943,25 +158184,25 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
157943
158184
|
|
|
157944
158185
|
// src/services/codefixes/useDefaultImport.ts
|
|
157945
158186
|
var fixId42 = "useDefaultImport";
|
|
157946
|
-
var
|
|
158187
|
+
var errorCodes54 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
157947
158188
|
registerCodeFix({
|
|
157948
|
-
errorCodes:
|
|
158189
|
+
errorCodes: errorCodes54,
|
|
157949
158190
|
getCodeActions(context) {
|
|
157950
158191
|
const { sourceFile, span: { start: start2 } } = context;
|
|
157951
|
-
const info =
|
|
158192
|
+
const info = getInfo19(sourceFile, start2);
|
|
157952
158193
|
if (!info)
|
|
157953
158194
|
return void 0;
|
|
157954
|
-
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));
|
|
157955
158196
|
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
157956
158197
|
},
|
|
157957
158198
|
fixIds: [fixId42],
|
|
157958
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157959
|
-
const info =
|
|
158199
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes54, (changes, diag2) => {
|
|
158200
|
+
const info = getInfo19(diag2.file, diag2.start);
|
|
157960
158201
|
if (info)
|
|
157961
|
-
|
|
158202
|
+
doChange36(changes, diag2.file, info, context.preferences);
|
|
157962
158203
|
})
|
|
157963
158204
|
});
|
|
157964
|
-
function
|
|
158205
|
+
function getInfo19(sourceFile, pos) {
|
|
157965
158206
|
const name = getTokenAtPosition(sourceFile, pos);
|
|
157966
158207
|
if (!isIdentifier(name))
|
|
157967
158208
|
return void 0;
|
|
@@ -157973,7 +158214,7 @@ function getInfo18(sourceFile, pos) {
|
|
|
157973
158214
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
157974
158215
|
}
|
|
157975
158216
|
}
|
|
157976
|
-
function
|
|
158217
|
+
function doChange36(changes, sourceFile, info, preferences) {
|
|
157977
158218
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
157978
158219
|
info.name,
|
|
157979
158220
|
/*namedImports*/
|
|
@@ -157985,11 +158226,11 @@ function doChange35(changes, sourceFile, info, preferences) {
|
|
|
157985
158226
|
|
|
157986
158227
|
// src/services/codefixes/useBigintLiteral.ts
|
|
157987
158228
|
var fixId43 = "useBigintLiteral";
|
|
157988
|
-
var
|
|
158229
|
+
var errorCodes55 = [
|
|
157989
158230
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
157990
158231
|
];
|
|
157991
158232
|
registerCodeFix({
|
|
157992
|
-
errorCodes:
|
|
158233
|
+
errorCodes: errorCodes55,
|
|
157993
158234
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
157994
158235
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
157995
158236
|
if (changes.length > 0) {
|
|
@@ -157998,7 +158239,7 @@ registerCodeFix({
|
|
|
157998
158239
|
},
|
|
157999
158240
|
fixIds: [fixId43],
|
|
158000
158241
|
getAllCodeActions: (context) => {
|
|
158001
|
-
return codeFixAll(context,
|
|
158242
|
+
return codeFixAll(context, errorCodes55, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
158002
158243
|
}
|
|
158003
158244
|
});
|
|
158004
158245
|
function makeChange9(changeTracker, sourceFile, span) {
|
|
@@ -158013,17 +158254,17 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
158013
158254
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
158014
158255
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
158015
158256
|
var fixId44 = fixIdAddMissingTypeof;
|
|
158016
|
-
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];
|
|
158017
158258
|
registerCodeFix({
|
|
158018
|
-
errorCodes:
|
|
158259
|
+
errorCodes: errorCodes56,
|
|
158019
158260
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
158020
158261
|
const { sourceFile, span } = context;
|
|
158021
158262
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
158022
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158263
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
|
|
158023
158264
|
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
158024
158265
|
},
|
|
158025
158266
|
fixIds: [fixId44],
|
|
158026
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158267
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
158027
158268
|
});
|
|
158028
158269
|
function getImportTypeNode(sourceFile, pos) {
|
|
158029
158270
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -158031,7 +158272,7 @@ function getImportTypeNode(sourceFile, pos) {
|
|
|
158031
158272
|
Debug.assert(token.parent.kind === 205 /* ImportType */, "Token parent should be an ImportType");
|
|
158032
158273
|
return token.parent;
|
|
158033
158274
|
}
|
|
158034
|
-
function
|
|
158275
|
+
function doChange37(changes, sourceFile, importType) {
|
|
158035
158276
|
const newTypeNode = factory.updateImportTypeNode(
|
|
158036
158277
|
importType,
|
|
158037
158278
|
importType.argument,
|
|
@@ -158046,23 +158287,23 @@ function doChange36(changes, sourceFile, importType) {
|
|
|
158046
158287
|
|
|
158047
158288
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
158048
158289
|
var fixID2 = "wrapJsxInFragment";
|
|
158049
|
-
var
|
|
158290
|
+
var errorCodes57 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
158050
158291
|
registerCodeFix({
|
|
158051
|
-
errorCodes:
|
|
158292
|
+
errorCodes: errorCodes57,
|
|
158052
158293
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
158053
158294
|
const { sourceFile, span } = context;
|
|
158054
158295
|
const node = findNodeToFix(sourceFile, span.start);
|
|
158055
158296
|
if (!node)
|
|
158056
158297
|
return void 0;
|
|
158057
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158298
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange38(t, sourceFile, node));
|
|
158058
158299
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
158059
158300
|
},
|
|
158060
158301
|
fixIds: [fixID2],
|
|
158061
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158302
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
158062
158303
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
158063
158304
|
if (!node)
|
|
158064
158305
|
return void 0;
|
|
158065
|
-
|
|
158306
|
+
doChange38(changes, context.sourceFile, node);
|
|
158066
158307
|
})
|
|
158067
158308
|
});
|
|
158068
158309
|
function findNodeToFix(sourceFile, pos) {
|
|
@@ -158078,7 +158319,7 @@ function findNodeToFix(sourceFile, pos) {
|
|
|
158078
158319
|
return void 0;
|
|
158079
158320
|
return binaryExpr;
|
|
158080
158321
|
}
|
|
158081
|
-
function
|
|
158322
|
+
function doChange38(changeTracker, sf, node) {
|
|
158082
158323
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
158083
158324
|
if (jsx)
|
|
158084
158325
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -158104,26 +158345,26 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
158104
158345
|
|
|
158105
158346
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
158106
158347
|
var fixId45 = "fixConvertToMappedObjectType";
|
|
158107
|
-
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];
|
|
158108
158349
|
registerCodeFix({
|
|
158109
|
-
errorCodes:
|
|
158350
|
+
errorCodes: errorCodes58,
|
|
158110
158351
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
158111
158352
|
const { sourceFile, span } = context;
|
|
158112
|
-
const info =
|
|
158353
|
+
const info = getInfo20(sourceFile, span.start);
|
|
158113
158354
|
if (!info)
|
|
158114
158355
|
return void 0;
|
|
158115
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158356
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
158116
158357
|
const name = idText(info.container.name);
|
|
158117
158358
|
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
158118
158359
|
},
|
|
158119
158360
|
fixIds: [fixId45],
|
|
158120
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158121
|
-
const info =
|
|
158361
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => {
|
|
158362
|
+
const info = getInfo20(diag2.file, diag2.start);
|
|
158122
158363
|
if (info)
|
|
158123
|
-
|
|
158364
|
+
doChange39(changes, diag2.file, info);
|
|
158124
158365
|
})
|
|
158125
158366
|
});
|
|
158126
|
-
function
|
|
158367
|
+
function getInfo20(sourceFile, pos) {
|
|
158127
158368
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
158128
158369
|
const indexSignature = tryCast(token.parent.parent, isIndexSignatureDeclaration);
|
|
158129
158370
|
if (!indexSignature)
|
|
@@ -158136,7 +158377,7 @@ function getInfo19(sourceFile, pos) {
|
|
|
158136
158377
|
function createTypeAliasFromInterface(declaration, type) {
|
|
158137
158378
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
158138
158379
|
}
|
|
158139
|
-
function
|
|
158380
|
+
function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
158140
158381
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
158141
158382
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
158142
158383
|
const parameter = first(indexSignature.parameters);
|
|
@@ -158166,11 +158407,11 @@ function doChange38(changes, sourceFile, { indexSignature, container }) {
|
|
|
158166
158407
|
|
|
158167
158408
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
158168
158409
|
var fixId46 = "removeAccidentalCallParentheses";
|
|
158169
|
-
var
|
|
158410
|
+
var errorCodes59 = [
|
|
158170
158411
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
158171
158412
|
];
|
|
158172
158413
|
registerCodeFix({
|
|
158173
|
-
errorCodes:
|
|
158414
|
+
errorCodes: errorCodes59,
|
|
158174
158415
|
getCodeActions(context) {
|
|
158175
158416
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
158176
158417
|
if (!callExpression) {
|
|
@@ -158186,11 +158427,11 @@ registerCodeFix({
|
|
|
158186
158427
|
|
|
158187
158428
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
158188
158429
|
var fixId47 = "removeUnnecessaryAwait";
|
|
158189
|
-
var
|
|
158430
|
+
var errorCodes60 = [
|
|
158190
158431
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
158191
158432
|
];
|
|
158192
158433
|
registerCodeFix({
|
|
158193
|
-
errorCodes:
|
|
158434
|
+
errorCodes: errorCodes60,
|
|
158194
158435
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
158195
158436
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
158196
158437
|
if (changes.length > 0) {
|
|
@@ -158199,7 +158440,7 @@ registerCodeFix({
|
|
|
158199
158440
|
},
|
|
158200
158441
|
fixIds: [fixId47],
|
|
158201
158442
|
getAllCodeActions: (context) => {
|
|
158202
|
-
return codeFixAll(context,
|
|
158443
|
+
return codeFixAll(context, errorCodes60, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
158203
158444
|
}
|
|
158204
158445
|
});
|
|
158205
158446
|
function makeChange10(changeTracker, sourceFile, span) {
|
|
@@ -158227,10 +158468,10 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
158227
158468
|
}
|
|
158228
158469
|
|
|
158229
158470
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
158230
|
-
var
|
|
158471
|
+
var errorCodes61 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
158231
158472
|
var fixId48 = "splitTypeOnlyImport";
|
|
158232
158473
|
registerCodeFix({
|
|
158233
|
-
errorCodes:
|
|
158474
|
+
errorCodes: errorCodes61,
|
|
158234
158475
|
fixIds: [fixId48],
|
|
158235
158476
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
158236
158477
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
@@ -158240,7 +158481,7 @@ registerCodeFix({
|
|
|
158240
158481
|
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
158241
158482
|
}
|
|
158242
158483
|
},
|
|
158243
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158484
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes61, (changes, error2) => {
|
|
158244
158485
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
158245
158486
|
})
|
|
158246
158487
|
});
|
|
@@ -158290,26 +158531,26 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
158290
158531
|
|
|
158291
158532
|
// src/services/codefixes/convertConstToLet.ts
|
|
158292
158533
|
var fixId49 = "fixConvertConstToLet";
|
|
158293
|
-
var
|
|
158534
|
+
var errorCodes62 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
158294
158535
|
registerCodeFix({
|
|
158295
|
-
errorCodes:
|
|
158536
|
+
errorCodes: errorCodes62,
|
|
158296
158537
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
158297
158538
|
const { sourceFile, span, program } = context;
|
|
158298
|
-
const info =
|
|
158539
|
+
const info = getInfo21(sourceFile, span.start, program);
|
|
158299
158540
|
if (info === void 0)
|
|
158300
158541
|
return;
|
|
158301
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158542
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
158302
158543
|
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
158303
158544
|
},
|
|
158304
158545
|
getAllCodeActions: (context) => {
|
|
158305
158546
|
const { program } = context;
|
|
158306
158547
|
const seen = /* @__PURE__ */ new Map();
|
|
158307
158548
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
158308
|
-
eachDiagnostic(context,
|
|
158309
|
-
const info =
|
|
158549
|
+
eachDiagnostic(context, errorCodes62, (diag2) => {
|
|
158550
|
+
const info = getInfo21(diag2.file, diag2.start, program);
|
|
158310
158551
|
if (info) {
|
|
158311
158552
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
158312
|
-
return
|
|
158553
|
+
return doChange40(changes, diag2.file, info.token);
|
|
158313
158554
|
}
|
|
158314
158555
|
}
|
|
158315
158556
|
return void 0;
|
|
@@ -158318,7 +158559,7 @@ registerCodeFix({
|
|
|
158318
158559
|
},
|
|
158319
158560
|
fixIds: [fixId49]
|
|
158320
158561
|
});
|
|
158321
|
-
function
|
|
158562
|
+
function getInfo21(sourceFile, pos, program) {
|
|
158322
158563
|
var _a;
|
|
158323
158564
|
const checker = program.getTypeChecker();
|
|
158324
158565
|
const symbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, pos));
|
|
@@ -158332,22 +158573,22 @@ function getInfo20(sourceFile, pos, program) {
|
|
|
158332
158573
|
return;
|
|
158333
158574
|
return { symbol, token: constToken };
|
|
158334
158575
|
}
|
|
158335
|
-
function
|
|
158576
|
+
function doChange40(changes, sourceFile, token) {
|
|
158336
158577
|
changes.replaceNode(sourceFile, token, factory.createToken(121 /* LetKeyword */));
|
|
158337
158578
|
}
|
|
158338
158579
|
|
|
158339
158580
|
// src/services/codefixes/fixExpectedComma.ts
|
|
158340
158581
|
var fixId50 = "fixExpectedComma";
|
|
158341
158582
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
158342
|
-
var
|
|
158583
|
+
var errorCodes63 = [expectedErrorCode];
|
|
158343
158584
|
registerCodeFix({
|
|
158344
|
-
errorCodes:
|
|
158585
|
+
errorCodes: errorCodes63,
|
|
158345
158586
|
getCodeActions(context) {
|
|
158346
158587
|
const { sourceFile } = context;
|
|
158347
|
-
const info =
|
|
158588
|
+
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
158348
158589
|
if (!info)
|
|
158349
158590
|
return void 0;
|
|
158350
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158591
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
158351
158592
|
return [createCodeFixAction(
|
|
158352
158593
|
fixId50,
|
|
158353
158594
|
changes,
|
|
@@ -158357,17 +158598,17 @@ registerCodeFix({
|
|
|
158357
158598
|
)];
|
|
158358
158599
|
},
|
|
158359
158600
|
fixIds: [fixId50],
|
|
158360
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158361
|
-
const info =
|
|
158601
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes63, (changes, diag2) => {
|
|
158602
|
+
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
158362
158603
|
if (info)
|
|
158363
|
-
|
|
158604
|
+
doChange41(changes, context.sourceFile, info);
|
|
158364
158605
|
})
|
|
158365
158606
|
});
|
|
158366
|
-
function
|
|
158607
|
+
function getInfo22(sourceFile, pos, _) {
|
|
158367
158608
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
158368
158609
|
return node.kind === 27 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
158369
158610
|
}
|
|
158370
|
-
function
|
|
158611
|
+
function doChange41(changes, sourceFile, { node }) {
|
|
158371
158612
|
const newNode = factory.createToken(28 /* CommaToken */);
|
|
158372
158613
|
changes.replaceNode(sourceFile, node, newNode);
|
|
158373
158614
|
}
|
|
@@ -158375,12 +158616,12 @@ function doChange40(changes, sourceFile, { node }) {
|
|
|
158375
158616
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
158376
158617
|
var fixName7 = "addVoidToPromise";
|
|
158377
158618
|
var fixId51 = "addVoidToPromise";
|
|
158378
|
-
var
|
|
158619
|
+
var errorCodes64 = [
|
|
158379
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,
|
|
158380
158621
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
158381
158622
|
];
|
|
158382
158623
|
registerCodeFix({
|
|
158383
|
-
errorCodes:
|
|
158624
|
+
errorCodes: errorCodes64,
|
|
158384
158625
|
fixIds: [fixId51],
|
|
158385
158626
|
getCodeActions(context) {
|
|
158386
158627
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
@@ -158389,7 +158630,7 @@ registerCodeFix({
|
|
|
158389
158630
|
}
|
|
158390
158631
|
},
|
|
158391
158632
|
getAllCodeActions(context) {
|
|
158392
|
-
return codeFixAll(context,
|
|
158633
|
+
return codeFixAll(context, errorCodes64, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
158393
158634
|
}
|
|
158394
158635
|
});
|
|
158395
158636
|
function makeChange11(changes, sourceFile, span, program, seen) {
|
|
@@ -160191,7 +160432,7 @@ function getCompletionEntryDetails(program, log, sourceFile, position, entryId,
|
|
|
160191
160432
|
const { name, source, data } = entryId;
|
|
160192
160433
|
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
|
160193
160434
|
if (isInString(sourceFile, position, previousToken)) {
|
|
160194
|
-
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);
|
|
160195
160436
|
}
|
|
160196
160437
|
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
|
|
160197
160438
|
switch (symbolCompletion.type) {
|
|
@@ -160422,7 +160663,7 @@ function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) {
|
|
|
160422
160663
|
symbol,
|
|
160423
160664
|
enclosingDeclaration,
|
|
160424
160665
|
/*meaning*/
|
|
160425
|
-
|
|
160666
|
+
-1 /* All */,
|
|
160426
160667
|
/*useOnlyExternalAliasing*/
|
|
160427
160668
|
false
|
|
160428
160669
|
);
|
|
@@ -162381,7 +162622,7 @@ function getStringLiteralCompletions(sourceFile, position, contextToken, options
|
|
|
162381
162622
|
if (isInString(sourceFile, position, contextToken)) {
|
|
162382
162623
|
if (!contextToken || !isStringLiteralLike(contextToken))
|
|
162383
162624
|
return void 0;
|
|
162384
|
-
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program
|
|
162625
|
+
const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences);
|
|
162385
162626
|
return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences, position, includeSymbol);
|
|
162386
162627
|
}
|
|
162387
162628
|
}
|
|
@@ -162451,11 +162692,11 @@ function convertStringLiteralCompletions(completion, contextToken, sourceFile, h
|
|
|
162451
162692
|
return Debug.assertNever(completion);
|
|
162452
162693
|
}
|
|
162453
162694
|
}
|
|
162454
|
-
function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken,
|
|
162695
|
+
function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, program, host, cancellationToken, preferences) {
|
|
162455
162696
|
if (!contextToken || !isStringLiteralLike(contextToken))
|
|
162456
162697
|
return void 0;
|
|
162457
|
-
const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position,
|
|
162458
|
-
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);
|
|
162459
162700
|
}
|
|
162460
162701
|
function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) {
|
|
162461
162702
|
switch (completion.kind) {
|
|
@@ -162513,13 +162754,14 @@ function kindModifiersFromExtension(extension) {
|
|
|
162513
162754
|
return Debug.assertNever(extension);
|
|
162514
162755
|
}
|
|
162515
162756
|
}
|
|
162516
|
-
function getStringLiteralCompletionEntries(sourceFile, node, position,
|
|
162757
|
+
function getStringLiteralCompletionEntries(sourceFile, node, position, program, host, preferences) {
|
|
162758
|
+
const typeChecker = program.getTypeChecker();
|
|
162517
162759
|
const parent2 = walkUpParentheses(node.parent);
|
|
162518
162760
|
switch (parent2.kind) {
|
|
162519
162761
|
case 201 /* LiteralType */: {
|
|
162520
162762
|
const grandParent = walkUpParentheses(parent2.parent);
|
|
162521
162763
|
if (grandParent.kind === 205 /* ImportType */) {
|
|
162522
|
-
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162764
|
+
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
|
162523
162765
|
}
|
|
162524
162766
|
return fromUnionableLiteralType(grandParent);
|
|
162525
162767
|
}
|
|
@@ -162545,7 +162787,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck
|
|
|
162545
162787
|
case 272 /* ImportDeclaration */:
|
|
162546
162788
|
case 278 /* ExportDeclaration */:
|
|
162547
162789
|
case 283 /* ExternalModuleReference */:
|
|
162548
|
-
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162790
|
+
return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) };
|
|
162549
162791
|
case 296 /* CaseClause */:
|
|
162550
162792
|
const tracker = newCaseClauseTracker(typeChecker, parent2.parent.clauses);
|
|
162551
162793
|
const contextualTypes = fromContextualType();
|
|
@@ -162675,14 +162917,16 @@ function addReplacementSpans(text, textStart, names) {
|
|
|
162675
162917
|
const wholeSpan = text.length === 0 ? void 0 : createTextSpan(textStart, text.length);
|
|
162676
162918
|
return names.map(({ name, kind, extension }) => name.includes(directorySeparator) || name.includes(altDirectorySeparator) ? { name, kind, extension, span: wholeSpan } : { name, kind, extension, span });
|
|
162677
162919
|
}
|
|
162678
|
-
function getStringLiteralCompletionsFromModuleNames(sourceFile, node,
|
|
162679
|
-
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));
|
|
162680
162922
|
}
|
|
162681
|
-
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node,
|
|
162923
|
+
function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, program, host, preferences) {
|
|
162682
162924
|
const literalValue = normalizeSlashes(node.text);
|
|
162683
|
-
const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : void 0;
|
|
162925
|
+
const mode = isStringLiteralLike(node) ? program.getModeForUsageLocation(sourceFile, node) : void 0;
|
|
162684
162926
|
const scriptPath = sourceFile.path;
|
|
162685
162927
|
const scriptDirectory = getDirectoryPath(scriptPath);
|
|
162928
|
+
const compilerOptions = program.getCompilerOptions();
|
|
162929
|
+
const typeChecker = program.getTypeChecker();
|
|
162686
162930
|
const extensionOptions = getExtensionOptions(compilerOptions, 1 /* ModuleSpecifier */, sourceFile, typeChecker, preferences, mode);
|
|
162687
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);
|
|
162688
162932
|
}
|
|
@@ -164289,7 +164533,7 @@ var Core;
|
|
|
164289
164533
|
if (!options.implementations && isStringLiteralLike(node)) {
|
|
164290
164534
|
if (isModuleSpecifierLike(node)) {
|
|
164291
164535
|
const fileIncludeReasons = program.getFileIncludeReasons();
|
|
164292
|
-
const referencedFileName = (_b = (_a = program.
|
|
164536
|
+
const referencedFileName = (_b = (_a = program.getResolvedModuleFromModuleSpecifier(node)) == null ? void 0 : _a.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
164293
164537
|
const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : void 0;
|
|
164294
164538
|
if (referencedFile) {
|
|
164295
164539
|
return [{ definition: { type: 4 /* String */, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }];
|
|
@@ -165794,7 +166038,7 @@ function getDefinitionAtPosition(program, sourceFile, position, searchOtherFiles
|
|
|
165794
166038
|
}
|
|
165795
166039
|
}
|
|
165796
166040
|
if (!symbol && isModuleSpecifierLike(fallbackNode)) {
|
|
165797
|
-
const ref = (_a = program.
|
|
166041
|
+
const ref = (_a = program.getResolvedModuleFromModuleSpecifier(fallbackNode)) == null ? void 0 : _a.resolvedModule;
|
|
165798
166042
|
if (ref) {
|
|
165799
166043
|
return [{
|
|
165800
166044
|
name: fallbackNode.text,
|
|
@@ -165909,7 +166153,7 @@ function getReferenceAtPosition(sourceFile, position, program) {
|
|
|
165909
166153
|
if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) {
|
|
165910
166154
|
const node = getTouchingToken(sourceFile, position);
|
|
165911
166155
|
let resolution;
|
|
165912
|
-
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.
|
|
166156
|
+
if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node))) {
|
|
165913
166157
|
const verifiedFileName = (_b = resolution.resolvedModule) == null ? void 0 : _b.resolvedFileName;
|
|
165914
166158
|
const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text);
|
|
165915
166159
|
return {
|
|
@@ -175095,6 +175339,7 @@ __export(ts_exports2, {
|
|
|
175095
175339
|
getStaticPropertiesAndClassStaticBlock: () => getStaticPropertiesAndClassStaticBlock,
|
|
175096
175340
|
getStrictOptionValue: () => getStrictOptionValue,
|
|
175097
175341
|
getStringComparer: () => getStringComparer,
|
|
175342
|
+
getSubPatternFromSpec: () => getSubPatternFromSpec,
|
|
175098
175343
|
getSuperCallFromStatement: () => getSuperCallFromStatement,
|
|
175099
175344
|
getSuperContainer: () => getSuperContainer,
|
|
175100
175345
|
getSupportedCodeFixes: () => getSupportedCodeFixes,
|
|
@@ -176181,7 +176426,6 @@ __export(ts_exports2, {
|
|
|
176181
176426
|
setValueDeclaration: () => setValueDeclaration,
|
|
176182
176427
|
shouldAllowImportingTsExtension: () => shouldAllowImportingTsExtension,
|
|
176183
176428
|
shouldPreserveConstEnums: () => shouldPreserveConstEnums,
|
|
176184
|
-
shouldResolveJsRequire: () => shouldResolveJsRequire,
|
|
176185
176429
|
shouldUseUriStyleNodeCoreModules: () => shouldUseUriStyleNodeCoreModules,
|
|
176186
176430
|
showModuleSpecifier: () => showModuleSpecifier,
|
|
176187
176431
|
signatureHasLiteralTypes: () => signatureHasLiteralTypes,
|
|
@@ -176344,7 +176588,6 @@ __export(ts_exports2, {
|
|
|
176344
176588
|
typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
|
|
176345
176589
|
typeKeywords: () => typeKeywords,
|
|
176346
176590
|
typeParameterNamePart: () => typeParameterNamePart,
|
|
176347
|
-
typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
|
|
176348
176591
|
typeToDisplayParts: () => typeToDisplayParts,
|
|
176349
176592
|
unchangedPollThresholds: () => unchangedPollThresholds,
|
|
176350
176593
|
unchangedTextChangeRange: () => unchangedTextChangeRange,
|
|
@@ -177417,11 +177660,18 @@ var ModuleKind2 = /* @__PURE__ */ ((ModuleKind3) => {
|
|
|
177417
177660
|
ModuleKind3["ES6"] = "ES6";
|
|
177418
177661
|
ModuleKind3["ES2015"] = "ES2015";
|
|
177419
177662
|
ModuleKind3["ESNext"] = "ESNext";
|
|
177663
|
+
ModuleKind3["Node16"] = "Node16";
|
|
177664
|
+
ModuleKind3["NodeNext"] = "NodeNext";
|
|
177665
|
+
ModuleKind3["Preserve"] = "Preserve";
|
|
177420
177666
|
return ModuleKind3;
|
|
177421
177667
|
})(ModuleKind2 || {});
|
|
177422
177668
|
var ModuleResolutionKind2 = /* @__PURE__ */ ((ModuleResolutionKind3) => {
|
|
177423
177669
|
ModuleResolutionKind3["Classic"] = "Classic";
|
|
177424
177670
|
ModuleResolutionKind3["Node"] = "Node";
|
|
177671
|
+
ModuleResolutionKind3["Node10"] = "Node10";
|
|
177672
|
+
ModuleResolutionKind3["Node16"] = "Node16";
|
|
177673
|
+
ModuleResolutionKind3["NodeNext"] = "NodeNext";
|
|
177674
|
+
ModuleResolutionKind3["Bundler"] = "Bundler";
|
|
177425
177675
|
return ModuleResolutionKind3;
|
|
177426
177676
|
})(ModuleResolutionKind2 || {});
|
|
177427
177677
|
var NewLineKind2 = /* @__PURE__ */ ((NewLineKind3) => {
|
|
@@ -189896,6 +190146,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
189896
190146
|
getStaticPropertiesAndClassStaticBlock,
|
|
189897
190147
|
getStrictOptionValue,
|
|
189898
190148
|
getStringComparer,
|
|
190149
|
+
getSubPatternFromSpec,
|
|
189899
190150
|
getSuperCallFromStatement,
|
|
189900
190151
|
getSuperContainer,
|
|
189901
190152
|
getSupportedCodeFixes,
|
|
@@ -190982,7 +191233,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
190982
191233
|
setValueDeclaration,
|
|
190983
191234
|
shouldAllowImportingTsExtension,
|
|
190984
191235
|
shouldPreserveConstEnums,
|
|
190985
|
-
shouldResolveJsRequire,
|
|
190986
191236
|
shouldUseUriStyleNodeCoreModules,
|
|
190987
191237
|
showModuleSpecifier,
|
|
190988
191238
|
signatureHasLiteralTypes,
|
|
@@ -191145,7 +191395,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
191145
191395
|
typeDirectiveIsEqualTo,
|
|
191146
191396
|
typeKeywords,
|
|
191147
191397
|
typeParameterNamePart,
|
|
191148
|
-
typeReferenceResolutionNameAndModeGetter,
|
|
191149
191398
|
typeToDisplayParts,
|
|
191150
191399
|
unchangedPollThresholds,
|
|
191151
191400
|
unchangedTextChangeRange,
|