typescript 5.1.0-dev.20230227 → 5.1.0-dev.20230302
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/README.md +2 -0
- package/lib/lib.es2015.collection.d.ts +1 -1
- package/lib/tsc.js +216 -152
- package/lib/tsserver.js +960 -697
- package/lib/tsserverlibrary.d.ts +7 -44
- package/lib/tsserverlibrary.js +1019 -745
- package/lib/typescript.d.ts +5 -10
- package/lib/typescript.js +897 -634
- package/lib/typingsInstaller.js +50 -14
- package/package.json +14 -14
package/lib/typescript.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.1";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230302`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -1000,9 +1000,6 @@ var ts = (() => {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
function createUnderscoreEscapedMultiMap() {
|
|
1004
|
-
return createMultiMap();
|
|
1005
|
-
}
|
|
1006
1003
|
function createQueue(items) {
|
|
1007
1004
|
const elements = (items == null ? void 0 : items.slice()) || [];
|
|
1008
1005
|
let headIndex = 0;
|
|
@@ -1625,7 +1622,7 @@ var ts = (() => {
|
|
|
1625
1622
|
function isNodeLikeSystem() {
|
|
1626
1623
|
return typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object";
|
|
1627
1624
|
}
|
|
1628
|
-
var emptyArray, emptyMap, emptySet, SortKind, elementAt, hasOwnProperty,
|
|
1625
|
+
var emptyArray, emptyMap, emptySet, SortKind, elementAt, hasOwnProperty, fileNameLowerCaseRegExp, AssertionLevel, createUIStringComparer, uiComparerCaseSensitive, uiLocale, trimString, trimStringEnd, trimStringStart;
|
|
1629
1626
|
var init_core = __esm({
|
|
1630
1627
|
"src/compiler/core.ts"() {
|
|
1631
1628
|
"use strict";
|
|
@@ -1650,10 +1647,6 @@ var ts = (() => {
|
|
|
1650
1647
|
return void 0;
|
|
1651
1648
|
};
|
|
1652
1649
|
hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1653
|
-
noopPush = {
|
|
1654
|
-
push: noop,
|
|
1655
|
-
length: 0
|
|
1656
|
-
};
|
|
1657
1650
|
fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
|
|
1658
1651
|
AssertionLevel = /* @__PURE__ */ ((AssertionLevel2) => {
|
|
1659
1652
|
AssertionLevel2[AssertionLevel2["None"] = 0] = "None";
|
|
@@ -8461,6 +8454,7 @@ ${lanes.join("\n")}
|
|
|
8461
8454
|
File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
|
|
8462
8455
|
Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
|
|
8463
8456
|
Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
|
|
8457
|
+
Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder: diag(6265, 3 /* Message */, "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265", "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder."),
|
|
8464
8458
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
8465
8459
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
8466
8460
|
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
@@ -8856,6 +8850,8 @@ ${lanes.join("\n")}
|
|
|
8856
8850
|
This_may_be_converted_to_an_async_function: diag(80006, 2 /* Suggestion */, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."),
|
|
8857
8851
|
await_has_no_effect_on_the_type_of_this_expression: diag(80007, 2 /* Suggestion */, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."),
|
|
8858
8852
|
Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, 2 /* Suggestion */, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."),
|
|
8853
|
+
JSDoc_typedef_may_be_converted_to_TypeScript_type: diag(80009, 2 /* Suggestion */, "JSDoc_typedef_may_be_converted_to_TypeScript_type_80009", "JSDoc typedef may be converted to TypeScript type."),
|
|
8854
|
+
JSDoc_typedefs_may_be_converted_to_TypeScript_types: diag(80010, 2 /* Suggestion */, "JSDoc_typedefs_may_be_converted_to_TypeScript_types_80010", "JSDoc typedefs may be converted to TypeScript types."),
|
|
8859
8855
|
Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
8860
8856
|
Make_super_call_the_first_statement_in_the_constructor: diag(90002, 3 /* Message */, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
|
|
8861
8857
|
Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
@@ -9070,6 +9066,8 @@ ${lanes.join("\n")}
|
|
|
9070
9066
|
Rename_param_tag_name_0_to_1: diag(95173, 3 /* Message */, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
9071
9067
|
Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
|
|
9072
9068
|
Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
9069
|
+
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
|
|
9070
|
+
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
9073
9071
|
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."),
|
|
9074
9072
|
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'."),
|
|
9075
9073
|
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?"),
|
|
@@ -38856,20 +38854,14 @@ ${lanes.join("\n")}
|
|
|
38856
38854
|
currentDirectory = host.getCurrentDirectory();
|
|
38857
38855
|
}
|
|
38858
38856
|
if (currentDirectory !== void 0) {
|
|
38859
|
-
return getDefaultTypeRoots(currentDirectory
|
|
38857
|
+
return getDefaultTypeRoots(currentDirectory);
|
|
38860
38858
|
}
|
|
38861
38859
|
}
|
|
38862
|
-
function getDefaultTypeRoots(currentDirectory
|
|
38863
|
-
if (!host.directoryExists) {
|
|
38864
|
-
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
38865
|
-
}
|
|
38860
|
+
function getDefaultTypeRoots(currentDirectory) {
|
|
38866
38861
|
let typeRoots;
|
|
38867
38862
|
forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
|
|
38868
38863
|
const atTypes = combinePaths(directory, nodeModulesAtTypes);
|
|
38869
|
-
|
|
38870
|
-
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
38871
|
-
}
|
|
38872
|
-
return void 0;
|
|
38864
|
+
(typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
|
|
38873
38865
|
});
|
|
38874
38866
|
return typeRoots;
|
|
38875
38867
|
}
|
|
@@ -39005,10 +38997,22 @@ ${lanes.join("\n")}
|
|
|
39005
38997
|
}
|
|
39006
38998
|
return firstDefined(typeRoots, (typeRoot) => {
|
|
39007
38999
|
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
39008
|
-
const
|
|
39009
|
-
const directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
39000
|
+
const directoryExists = directoryProbablyExists(typeRoot, host);
|
|
39010
39001
|
if (!directoryExists && traceEnabled) {
|
|
39011
|
-
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it,
|
|
39002
|
+
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
39003
|
+
}
|
|
39004
|
+
if (options.typeRoots) {
|
|
39005
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
|
|
39006
|
+
if (resolvedFromFile) {
|
|
39007
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
39008
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
39009
|
+
packageDirectory,
|
|
39010
|
+
/*onlyRecordFailures*/
|
|
39011
|
+
false,
|
|
39012
|
+
moduleResolutionState
|
|
39013
|
+
) : void 0;
|
|
39014
|
+
return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
|
|
39015
|
+
}
|
|
39012
39016
|
}
|
|
39013
39017
|
return resolvedTypeScriptOnly(
|
|
39014
39018
|
loadNodeModuleFromDirectory(
|
|
@@ -39028,33 +39032,37 @@ ${lanes.join("\n")}
|
|
|
39028
39032
|
function secondaryLookup() {
|
|
39029
39033
|
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
|
|
39030
39034
|
if (initialLocationForSecondaryLookup !== void 0) {
|
|
39031
|
-
if (traceEnabled) {
|
|
39032
|
-
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
39033
|
-
}
|
|
39034
39035
|
let result2;
|
|
39035
|
-
if (!
|
|
39036
|
-
|
|
39037
|
-
|
|
39038
|
-
|
|
39039
|
-
|
|
39040
|
-
|
|
39041
|
-
|
|
39042
|
-
|
|
39043
|
-
|
|
39044
|
-
|
|
39045
|
-
|
|
39046
|
-
|
|
39047
|
-
|
|
39048
|
-
|
|
39049
|
-
|
|
39050
|
-
|
|
39051
|
-
|
|
39052
|
-
|
|
39053
|
-
|
|
39054
|
-
|
|
39055
|
-
|
|
39056
|
-
|
|
39057
|
-
|
|
39036
|
+
if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
|
|
39037
|
+
if (traceEnabled) {
|
|
39038
|
+
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
39039
|
+
}
|
|
39040
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
39041
|
+
const searchResult = loadModuleFromNearestNodeModulesDirectory(
|
|
39042
|
+
4 /* Declaration */,
|
|
39043
|
+
typeReferenceDirectiveName,
|
|
39044
|
+
initialLocationForSecondaryLookup,
|
|
39045
|
+
moduleResolutionState,
|
|
39046
|
+
/*cache*/
|
|
39047
|
+
void 0,
|
|
39048
|
+
/*redirectedReference*/
|
|
39049
|
+
void 0
|
|
39050
|
+
);
|
|
39051
|
+
result2 = searchResult && searchResult.value;
|
|
39052
|
+
} else {
|
|
39053
|
+
const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
|
|
39054
|
+
result2 = nodeLoadModuleByRelativeName(
|
|
39055
|
+
4 /* Declaration */,
|
|
39056
|
+
candidate,
|
|
39057
|
+
/*onlyRecordFailures*/
|
|
39058
|
+
false,
|
|
39059
|
+
moduleResolutionState,
|
|
39060
|
+
/*considerPackageJson*/
|
|
39061
|
+
true
|
|
39062
|
+
);
|
|
39063
|
+
}
|
|
39064
|
+
} else if (traceEnabled) {
|
|
39065
|
+
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
|
|
39058
39066
|
}
|
|
39059
39067
|
return resolvedTypeScriptOnly(result2);
|
|
39060
39068
|
} else {
|
|
@@ -39873,6 +39881,9 @@ ${lanes.join("\n")}
|
|
|
39873
39881
|
}
|
|
39874
39882
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
39875
39883
|
}
|
|
39884
|
+
if (extensions2 & 4 /* Declaration */) {
|
|
39885
|
+
resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
|
|
39886
|
+
}
|
|
39876
39887
|
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
39877
39888
|
} else {
|
|
39878
39889
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
@@ -40052,6 +40063,7 @@ ${lanes.join("\n")}
|
|
|
40052
40063
|
return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
|
|
40053
40064
|
}
|
|
40054
40065
|
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
40066
|
+
var _a2;
|
|
40055
40067
|
if (!onlyRecordFailures) {
|
|
40056
40068
|
if (state.host.fileExists(fileName)) {
|
|
40057
40069
|
if (state.traceEnabled) {
|
|
@@ -40064,7 +40076,7 @@ ${lanes.join("\n")}
|
|
|
40064
40076
|
}
|
|
40065
40077
|
}
|
|
40066
40078
|
}
|
|
40067
|
-
state.failedLookupLocations.push(fileName);
|
|
40079
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
|
|
40068
40080
|
return void 0;
|
|
40069
40081
|
}
|
|
40070
40082
|
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
|
|
@@ -40179,8 +40191,8 @@ ${lanes.join("\n")}
|
|
|
40179
40191
|
host,
|
|
40180
40192
|
compilerOptions: options,
|
|
40181
40193
|
traceEnabled: isTraceEnabled(options, host),
|
|
40182
|
-
failedLookupLocations:
|
|
40183
|
-
affectingLocations:
|
|
40194
|
+
failedLookupLocations: void 0,
|
|
40195
|
+
affectingLocations: void 0,
|
|
40184
40196
|
packageJsonInfoCache,
|
|
40185
40197
|
features: 0 /* None */,
|
|
40186
40198
|
conditions: emptyArray,
|
|
@@ -40214,24 +40226,24 @@ ${lanes.join("\n")}
|
|
|
40214
40226
|
return packageJsonInfo.contents.versionPaths || void 0;
|
|
40215
40227
|
}
|
|
40216
40228
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
40217
|
-
var _a2, _b, _c;
|
|
40229
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
40218
40230
|
const { host, traceEnabled } = state;
|
|
40219
40231
|
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
|
40220
40232
|
if (onlyRecordFailures) {
|
|
40221
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40233
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
|
|
40222
40234
|
return void 0;
|
|
40223
40235
|
}
|
|
40224
|
-
const existing = (
|
|
40236
|
+
const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
40225
40237
|
if (existing !== void 0) {
|
|
40226
40238
|
if (typeof existing !== "boolean") {
|
|
40227
40239
|
if (traceEnabled)
|
|
40228
40240
|
trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
|
|
40229
|
-
state.affectingLocations.push(packageJsonPath);
|
|
40241
|
+
(_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
|
|
40230
40242
|
return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
|
|
40231
40243
|
} else {
|
|
40232
40244
|
if (existing && traceEnabled)
|
|
40233
40245
|
trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
|
|
40234
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40246
|
+
(_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
|
|
40235
40247
|
return void 0;
|
|
40236
40248
|
}
|
|
40237
40249
|
}
|
|
@@ -40242,15 +40254,15 @@ ${lanes.join("\n")}
|
|
|
40242
40254
|
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
40243
40255
|
}
|
|
40244
40256
|
const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
|
|
40245
|
-
(
|
|
40246
|
-
state.affectingLocations.push(packageJsonPath);
|
|
40257
|
+
(_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
|
|
40258
|
+
(_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
|
|
40247
40259
|
return result;
|
|
40248
40260
|
} else {
|
|
40249
40261
|
if (directoryExists && traceEnabled) {
|
|
40250
40262
|
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
40251
40263
|
}
|
|
40252
|
-
(
|
|
40253
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40264
|
+
(_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
|
|
40265
|
+
(_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
|
|
40254
40266
|
}
|
|
40255
40267
|
}
|
|
40256
40268
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
@@ -41070,11 +41082,13 @@ ${lanes.join("\n")}
|
|
|
41070
41082
|
state
|
|
41071
41083
|
));
|
|
41072
41084
|
});
|
|
41073
|
-
if (resolved2)
|
|
41085
|
+
if (resolved2)
|
|
41074
41086
|
return resolved2;
|
|
41075
|
-
}
|
|
41076
41087
|
if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
|
|
41077
|
-
|
|
41088
|
+
let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
|
|
41089
|
+
if (extensions & 4 /* Declaration */)
|
|
41090
|
+
resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
|
|
41091
|
+
return resolved3;
|
|
41078
41092
|
}
|
|
41079
41093
|
} else {
|
|
41080
41094
|
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
|
@@ -41088,6 +41102,31 @@ ${lanes.join("\n")}
|
|
|
41088
41102
|
}
|
|
41089
41103
|
}
|
|
41090
41104
|
}
|
|
41105
|
+
function resolveFromTypeRoot(moduleName, state) {
|
|
41106
|
+
if (!state.compilerOptions.typeRoots)
|
|
41107
|
+
return;
|
|
41108
|
+
for (const typeRoot of state.compilerOptions.typeRoots) {
|
|
41109
|
+
const candidate = combinePaths(typeRoot, moduleName);
|
|
41110
|
+
const directoryExists = directoryProbablyExists(typeRoot, state.host);
|
|
41111
|
+
if (!directoryExists && state.traceEnabled) {
|
|
41112
|
+
trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
41113
|
+
}
|
|
41114
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
|
|
41115
|
+
if (resolvedFromFile) {
|
|
41116
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
41117
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
41118
|
+
packageDirectory,
|
|
41119
|
+
/*onlyRecordFailures*/
|
|
41120
|
+
false,
|
|
41121
|
+
state
|
|
41122
|
+
) : void 0;
|
|
41123
|
+
return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
|
|
41124
|
+
}
|
|
41125
|
+
const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
|
|
41126
|
+
if (resolved)
|
|
41127
|
+
return toSearchResult(resolved);
|
|
41128
|
+
}
|
|
41129
|
+
}
|
|
41091
41130
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
41092
41131
|
return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
|
|
41093
41132
|
}
|
|
@@ -50209,7 +50248,7 @@ ${lanes.join("\n")}
|
|
|
50209
50248
|
}
|
|
50210
50249
|
}
|
|
50211
50250
|
const mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */);
|
|
50212
|
-
const seenNames = mayHaveNameCollisions ?
|
|
50251
|
+
const seenNames = mayHaveNameCollisions ? createMultiMap() : void 0;
|
|
50213
50252
|
const result = [];
|
|
50214
50253
|
let i = 0;
|
|
50215
50254
|
for (const type of types) {
|
|
@@ -54010,7 +54049,11 @@ ${lanes.join("\n")}
|
|
|
54010
54049
|
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
|
54011
54050
|
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
|
54012
54051
|
} else {
|
|
54013
|
-
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
54052
|
+
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
54053
|
+
type,
|
|
54054
|
+
/*isProperty*/
|
|
54055
|
+
true
|
|
54056
|
+
) : type;
|
|
54014
54057
|
}
|
|
54015
54058
|
}
|
|
54016
54059
|
function getTypeOfEnumMember(symbol) {
|
|
@@ -62490,7 +62533,7 @@ ${lanes.join("\n")}
|
|
|
62490
62533
|
0 /* None */
|
|
62491
62534
|
);
|
|
62492
62535
|
}
|
|
62493
|
-
} else if (result2 && isNonGenericObjectType(target2) && !isArrayOrTupleType(target2) && source2.flags & 2097152 /* Intersection */ && getApparentType(source2).flags & 3670016 /* StructuredType */ && !some(source2.types, (t) => !!(getObjectFlags(t) & 262144 /* NonInferrableType */))) {
|
|
62536
|
+
} else if (result2 && isNonGenericObjectType(target2) && !isArrayOrTupleType(target2) && source2.flags & 2097152 /* Intersection */ && getApparentType(source2).flags & 3670016 /* StructuredType */ && !some(source2.types, (t) => t === target2 || !!(getObjectFlags(t) & 262144 /* NonInferrableType */))) {
|
|
62494
62537
|
result2 &= propertiesRelatedTo(
|
|
62495
62538
|
source2,
|
|
62496
62539
|
target2,
|
|
@@ -62711,6 +62754,7 @@ ${lanes.join("\n")}
|
|
|
62711
62754
|
} else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
62712
62755
|
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
62713
62756
|
if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
|
|
62757
|
+
instantiateType(source2.objectType, reportUnreliableMapper);
|
|
62714
62758
|
result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
|
|
62715
62759
|
}
|
|
62716
62760
|
if (result2) {
|
|
@@ -65856,7 +65900,7 @@ ${lanes.join("\n")}
|
|
|
65856
65900
|
);
|
|
65857
65901
|
}
|
|
65858
65902
|
function isInAmbientOrTypeNode(node) {
|
|
65859
|
-
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
|
65903
|
+
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
|
65860
65904
|
}
|
|
65861
65905
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
65862
65906
|
switch (node.kind) {
|
|
@@ -69004,6 +69048,16 @@ ${lanes.join("\n")}
|
|
|
69004
69048
|
const symbol = getSymbolOfDeclaration(element);
|
|
69005
69049
|
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
69006
69050
|
}
|
|
69051
|
+
if (hasDynamicName(element)) {
|
|
69052
|
+
const name = getNameOfDeclaration(element);
|
|
69053
|
+
if (name && isComputedPropertyName(name)) {
|
|
69054
|
+
const exprType = checkExpression(name.expression);
|
|
69055
|
+
const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
|
|
69056
|
+
if (propType) {
|
|
69057
|
+
return propType;
|
|
69058
|
+
}
|
|
69059
|
+
}
|
|
69060
|
+
}
|
|
69007
69061
|
if (element.name) {
|
|
69008
69062
|
const nameType = getLiteralTypeFromPropertyName(element.name);
|
|
69009
69063
|
return mapType(
|
|
@@ -73777,7 +73831,7 @@ ${lanes.join("\n")}
|
|
|
73777
73831
|
}
|
|
73778
73832
|
function getNonArrayRestType(signature) {
|
|
73779
73833
|
const restType = getEffectiveRestType(signature);
|
|
73780
|
-
return restType && !isArrayType(restType) && !isTypeAny(restType)
|
|
73834
|
+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
|
|
73781
73835
|
}
|
|
73782
73836
|
function getTypeOfFirstParameterOfSignature(signature) {
|
|
73783
73837
|
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
|
|
@@ -78591,6 +78645,9 @@ ${lanes.join("\n")}
|
|
|
78591
78645
|
return;
|
|
78592
78646
|
}
|
|
78593
78647
|
if (isBindingPattern(node.name)) {
|
|
78648
|
+
if (isInAmbientOrTypeNode(node)) {
|
|
78649
|
+
return;
|
|
78650
|
+
}
|
|
78594
78651
|
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
|
|
78595
78652
|
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
|
78596
78653
|
if (needCheckInitializer || needCheckWidenedType) {
|
|
@@ -88009,6 +88066,7 @@ ${lanes.join("\n")}
|
|
|
88009
88066
|
);
|
|
88010
88067
|
}
|
|
88011
88068
|
function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
|
|
88069
|
+
const { factory: factory2 } = flattenContext.context;
|
|
88012
88070
|
if (isComputedPropertyName(propertyName)) {
|
|
88013
88071
|
const argumentExpression = ensureIdentifier(
|
|
88014
88072
|
flattenContext,
|
|
@@ -88020,7 +88078,7 @@ ${lanes.join("\n")}
|
|
|
88020
88078
|
);
|
|
88021
88079
|
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
|
88022
88080
|
} else if (isStringOrNumericLiteralLike(propertyName)) {
|
|
88023
|
-
const argumentExpression =
|
|
88081
|
+
const argumentExpression = factory2.cloneNode(propertyName);
|
|
88024
88082
|
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
|
88025
88083
|
} else {
|
|
88026
88084
|
const name = flattenContext.context.factory.createIdentifier(idText(propertyName));
|
|
@@ -88102,28 +88160,29 @@ ${lanes.join("\n")}
|
|
|
88102
88160
|
if (level === 0 /* LiftRestriction */ && !hasInvalidEscape(template)) {
|
|
88103
88161
|
return visitEachChild(node, visitor, context);
|
|
88104
88162
|
}
|
|
88163
|
+
const { factory: factory2 } = context;
|
|
88105
88164
|
if (isNoSubstitutionTemplateLiteral(template)) {
|
|
88106
|
-
cookedStrings.push(createTemplateCooked(template));
|
|
88107
|
-
rawStrings.push(getRawLiteral(template, currentSourceFile));
|
|
88165
|
+
cookedStrings.push(createTemplateCooked(factory2, template));
|
|
88166
|
+
rawStrings.push(getRawLiteral(factory2, template, currentSourceFile));
|
|
88108
88167
|
} else {
|
|
88109
|
-
cookedStrings.push(createTemplateCooked(template.head));
|
|
88110
|
-
rawStrings.push(getRawLiteral(template.head, currentSourceFile));
|
|
88168
|
+
cookedStrings.push(createTemplateCooked(factory2, template.head));
|
|
88169
|
+
rawStrings.push(getRawLiteral(factory2, template.head, currentSourceFile));
|
|
88111
88170
|
for (const templateSpan of template.templateSpans) {
|
|
88112
|
-
cookedStrings.push(createTemplateCooked(templateSpan.literal));
|
|
88113
|
-
rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
|
|
88171
|
+
cookedStrings.push(createTemplateCooked(factory2, templateSpan.literal));
|
|
88172
|
+
rawStrings.push(getRawLiteral(factory2, templateSpan.literal, currentSourceFile));
|
|
88114
88173
|
templateArguments.push(Debug.checkDefined(visitNode(templateSpan.expression, visitor, isExpression)));
|
|
88115
88174
|
}
|
|
88116
88175
|
}
|
|
88117
88176
|
const helperCall = context.getEmitHelperFactory().createTemplateObjectHelper(
|
|
88118
|
-
|
|
88119
|
-
|
|
88177
|
+
factory2.createArrayLiteralExpression(cookedStrings),
|
|
88178
|
+
factory2.createArrayLiteralExpression(rawStrings)
|
|
88120
88179
|
);
|
|
88121
88180
|
if (isExternalModule(currentSourceFile)) {
|
|
88122
|
-
const tempVar =
|
|
88181
|
+
const tempVar = factory2.createUniqueName("templateObject");
|
|
88123
88182
|
recordTaggedTemplateString(tempVar);
|
|
88124
|
-
templateArguments[0] =
|
|
88183
|
+
templateArguments[0] = factory2.createLogicalOr(
|
|
88125
88184
|
tempVar,
|
|
88126
|
-
|
|
88185
|
+
factory2.createAssignment(
|
|
88127
88186
|
tempVar,
|
|
88128
88187
|
helperCall
|
|
88129
88188
|
)
|
|
@@ -88131,17 +88190,17 @@ ${lanes.join("\n")}
|
|
|
88131
88190
|
} else {
|
|
88132
88191
|
templateArguments[0] = helperCall;
|
|
88133
88192
|
}
|
|
88134
|
-
return
|
|
88193
|
+
return factory2.createCallExpression(
|
|
88135
88194
|
tag,
|
|
88136
88195
|
/*typeArguments*/
|
|
88137
88196
|
void 0,
|
|
88138
88197
|
templateArguments
|
|
88139
88198
|
);
|
|
88140
88199
|
}
|
|
88141
|
-
function createTemplateCooked(template) {
|
|
88142
|
-
return template.templateFlags ?
|
|
88200
|
+
function createTemplateCooked(factory2, template) {
|
|
88201
|
+
return template.templateFlags ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
|
|
88143
88202
|
}
|
|
88144
|
-
function getRawLiteral(node, currentSourceFile) {
|
|
88203
|
+
function getRawLiteral(factory2, node, currentSourceFile) {
|
|
88145
88204
|
let text = node.rawText;
|
|
88146
88205
|
if (text === void 0) {
|
|
88147
88206
|
Debug.assertIsDefined(
|
|
@@ -88153,7 +88212,7 @@ ${lanes.join("\n")}
|
|
|
88153
88212
|
text = text.substring(1, text.length - (isLast ? 1 : 2));
|
|
88154
88213
|
}
|
|
88155
88214
|
text = text.replace(/\r\n?/g, "\n");
|
|
88156
|
-
return setTextRange(
|
|
88215
|
+
return setTextRange(factory2.createStringLiteral(text), node);
|
|
88157
88216
|
}
|
|
88158
88217
|
var ProcessLevel;
|
|
88159
88218
|
var init_taggedTemplate = __esm({
|
|
@@ -91628,12 +91687,14 @@ ${lanes.join("\n")}
|
|
|
91628
91687
|
if (privateIdentifierInfo.kind === "f" /* Field */) {
|
|
91629
91688
|
if (!privateIdentifierInfo.isStatic) {
|
|
91630
91689
|
return createPrivateInstanceFieldInitializer(
|
|
91690
|
+
factory2,
|
|
91631
91691
|
receiver,
|
|
91632
91692
|
visitNode(property.initializer, initializerVisitor, isExpression),
|
|
91633
91693
|
privateIdentifierInfo.brandCheckIdentifier
|
|
91634
91694
|
);
|
|
91635
91695
|
} else {
|
|
91636
91696
|
return createPrivateStaticFieldInitializer(
|
|
91697
|
+
factory2,
|
|
91637
91698
|
privateIdentifierInfo.variableName,
|
|
91638
91699
|
visitNode(property.initializer, initializerVisitor, isExpression)
|
|
91639
91700
|
);
|
|
@@ -91715,7 +91776,7 @@ ${lanes.join("\n")}
|
|
|
91715
91776
|
Debug.assert(weakSetName, "weakSetName should be set in private identifier environment");
|
|
91716
91777
|
statements.push(
|
|
91717
91778
|
factory2.createExpressionStatement(
|
|
91718
|
-
createPrivateInstanceMethodInitializer(receiver, weakSetName)
|
|
91779
|
+
createPrivateInstanceMethodInitializer(factory2, receiver, weakSetName)
|
|
91719
91780
|
)
|
|
91720
91781
|
);
|
|
91721
91782
|
}
|
|
@@ -92168,25 +92229,25 @@ ${lanes.join("\n")}
|
|
|
92168
92229
|
return void 0;
|
|
92169
92230
|
}
|
|
92170
92231
|
}
|
|
92171
|
-
function createPrivateStaticFieldInitializer(variableName, initializer) {
|
|
92172
|
-
return
|
|
92232
|
+
function createPrivateStaticFieldInitializer(factory2, variableName, initializer) {
|
|
92233
|
+
return factory2.createAssignment(
|
|
92173
92234
|
variableName,
|
|
92174
|
-
|
|
92175
|
-
|
|
92235
|
+
factory2.createObjectLiteralExpression([
|
|
92236
|
+
factory2.createPropertyAssignment("value", initializer || factory2.createVoidZero())
|
|
92176
92237
|
])
|
|
92177
92238
|
);
|
|
92178
92239
|
}
|
|
92179
|
-
function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
|
|
92180
|
-
return
|
|
92181
|
-
|
|
92240
|
+
function createPrivateInstanceFieldInitializer(factory2, receiver, initializer, weakMapName) {
|
|
92241
|
+
return factory2.createCallExpression(
|
|
92242
|
+
factory2.createPropertyAccessExpression(weakMapName, "set"),
|
|
92182
92243
|
/*typeArguments*/
|
|
92183
92244
|
void 0,
|
|
92184
|
-
[receiver, initializer ||
|
|
92245
|
+
[receiver, initializer || factory2.createVoidZero()]
|
|
92185
92246
|
);
|
|
92186
92247
|
}
|
|
92187
|
-
function createPrivateInstanceMethodInitializer(receiver, weakSetName) {
|
|
92188
|
-
return
|
|
92189
|
-
|
|
92248
|
+
function createPrivateInstanceMethodInitializer(factory2, receiver, weakSetName) {
|
|
92249
|
+
return factory2.createCallExpression(
|
|
92250
|
+
factory2.createPropertyAccessExpression(weakSetName, "add"),
|
|
92190
92251
|
/*typeArguments*/
|
|
92191
92252
|
void 0,
|
|
92192
92253
|
[receiver]
|
|
@@ -92208,6 +92269,7 @@ ${lanes.join("\n")}
|
|
|
92208
92269
|
// src/compiler/transformers/typeSerializer.ts
|
|
92209
92270
|
function createRuntimeTypeSerializer(context) {
|
|
92210
92271
|
const {
|
|
92272
|
+
factory: factory2,
|
|
92211
92273
|
hoistVariableDeclaration
|
|
92212
92274
|
} = context;
|
|
92213
92275
|
const resolver = context.getEmitResolver();
|
|
@@ -92247,9 +92309,9 @@ ${lanes.join("\n")}
|
|
|
92247
92309
|
case 260 /* ClassDeclaration */:
|
|
92248
92310
|
case 228 /* ClassExpression */:
|
|
92249
92311
|
case 171 /* MethodDeclaration */:
|
|
92250
|
-
return
|
|
92312
|
+
return factory2.createIdentifier("Function");
|
|
92251
92313
|
default:
|
|
92252
|
-
return
|
|
92314
|
+
return factory2.createVoidZero();
|
|
92253
92315
|
}
|
|
92254
92316
|
}
|
|
92255
92317
|
function serializeParameterTypesOfNode(node, container) {
|
|
@@ -92270,7 +92332,7 @@ ${lanes.join("\n")}
|
|
|
92270
92332
|
}
|
|
92271
92333
|
}
|
|
92272
92334
|
}
|
|
92273
|
-
return
|
|
92335
|
+
return factory2.createArrayLiteralExpression(expressions);
|
|
92274
92336
|
}
|
|
92275
92337
|
function getParametersOfDecoratedDeclaration(node, container) {
|
|
92276
92338
|
if (container && node.kind === 174 /* GetAccessor */) {
|
|
@@ -92285,39 +92347,39 @@ ${lanes.join("\n")}
|
|
|
92285
92347
|
if (isFunctionLike(node) && node.type) {
|
|
92286
92348
|
return serializeTypeNode(node.type);
|
|
92287
92349
|
} else if (isAsyncFunction(node)) {
|
|
92288
|
-
return
|
|
92350
|
+
return factory2.createIdentifier("Promise");
|
|
92289
92351
|
}
|
|
92290
|
-
return
|
|
92352
|
+
return factory2.createVoidZero();
|
|
92291
92353
|
}
|
|
92292
92354
|
function serializeTypeNode(node) {
|
|
92293
92355
|
if (node === void 0) {
|
|
92294
|
-
return
|
|
92356
|
+
return factory2.createIdentifier("Object");
|
|
92295
92357
|
}
|
|
92296
92358
|
node = skipTypeParentheses(node);
|
|
92297
92359
|
switch (node.kind) {
|
|
92298
92360
|
case 114 /* VoidKeyword */:
|
|
92299
92361
|
case 155 /* UndefinedKeyword */:
|
|
92300
92362
|
case 144 /* NeverKeyword */:
|
|
92301
|
-
return
|
|
92363
|
+
return factory2.createVoidZero();
|
|
92302
92364
|
case 181 /* FunctionType */:
|
|
92303
92365
|
case 182 /* ConstructorType */:
|
|
92304
|
-
return
|
|
92366
|
+
return factory2.createIdentifier("Function");
|
|
92305
92367
|
case 185 /* ArrayType */:
|
|
92306
92368
|
case 186 /* TupleType */:
|
|
92307
|
-
return
|
|
92369
|
+
return factory2.createIdentifier("Array");
|
|
92308
92370
|
case 179 /* TypePredicate */:
|
|
92309
|
-
return node.assertsModifier ?
|
|
92371
|
+
return node.assertsModifier ? factory2.createVoidZero() : factory2.createIdentifier("Boolean");
|
|
92310
92372
|
case 134 /* BooleanKeyword */:
|
|
92311
|
-
return
|
|
92373
|
+
return factory2.createIdentifier("Boolean");
|
|
92312
92374
|
case 200 /* TemplateLiteralType */:
|
|
92313
92375
|
case 152 /* StringKeyword */:
|
|
92314
|
-
return
|
|
92376
|
+
return factory2.createIdentifier("String");
|
|
92315
92377
|
case 149 /* ObjectKeyword */:
|
|
92316
|
-
return
|
|
92378
|
+
return factory2.createIdentifier("Object");
|
|
92317
92379
|
case 198 /* LiteralType */:
|
|
92318
92380
|
return serializeLiteralOfLiteralTypeNode(node.literal);
|
|
92319
92381
|
case 148 /* NumberKeyword */:
|
|
92320
|
-
return
|
|
92382
|
+
return factory2.createIdentifier("Number");
|
|
92321
92383
|
case 160 /* BigIntKeyword */:
|
|
92322
92384
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92323
92385
|
case 153 /* SymbolKeyword */:
|
|
@@ -92369,13 +92431,13 @@ ${lanes.join("\n")}
|
|
|
92369
92431
|
default:
|
|
92370
92432
|
return Debug.failBadSyntaxKind(node);
|
|
92371
92433
|
}
|
|
92372
|
-
return
|
|
92434
|
+
return factory2.createIdentifier("Object");
|
|
92373
92435
|
}
|
|
92374
92436
|
function serializeLiteralOfLiteralTypeNode(node) {
|
|
92375
92437
|
switch (node.kind) {
|
|
92376
92438
|
case 10 /* StringLiteral */:
|
|
92377
92439
|
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
92378
|
-
return
|
|
92440
|
+
return factory2.createIdentifier("String");
|
|
92379
92441
|
case 221 /* PrefixUnaryExpression */: {
|
|
92380
92442
|
const operand = node.operand;
|
|
92381
92443
|
switch (operand.kind) {
|
|
@@ -92387,14 +92449,14 @@ ${lanes.join("\n")}
|
|
|
92387
92449
|
}
|
|
92388
92450
|
}
|
|
92389
92451
|
case 8 /* NumericLiteral */:
|
|
92390
|
-
return
|
|
92452
|
+
return factory2.createIdentifier("Number");
|
|
92391
92453
|
case 9 /* BigIntLiteral */:
|
|
92392
92454
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92393
92455
|
case 110 /* TrueKeyword */:
|
|
92394
92456
|
case 95 /* FalseKeyword */:
|
|
92395
|
-
return
|
|
92457
|
+
return factory2.createIdentifier("Boolean");
|
|
92396
92458
|
case 104 /* NullKeyword */:
|
|
92397
|
-
return
|
|
92459
|
+
return factory2.createVoidZero();
|
|
92398
92460
|
default:
|
|
92399
92461
|
return Debug.failBadSyntaxKind(node);
|
|
92400
92462
|
}
|
|
@@ -92405,16 +92467,16 @@ ${lanes.join("\n")}
|
|
|
92405
92467
|
typeNode = skipTypeParentheses(typeNode);
|
|
92406
92468
|
if (typeNode.kind === 144 /* NeverKeyword */) {
|
|
92407
92469
|
if (isIntersection)
|
|
92408
|
-
return
|
|
92470
|
+
return factory2.createVoidZero();
|
|
92409
92471
|
continue;
|
|
92410
92472
|
}
|
|
92411
92473
|
if (typeNode.kind === 157 /* UnknownKeyword */) {
|
|
92412
92474
|
if (!isIntersection)
|
|
92413
|
-
return
|
|
92475
|
+
return factory2.createIdentifier("Object");
|
|
92414
92476
|
continue;
|
|
92415
92477
|
}
|
|
92416
92478
|
if (typeNode.kind === 131 /* AnyKeyword */) {
|
|
92417
|
-
return
|
|
92479
|
+
return factory2.createIdentifier("Object");
|
|
92418
92480
|
}
|
|
92419
92481
|
if (!strictNullChecks && (isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 155 /* UndefinedKeyword */)) {
|
|
92420
92482
|
continue;
|
|
@@ -92425,13 +92487,13 @@ ${lanes.join("\n")}
|
|
|
92425
92487
|
}
|
|
92426
92488
|
if (serializedType) {
|
|
92427
92489
|
if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
|
|
92428
|
-
return
|
|
92490
|
+
return factory2.createIdentifier("Object");
|
|
92429
92491
|
}
|
|
92430
92492
|
} else {
|
|
92431
92493
|
serializedType = serializedConstituent;
|
|
92432
92494
|
}
|
|
92433
92495
|
}
|
|
92434
|
-
return serializedType != null ? serializedType :
|
|
92496
|
+
return serializedType != null ? serializedType : factory2.createVoidZero();
|
|
92435
92497
|
}
|
|
92436
92498
|
function equateSerializedTypeNodes(left, right) {
|
|
92437
92499
|
return (
|
|
@@ -92465,48 +92527,48 @@ ${lanes.join("\n")}
|
|
|
92465
92527
|
switch (kind) {
|
|
92466
92528
|
case 0 /* Unknown */:
|
|
92467
92529
|
if (findAncestor(node, (n) => n.parent && isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n))) {
|
|
92468
|
-
return
|
|
92530
|
+
return factory2.createIdentifier("Object");
|
|
92469
92531
|
}
|
|
92470
92532
|
const serialized = serializeEntityNameAsExpressionFallback(node.typeName);
|
|
92471
|
-
const temp =
|
|
92472
|
-
return
|
|
92473
|
-
|
|
92533
|
+
const temp = factory2.createTempVariable(hoistVariableDeclaration);
|
|
92534
|
+
return factory2.createConditionalExpression(
|
|
92535
|
+
factory2.createTypeCheck(factory2.createAssignment(temp, serialized), "function"),
|
|
92474
92536
|
/*questionToken*/
|
|
92475
92537
|
void 0,
|
|
92476
92538
|
temp,
|
|
92477
92539
|
/*colonToken*/
|
|
92478
92540
|
void 0,
|
|
92479
|
-
|
|
92541
|
+
factory2.createIdentifier("Object")
|
|
92480
92542
|
);
|
|
92481
92543
|
case 1 /* TypeWithConstructSignatureAndValue */:
|
|
92482
92544
|
return serializeEntityNameAsExpression(node.typeName);
|
|
92483
92545
|
case 2 /* VoidNullableOrNeverType */:
|
|
92484
|
-
return
|
|
92546
|
+
return factory2.createVoidZero();
|
|
92485
92547
|
case 4 /* BigIntLikeType */:
|
|
92486
92548
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92487
92549
|
case 6 /* BooleanType */:
|
|
92488
|
-
return
|
|
92550
|
+
return factory2.createIdentifier("Boolean");
|
|
92489
92551
|
case 3 /* NumberLikeType */:
|
|
92490
|
-
return
|
|
92552
|
+
return factory2.createIdentifier("Number");
|
|
92491
92553
|
case 5 /* StringLikeType */:
|
|
92492
|
-
return
|
|
92554
|
+
return factory2.createIdentifier("String");
|
|
92493
92555
|
case 7 /* ArrayLikeType */:
|
|
92494
|
-
return
|
|
92556
|
+
return factory2.createIdentifier("Array");
|
|
92495
92557
|
case 8 /* ESSymbolType */:
|
|
92496
92558
|
return getGlobalConstructor("Symbol", 2 /* ES2015 */);
|
|
92497
92559
|
case 10 /* TypeWithCallSignature */:
|
|
92498
|
-
return
|
|
92560
|
+
return factory2.createIdentifier("Function");
|
|
92499
92561
|
case 9 /* Promise */:
|
|
92500
|
-
return
|
|
92562
|
+
return factory2.createIdentifier("Promise");
|
|
92501
92563
|
case 11 /* ObjectType */:
|
|
92502
|
-
return
|
|
92564
|
+
return factory2.createIdentifier("Object");
|
|
92503
92565
|
default:
|
|
92504
92566
|
return Debug.assertNever(kind);
|
|
92505
92567
|
}
|
|
92506
92568
|
}
|
|
92507
92569
|
function createCheckedValue(left, right) {
|
|
92508
|
-
return
|
|
92509
|
-
|
|
92570
|
+
return factory2.createLogicalAnd(
|
|
92571
|
+
factory2.createStrictInequality(factory2.createTypeOfExpression(left), factory2.createStringLiteral("undefined")),
|
|
92510
92572
|
right
|
|
92511
92573
|
);
|
|
92512
92574
|
}
|
|
@@ -92519,13 +92581,13 @@ ${lanes.join("\n")}
|
|
|
92519
92581
|
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
|
|
92520
92582
|
}
|
|
92521
92583
|
const left = serializeEntityNameAsExpressionFallback(node.left);
|
|
92522
|
-
const temp =
|
|
92523
|
-
return
|
|
92524
|
-
|
|
92584
|
+
const temp = factory2.createTempVariable(hoistVariableDeclaration);
|
|
92585
|
+
return factory2.createLogicalAnd(
|
|
92586
|
+
factory2.createLogicalAnd(
|
|
92525
92587
|
left.left,
|
|
92526
|
-
|
|
92588
|
+
factory2.createStrictInequality(factory2.createAssignment(temp, left.right), factory2.createVoidZero())
|
|
92527
92589
|
),
|
|
92528
|
-
|
|
92590
|
+
factory2.createPropertyAccessExpression(temp, node.right)
|
|
92529
92591
|
);
|
|
92530
92592
|
}
|
|
92531
92593
|
function serializeEntityNameAsExpression(node) {
|
|
@@ -92540,21 +92602,21 @@ ${lanes.join("\n")}
|
|
|
92540
92602
|
}
|
|
92541
92603
|
}
|
|
92542
92604
|
function serializeQualifiedNameAsExpression(node) {
|
|
92543
|
-
return
|
|
92605
|
+
return factory2.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
|
|
92544
92606
|
}
|
|
92545
92607
|
function getGlobalConstructorWithFallback(name) {
|
|
92546
|
-
return
|
|
92547
|
-
|
|
92608
|
+
return factory2.createConditionalExpression(
|
|
92609
|
+
factory2.createTypeCheck(factory2.createIdentifier(name), "function"),
|
|
92548
92610
|
/*questionToken*/
|
|
92549
92611
|
void 0,
|
|
92550
|
-
|
|
92612
|
+
factory2.createIdentifier(name),
|
|
92551
92613
|
/*colonToken*/
|
|
92552
92614
|
void 0,
|
|
92553
|
-
|
|
92615
|
+
factory2.createIdentifier("Object")
|
|
92554
92616
|
);
|
|
92555
92617
|
}
|
|
92556
92618
|
function getGlobalConstructor(name, minLanguageVersion) {
|
|
92557
|
-
return languageVersion < minLanguageVersion ? getGlobalConstructorWithFallback(name) :
|
|
92619
|
+
return languageVersion < minLanguageVersion ? getGlobalConstructorWithFallback(name) : factory2.createIdentifier(name);
|
|
92558
92620
|
}
|
|
92559
92621
|
}
|
|
92560
92622
|
var init_typeSerializer = __esm({
|
|
@@ -107500,7 +107562,7 @@ ${lanes.join("\n")}
|
|
|
107500
107562
|
}
|
|
107501
107563
|
const newParam = factory2.updateParameterDeclaration(
|
|
107502
107564
|
p,
|
|
107503
|
-
maskModifiers(p, modifierMask),
|
|
107565
|
+
maskModifiers(factory2, p, modifierMask),
|
|
107504
107566
|
p.dotDotDotToken,
|
|
107505
107567
|
filterBindingPatternInitializersAndRenamings(p.name),
|
|
107506
107568
|
resolver.isOptionalParameter(p) ? p.questionToken || factory2.createToken(57 /* QuestionToken */) : void 0,
|
|
@@ -108614,8 +108676,8 @@ ${lanes.join("\n")}
|
|
|
108614
108676
|
}
|
|
108615
108677
|
return false;
|
|
108616
108678
|
}
|
|
108617
|
-
function maskModifiers(node, modifierMask, modifierAdditions) {
|
|
108618
|
-
return
|
|
108679
|
+
function maskModifiers(factory2, node, modifierMask, modifierAdditions) {
|
|
108680
|
+
return factory2.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
|
|
108619
108681
|
}
|
|
108620
108682
|
function maskModifierFlags(node, modifierMask = 258047 /* All */ ^ 4 /* Public */, modifierAdditions = 0 /* None */) {
|
|
108621
108683
|
let flags = getEffectiveModifierFlags(node) & modifierMask | modifierAdditions;
|
|
@@ -121571,7 +121633,7 @@ ${lanes.join("\n")}
|
|
|
121571
121633
|
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
121572
121634
|
}
|
|
121573
121635
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
121574
|
-
return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
121636
|
+
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
121575
121637
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
121576
121638
|
if (cachedDirectoryStructureHost) {
|
|
121577
121639
|
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
|
@@ -121582,7 +121644,7 @@ ${lanes.join("\n")}
|
|
|
121582
121644
|
if (dirPath) {
|
|
121583
121645
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
121584
121646
|
}
|
|
121585
|
-
}, 1 /* Recursive */);
|
|
121647
|
+
}, 1 /* Recursive */) : noopFileWatcher;
|
|
121586
121648
|
}
|
|
121587
121649
|
function updateTypeRootsWatch() {
|
|
121588
121650
|
const options = resolutionHost.getCompilationSettings();
|
|
@@ -121590,7 +121652,7 @@ ${lanes.join("\n")}
|
|
|
121590
121652
|
closeTypeRootsWatch();
|
|
121591
121653
|
return;
|
|
121592
121654
|
}
|
|
121593
|
-
const typeRoots = getEffectiveTypeRoots(options, {
|
|
121655
|
+
const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
|
|
121594
121656
|
if (typeRoots) {
|
|
121595
121657
|
mutateMap(
|
|
121596
121658
|
typeRootsWatches,
|
|
@@ -121604,7 +121666,9 @@ ${lanes.join("\n")}
|
|
|
121604
121666
|
closeTypeRootsWatch();
|
|
121605
121667
|
}
|
|
121606
121668
|
}
|
|
121607
|
-
function
|
|
121669
|
+
function canWatchTypeRootPath(nodeTypesDirectory) {
|
|
121670
|
+
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
121671
|
+
return true;
|
|
121608
121672
|
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
|
121609
121673
|
const dirPath = resolutionHost.toPath(dir);
|
|
121610
121674
|
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
@@ -131647,6 +131711,10 @@ ${lanes.join("\n")}
|
|
|
131647
131711
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
131648
131712
|
}
|
|
131649
131713
|
}
|
|
131714
|
+
const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
|
|
131715
|
+
if (jsdocTypedefNode) {
|
|
131716
|
+
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
131717
|
+
}
|
|
131650
131718
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
131651
131719
|
diags.push(createDiagnosticForNode(node.name || node, Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types));
|
|
131652
131720
|
}
|
|
@@ -133462,18 +133530,6 @@ ${lanes.join("\n")}
|
|
|
133462
133530
|
synchronizeHostData();
|
|
133463
133531
|
return ts_FindAllReferences_exports.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
133464
133532
|
}
|
|
133465
|
-
function getOccurrencesAtPosition(fileName, position) {
|
|
133466
|
-
return flatMap(
|
|
133467
|
-
getDocumentHighlights(fileName, position, [fileName]),
|
|
133468
|
-
(entry) => entry.highlightSpans.map((highlightSpan) => ({
|
|
133469
|
-
fileName: entry.fileName,
|
|
133470
|
-
textSpan: highlightSpan.textSpan,
|
|
133471
|
-
isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */,
|
|
133472
|
-
...highlightSpan.isInString && { isInString: true },
|
|
133473
|
-
...highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan }
|
|
133474
|
-
}))
|
|
133475
|
-
);
|
|
133476
|
-
}
|
|
133477
133533
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
133478
133534
|
const normalizedFileName = normalizePath(fileName);
|
|
133479
133535
|
Debug.assert(filesToSearch.some((f) => normalizePath(f) === normalizedFileName));
|
|
@@ -133666,22 +133722,22 @@ ${lanes.join("\n")}
|
|
|
133666
133722
|
}
|
|
133667
133723
|
return [];
|
|
133668
133724
|
}
|
|
133669
|
-
function getCodeFixesAtPosition(fileName, start, end,
|
|
133725
|
+
function getCodeFixesAtPosition(fileName, start, end, errorCodes64, formatOptions, preferences = emptyOptions) {
|
|
133670
133726
|
synchronizeHostData();
|
|
133671
133727
|
const sourceFile = getValidSourceFile(fileName);
|
|
133672
133728
|
const span = createTextSpanFromBounds(start, end);
|
|
133673
133729
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
133674
|
-
return flatMap(deduplicate(
|
|
133730
|
+
return flatMap(deduplicate(errorCodes64, equateValues, compareValues), (errorCode) => {
|
|
133675
133731
|
cancellationToken.throwIfCancellationRequested();
|
|
133676
133732
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
133677
133733
|
});
|
|
133678
133734
|
}
|
|
133679
|
-
function getCombinedCodeFix(scope,
|
|
133735
|
+
function getCombinedCodeFix(scope, fixId52, formatOptions, preferences = emptyOptions) {
|
|
133680
133736
|
synchronizeHostData();
|
|
133681
133737
|
Debug.assert(scope.type === "file");
|
|
133682
133738
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
133683
133739
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
133684
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
133740
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId52, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
133685
133741
|
}
|
|
133686
133742
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
133687
133743
|
var _a3;
|
|
@@ -134103,7 +134159,6 @@ ${lanes.join("\n")}
|
|
|
134103
134159
|
getReferencesAtPosition,
|
|
134104
134160
|
findReferences,
|
|
134105
134161
|
getFileReferences,
|
|
134106
|
-
getOccurrencesAtPosition,
|
|
134107
134162
|
getDocumentHighlights,
|
|
134108
134163
|
getNameOrDottedNameSpan,
|
|
134109
134164
|
getBreakpointStatementAtPosition,
|
|
@@ -134929,7 +134984,6 @@ ${lanes.join("\n")}
|
|
|
134929
134984
|
"getTypeDefinitionAtPosition",
|
|
134930
134985
|
"getReferencesAtPosition",
|
|
134931
134986
|
"findReferences",
|
|
134932
|
-
"getOccurrencesAtPosition",
|
|
134933
134987
|
"getDocumentHighlights",
|
|
134934
134988
|
"getNavigateToItems",
|
|
134935
134989
|
"getRenameInfo",
|
|
@@ -135513,12 +135567,6 @@ ${lanes.join("\n")}
|
|
|
135513
135567
|
() => this.languageService.getFileReferences(fileName)
|
|
135514
135568
|
);
|
|
135515
135569
|
}
|
|
135516
|
-
getOccurrencesAtPosition(fileName, position) {
|
|
135517
|
-
return this.forwardJSONCall(
|
|
135518
|
-
`getOccurrencesAtPosition('${fileName}', ${position})`,
|
|
135519
|
-
() => this.languageService.getOccurrencesAtPosition(fileName, position)
|
|
135520
|
-
);
|
|
135521
|
-
}
|
|
135522
135570
|
getDocumentHighlights(fileName, position, filesToSearch) {
|
|
135523
135571
|
return this.forwardJSONCall(
|
|
135524
135572
|
`getDocumentHighlights('${fileName}', ${position})`,
|
|
@@ -137152,23 +137200,23 @@ ${lanes.join("\n")}
|
|
|
137152
137200
|
void 0
|
|
137153
137201
|
);
|
|
137154
137202
|
}
|
|
137155
|
-
function createCodeFixAction(fixName8, changes, description2,
|
|
137156
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
137203
|
+
function createCodeFixAction(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
137204
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, diagnosticToString(fixAllDescription), command);
|
|
137157
137205
|
}
|
|
137158
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description2,
|
|
137159
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
137206
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
137207
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
137160
137208
|
}
|
|
137161
|
-
function createCodeFixActionWorker(fixName8, description2, changes,
|
|
137162
|
-
return { fixName: fixName8, description: description2, changes, fixId:
|
|
137209
|
+
function createCodeFixActionWorker(fixName8, description2, changes, fixId52, fixAllDescription, command) {
|
|
137210
|
+
return { fixName: fixName8, description: description2, changes, fixId: fixId52, fixAllDescription, commands: command ? [command] : void 0 };
|
|
137163
137211
|
}
|
|
137164
137212
|
function registerCodeFix(reg) {
|
|
137165
137213
|
for (const error of reg.errorCodes) {
|
|
137166
137214
|
errorCodeToFixes.add(String(error), reg);
|
|
137167
137215
|
}
|
|
137168
137216
|
if (reg.fixIds) {
|
|
137169
|
-
for (const
|
|
137170
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
137171
|
-
fixIdToRegistration.set(
|
|
137217
|
+
for (const fixId52 of reg.fixIds) {
|
|
137218
|
+
Debug.assert(!fixIdToRegistration.has(fixId52));
|
|
137219
|
+
fixIdToRegistration.set(fixId52, reg);
|
|
137172
137220
|
}
|
|
137173
137221
|
}
|
|
137174
137222
|
}
|
|
@@ -137176,17 +137224,17 @@ ${lanes.join("\n")}
|
|
|
137176
137224
|
return arrayFrom(errorCodeToFixes.keys());
|
|
137177
137225
|
}
|
|
137178
137226
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
137179
|
-
const { errorCodes:
|
|
137227
|
+
const { errorCodes: errorCodes64 } = registration;
|
|
137180
137228
|
let maybeFixableDiagnostics = 0;
|
|
137181
137229
|
for (const diag2 of diagnostics) {
|
|
137182
|
-
if (contains(
|
|
137230
|
+
if (contains(errorCodes64, diag2.code))
|
|
137183
137231
|
maybeFixableDiagnostics++;
|
|
137184
137232
|
if (maybeFixableDiagnostics > 1)
|
|
137185
137233
|
break;
|
|
137186
137234
|
}
|
|
137187
137235
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
137188
|
-
return ({ fixId:
|
|
137189
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
137236
|
+
return ({ fixId: fixId52, fixAllDescription, ...action }) => {
|
|
137237
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId52, fixAllDescription };
|
|
137190
137238
|
};
|
|
137191
137239
|
}
|
|
137192
137240
|
function getFixes(context) {
|
|
@@ -137203,14 +137251,14 @@ ${lanes.join("\n")}
|
|
|
137203
137251
|
function createFileTextChanges(fileName, textChanges2) {
|
|
137204
137252
|
return { fileName, textChanges: textChanges2 };
|
|
137205
137253
|
}
|
|
137206
|
-
function codeFixAll(context,
|
|
137254
|
+
function codeFixAll(context, errorCodes64, use) {
|
|
137207
137255
|
const commands = [];
|
|
137208
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
137256
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes64, (diag2) => use(t, diag2, commands)));
|
|
137209
137257
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
137210
137258
|
}
|
|
137211
|
-
function eachDiagnostic(context,
|
|
137259
|
+
function eachDiagnostic(context, errorCodes64, cb) {
|
|
137212
137260
|
for (const diag2 of getDiagnostics(context)) {
|
|
137213
|
-
if (contains(
|
|
137261
|
+
if (contains(errorCodes64, diag2.code)) {
|
|
137214
137262
|
cb(diag2);
|
|
137215
137263
|
}
|
|
137216
137264
|
}
|
|
@@ -139792,32 +139840,96 @@ ${lanes.join("\n")}
|
|
|
139792
139840
|
});
|
|
139793
139841
|
|
|
139794
139842
|
// src/services/codefixes/convertToTypeOnlyImport.ts
|
|
139795
|
-
function
|
|
139796
|
-
|
|
139843
|
+
function getDeclaration2(sourceFile, pos) {
|
|
139844
|
+
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
139845
|
+
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
139797
139846
|
}
|
|
139798
|
-
function
|
|
139799
|
-
if (
|
|
139800
|
-
|
|
139801
|
-
|
|
139802
|
-
|
|
139803
|
-
|
|
139804
|
-
|
|
139805
|
-
|
|
139806
|
-
changes.insertNodeBefore(context.sourceFile, importDeclaration, factory.updateImportDeclaration(
|
|
139807
|
-
importDeclaration,
|
|
139808
|
-
/*modifiers*/
|
|
139809
|
-
void 0,
|
|
139810
|
-
factory.createImportClause(
|
|
139811
|
-
/*isTypeOnly*/
|
|
139812
|
-
true,
|
|
139813
|
-
importClause.name,
|
|
139814
|
-
/*namedBindings*/
|
|
139815
|
-
void 0
|
|
139816
|
-
),
|
|
139817
|
-
importDeclaration.moduleSpecifier,
|
|
139818
|
-
/*assertClause*/
|
|
139819
|
-
void 0
|
|
139847
|
+
function doChange4(changes, sourceFile, declaration) {
|
|
139848
|
+
if (isImportSpecifier(declaration)) {
|
|
139849
|
+
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
139850
|
+
declaration,
|
|
139851
|
+
/*isTypeOnly*/
|
|
139852
|
+
true,
|
|
139853
|
+
declaration.propertyName,
|
|
139854
|
+
declaration.name
|
|
139820
139855
|
));
|
|
139856
|
+
} else {
|
|
139857
|
+
const importClause = declaration.importClause;
|
|
139858
|
+
if (importClause.name && importClause.namedBindings) {
|
|
139859
|
+
changes.replaceNodeWithNodes(sourceFile, declaration, [
|
|
139860
|
+
factory.createImportDeclaration(
|
|
139861
|
+
getSynthesizedDeepClones(
|
|
139862
|
+
declaration.modifiers,
|
|
139863
|
+
/*includeTrivia*/
|
|
139864
|
+
true
|
|
139865
|
+
),
|
|
139866
|
+
factory.createImportClause(
|
|
139867
|
+
/*isTypeOnly*/
|
|
139868
|
+
true,
|
|
139869
|
+
getSynthesizedDeepClone(
|
|
139870
|
+
importClause.name,
|
|
139871
|
+
/*includeTrivia*/
|
|
139872
|
+
true
|
|
139873
|
+
),
|
|
139874
|
+
/*namedBindings*/
|
|
139875
|
+
void 0
|
|
139876
|
+
),
|
|
139877
|
+
getSynthesizedDeepClone(
|
|
139878
|
+
declaration.moduleSpecifier,
|
|
139879
|
+
/*includeTrivia*/
|
|
139880
|
+
true
|
|
139881
|
+
),
|
|
139882
|
+
getSynthesizedDeepClone(
|
|
139883
|
+
declaration.assertClause,
|
|
139884
|
+
/*includeTrivia*/
|
|
139885
|
+
true
|
|
139886
|
+
)
|
|
139887
|
+
),
|
|
139888
|
+
factory.createImportDeclaration(
|
|
139889
|
+
getSynthesizedDeepClones(
|
|
139890
|
+
declaration.modifiers,
|
|
139891
|
+
/*includeTrivia*/
|
|
139892
|
+
true
|
|
139893
|
+
),
|
|
139894
|
+
factory.createImportClause(
|
|
139895
|
+
/*isTypeOnly*/
|
|
139896
|
+
true,
|
|
139897
|
+
/*name*/
|
|
139898
|
+
void 0,
|
|
139899
|
+
getSynthesizedDeepClone(
|
|
139900
|
+
importClause.namedBindings,
|
|
139901
|
+
/*includeTrivia*/
|
|
139902
|
+
true
|
|
139903
|
+
)
|
|
139904
|
+
),
|
|
139905
|
+
getSynthesizedDeepClone(
|
|
139906
|
+
declaration.moduleSpecifier,
|
|
139907
|
+
/*includeTrivia*/
|
|
139908
|
+
true
|
|
139909
|
+
),
|
|
139910
|
+
getSynthesizedDeepClone(
|
|
139911
|
+
declaration.assertClause,
|
|
139912
|
+
/*includeTrivia*/
|
|
139913
|
+
true
|
|
139914
|
+
)
|
|
139915
|
+
)
|
|
139916
|
+
]);
|
|
139917
|
+
} else {
|
|
139918
|
+
const importDeclaration = factory.updateImportDeclaration(
|
|
139919
|
+
declaration,
|
|
139920
|
+
declaration.modifiers,
|
|
139921
|
+
factory.updateImportClause(
|
|
139922
|
+
importClause,
|
|
139923
|
+
/*isTypeOnly*/
|
|
139924
|
+
true,
|
|
139925
|
+
importClause.name,
|
|
139926
|
+
importClause.namedBindings
|
|
139927
|
+
),
|
|
139928
|
+
declaration.moduleSpecifier,
|
|
139929
|
+
declaration.assertClause
|
|
139930
|
+
);
|
|
139931
|
+
changes.replaceNode(sourceFile, declaration, importDeclaration);
|
|
139932
|
+
}
|
|
139821
139933
|
}
|
|
139822
139934
|
}
|
|
139823
139935
|
var errorCodes14, fixId13;
|
|
@@ -139826,30 +139938,181 @@ ${lanes.join("\n")}
|
|
|
139826
139938
|
"use strict";
|
|
139827
139939
|
init_ts4();
|
|
139828
139940
|
init_ts_codefix();
|
|
139829
|
-
errorCodes14 = [
|
|
139941
|
+
errorCodes14 = [
|
|
139942
|
+
Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error.code,
|
|
139943
|
+
Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code
|
|
139944
|
+
];
|
|
139830
139945
|
fixId13 = "convertToTypeOnlyImport";
|
|
139831
139946
|
registerCodeFix({
|
|
139832
139947
|
errorCodes: errorCodes14,
|
|
139833
139948
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
139834
|
-
const
|
|
139835
|
-
|
|
139836
|
-
|
|
139837
|
-
});
|
|
139838
|
-
if (changes.length) {
|
|
139949
|
+
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
139950
|
+
if (declaration) {
|
|
139951
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(t, context.sourceFile, declaration));
|
|
139839
139952
|
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
139840
139953
|
}
|
|
139954
|
+
return void 0;
|
|
139841
139955
|
},
|
|
139842
139956
|
fixIds: [fixId13],
|
|
139843
139957
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
139844
139958
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
139845
|
-
const
|
|
139846
|
-
|
|
139959
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
139960
|
+
if (declaration) {
|
|
139961
|
+
doChange4(changes, diag2.file, declaration);
|
|
139962
|
+
}
|
|
139847
139963
|
});
|
|
139848
139964
|
}
|
|
139849
139965
|
});
|
|
139850
139966
|
}
|
|
139851
139967
|
});
|
|
139852
139968
|
|
|
139969
|
+
// src/services/codefixes/convertTypedefToType.ts
|
|
139970
|
+
function doChange5(changes, node, sourceFile) {
|
|
139971
|
+
if (isJSDocTypedefTag(node)) {
|
|
139972
|
+
fixSingleTypeDef(changes, node, sourceFile);
|
|
139973
|
+
}
|
|
139974
|
+
}
|
|
139975
|
+
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
139976
|
+
if (!typeDefNode)
|
|
139977
|
+
return;
|
|
139978
|
+
const declaration = createDeclaration(typeDefNode);
|
|
139979
|
+
if (!declaration)
|
|
139980
|
+
return;
|
|
139981
|
+
const comment = typeDefNode.parent;
|
|
139982
|
+
changes.replaceNode(
|
|
139983
|
+
sourceFile,
|
|
139984
|
+
comment,
|
|
139985
|
+
declaration
|
|
139986
|
+
);
|
|
139987
|
+
}
|
|
139988
|
+
function createDeclaration(tag) {
|
|
139989
|
+
var _a2;
|
|
139990
|
+
const { typeExpression } = tag;
|
|
139991
|
+
if (!typeExpression)
|
|
139992
|
+
return;
|
|
139993
|
+
const typeName = (_a2 = tag.name) == null ? void 0 : _a2.getText();
|
|
139994
|
+
if (!typeName)
|
|
139995
|
+
return;
|
|
139996
|
+
if (typeExpression.kind === 325 /* JSDocTypeLiteral */) {
|
|
139997
|
+
return createInterfaceForTypeLiteral(typeName, typeExpression);
|
|
139998
|
+
}
|
|
139999
|
+
if (typeExpression.kind === 312 /* JSDocTypeExpression */) {
|
|
140000
|
+
return createTypeAliasForTypeExpression(typeName, typeExpression);
|
|
140001
|
+
}
|
|
140002
|
+
}
|
|
140003
|
+
function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
140004
|
+
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
140005
|
+
if (!some(propertySignatures))
|
|
140006
|
+
return;
|
|
140007
|
+
const interfaceDeclaration = factory.createInterfaceDeclaration(
|
|
140008
|
+
/*modifiers*/
|
|
140009
|
+
void 0,
|
|
140010
|
+
typeName,
|
|
140011
|
+
/*typeParameters*/
|
|
140012
|
+
void 0,
|
|
140013
|
+
/*heritageClauses*/
|
|
140014
|
+
void 0,
|
|
140015
|
+
propertySignatures
|
|
140016
|
+
);
|
|
140017
|
+
return interfaceDeclaration;
|
|
140018
|
+
}
|
|
140019
|
+
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
140020
|
+
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
140021
|
+
if (!typeReference)
|
|
140022
|
+
return;
|
|
140023
|
+
const declaration = factory.createTypeAliasDeclaration(
|
|
140024
|
+
/*modifiers*/
|
|
140025
|
+
void 0,
|
|
140026
|
+
factory.createIdentifier(typeName),
|
|
140027
|
+
/*typeParameters*/
|
|
140028
|
+
void 0,
|
|
140029
|
+
typeReference
|
|
140030
|
+
);
|
|
140031
|
+
return declaration;
|
|
140032
|
+
}
|
|
140033
|
+
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
140034
|
+
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
140035
|
+
if (!some(propertyTags))
|
|
140036
|
+
return;
|
|
140037
|
+
const getSignature = (tag) => {
|
|
140038
|
+
var _a2;
|
|
140039
|
+
const name = getPropertyName(tag);
|
|
140040
|
+
const type = (_a2 = tag.typeExpression) == null ? void 0 : _a2.type;
|
|
140041
|
+
const isOptional = tag.isBracketed;
|
|
140042
|
+
let typeReference;
|
|
140043
|
+
if (type && isJSDocTypeLiteral(type)) {
|
|
140044
|
+
const signatures = createSignatureFromTypeLiteral(type);
|
|
140045
|
+
typeReference = factory.createTypeLiteralNode(signatures);
|
|
140046
|
+
} else if (type) {
|
|
140047
|
+
typeReference = getSynthesizedDeepClone(type);
|
|
140048
|
+
}
|
|
140049
|
+
if (typeReference && name) {
|
|
140050
|
+
const questionToken = isOptional ? factory.createToken(57 /* QuestionToken */) : void 0;
|
|
140051
|
+
const prop = factory.createPropertySignature(
|
|
140052
|
+
/*modifiers*/
|
|
140053
|
+
void 0,
|
|
140054
|
+
name,
|
|
140055
|
+
questionToken,
|
|
140056
|
+
typeReference
|
|
140057
|
+
);
|
|
140058
|
+
return prop;
|
|
140059
|
+
}
|
|
140060
|
+
};
|
|
140061
|
+
const props = mapDefined(propertyTags, getSignature);
|
|
140062
|
+
return props;
|
|
140063
|
+
}
|
|
140064
|
+
function getPropertyName(tag) {
|
|
140065
|
+
return tag.name.kind === 79 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
140066
|
+
}
|
|
140067
|
+
function getJSDocTypedefNode(node) {
|
|
140068
|
+
if (hasJSDocNodes(node)) {
|
|
140069
|
+
return forEach(node.jsDoc, (node2) => {
|
|
140070
|
+
var _a2;
|
|
140071
|
+
return (_a2 = node2.tags) == null ? void 0 : _a2.find(isJSDocTypedefTag);
|
|
140072
|
+
});
|
|
140073
|
+
}
|
|
140074
|
+
return void 0;
|
|
140075
|
+
}
|
|
140076
|
+
var fixId14, errorCodes15;
|
|
140077
|
+
var init_convertTypedefToType = __esm({
|
|
140078
|
+
"src/services/codefixes/convertTypedefToType.ts"() {
|
|
140079
|
+
"use strict";
|
|
140080
|
+
init_ts4();
|
|
140081
|
+
init_ts_codefix();
|
|
140082
|
+
fixId14 = "convertTypedefToType";
|
|
140083
|
+
errorCodes15 = [Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type.code];
|
|
140084
|
+
registerCodeFix({
|
|
140085
|
+
fixIds: [fixId14],
|
|
140086
|
+
errorCodes: errorCodes15,
|
|
140087
|
+
getCodeActions(context) {
|
|
140088
|
+
const node = getTokenAtPosition(
|
|
140089
|
+
context.sourceFile,
|
|
140090
|
+
context.span.start
|
|
140091
|
+
);
|
|
140092
|
+
if (!node)
|
|
140093
|
+
return;
|
|
140094
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange5(t, node, context.sourceFile));
|
|
140095
|
+
if (changes.length > 0) {
|
|
140096
|
+
return [
|
|
140097
|
+
createCodeFixAction(
|
|
140098
|
+
fixId14,
|
|
140099
|
+
changes,
|
|
140100
|
+
Diagnostics.Convert_typedef_to_TypeScript_type,
|
|
140101
|
+
fixId14,
|
|
140102
|
+
Diagnostics.Convert_all_typedef_to_TypeScript_types
|
|
140103
|
+
)
|
|
140104
|
+
];
|
|
140105
|
+
}
|
|
140106
|
+
},
|
|
140107
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
|
|
140108
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
140109
|
+
if (node)
|
|
140110
|
+
doChange5(changes, node, diag2.file);
|
|
140111
|
+
})
|
|
140112
|
+
});
|
|
140113
|
+
}
|
|
140114
|
+
});
|
|
140115
|
+
|
|
139853
140116
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
139854
140117
|
function getInfo2(sourceFile, pos) {
|
|
139855
140118
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -139865,7 +140128,7 @@ ${lanes.join("\n")}
|
|
|
139865
140128
|
}
|
|
139866
140129
|
return void 0;
|
|
139867
140130
|
}
|
|
139868
|
-
function
|
|
140131
|
+
function doChange6(changes, sourceFile, { container, typeNode, constraint, name }) {
|
|
139869
140132
|
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
|
|
139870
140133
|
/*readonlyToken*/
|
|
139871
140134
|
void 0,
|
|
@@ -139884,16 +140147,16 @@ ${lanes.join("\n")}
|
|
|
139884
140147
|
void 0
|
|
139885
140148
|
));
|
|
139886
140149
|
}
|
|
139887
|
-
var
|
|
140150
|
+
var fixId15, errorCodes16;
|
|
139888
140151
|
var init_convertLiteralTypeToMappedType = __esm({
|
|
139889
140152
|
"src/services/codefixes/convertLiteralTypeToMappedType.ts"() {
|
|
139890
140153
|
"use strict";
|
|
139891
140154
|
init_ts4();
|
|
139892
140155
|
init_ts_codefix();
|
|
139893
|
-
|
|
139894
|
-
|
|
140156
|
+
fixId15 = "convertLiteralTypeToMappedType";
|
|
140157
|
+
errorCodes16 = [Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0.code];
|
|
139895
140158
|
registerCodeFix({
|
|
139896
|
-
errorCodes:
|
|
140159
|
+
errorCodes: errorCodes16,
|
|
139897
140160
|
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
|
|
139898
140161
|
const { sourceFile, span } = context;
|
|
139899
140162
|
const info = getInfo2(sourceFile, span.start);
|
|
@@ -139901,14 +140164,14 @@ ${lanes.join("\n")}
|
|
|
139901
140164
|
return void 0;
|
|
139902
140165
|
}
|
|
139903
140166
|
const { name, constraint } = info;
|
|
139904
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
139905
|
-
return [createCodeFixAction(
|
|
140167
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange6(t, sourceFile, info));
|
|
140168
|
+
return [createCodeFixAction(fixId15, changes, [Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId15, Diagnostics.Convert_all_type_literals_to_mapped_type)];
|
|
139906
140169
|
},
|
|
139907
|
-
fixIds: [
|
|
139908
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
140170
|
+
fixIds: [fixId15],
|
|
140171
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes16, (changes, diag2) => {
|
|
139909
140172
|
const info = getInfo2(diag2.file, diag2.start);
|
|
139910
140173
|
if (info) {
|
|
139911
|
-
|
|
140174
|
+
doChange6(changes, diag2.file, info);
|
|
139912
140175
|
}
|
|
139913
140176
|
})
|
|
139914
140177
|
});
|
|
@@ -139967,31 +140230,31 @@ ${lanes.join("\n")}
|
|
|
139967
140230
|
const heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType);
|
|
139968
140231
|
return createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember));
|
|
139969
140232
|
}
|
|
139970
|
-
var
|
|
140233
|
+
var errorCodes17, fixId16;
|
|
139971
140234
|
var init_fixClassIncorrectlyImplementsInterface = __esm({
|
|
139972
140235
|
"src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts"() {
|
|
139973
140236
|
"use strict";
|
|
139974
140237
|
init_ts4();
|
|
139975
140238
|
init_ts_codefix();
|
|
139976
|
-
|
|
140239
|
+
errorCodes17 = [
|
|
139977
140240
|
Diagnostics.Class_0_incorrectly_implements_interface_1.code,
|
|
139978
140241
|
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code
|
|
139979
140242
|
];
|
|
139980
|
-
|
|
140243
|
+
fixId16 = "fixClassIncorrectlyImplementsInterface";
|
|
139981
140244
|
registerCodeFix({
|
|
139982
|
-
errorCodes:
|
|
140245
|
+
errorCodes: errorCodes17,
|
|
139983
140246
|
getCodeActions(context) {
|
|
139984
140247
|
const { sourceFile, span } = context;
|
|
139985
140248
|
const classDeclaration = getClass(sourceFile, span.start);
|
|
139986
140249
|
return mapDefined(getEffectiveImplementsTypeNodes(classDeclaration), (implementedTypeNode) => {
|
|
139987
140250
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences));
|
|
139988
|
-
return changes.length === 0 ? void 0 : createCodeFixAction(
|
|
140251
|
+
return changes.length === 0 ? void 0 : createCodeFixAction(fixId16, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId16, Diagnostics.Implement_all_unimplemented_interfaces);
|
|
139989
140252
|
});
|
|
139990
140253
|
},
|
|
139991
|
-
fixIds: [
|
|
140254
|
+
fixIds: [fixId16],
|
|
139992
140255
|
getAllCodeActions(context) {
|
|
139993
140256
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
139994
|
-
return codeFixAll(context,
|
|
140257
|
+
return codeFixAll(context, errorCodes17, (changes, diag2) => {
|
|
139995
140258
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
139996
140259
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
139997
140260
|
for (const implementedTypeNode of getEffectiveImplementsTypeNodes(classDeclaration)) {
|
|
@@ -141165,7 +141428,7 @@ ${lanes.join("\n")}
|
|
|
141165
141428
|
}
|
|
141166
141429
|
return !isStringANonContextualKeyword(res) ? res || "_" : `_${res}`;
|
|
141167
141430
|
}
|
|
141168
|
-
var importFixName, importFixId,
|
|
141431
|
+
var importFixName, importFixId, errorCodes18;
|
|
141169
141432
|
var init_importFixes = __esm({
|
|
141170
141433
|
"src/services/codefixes/importFixes.ts"() {
|
|
141171
141434
|
"use strict";
|
|
@@ -141173,7 +141436,7 @@ ${lanes.join("\n")}
|
|
|
141173
141436
|
init_ts_codefix();
|
|
141174
141437
|
importFixName = "import";
|
|
141175
141438
|
importFixId = "fixMissingImport";
|
|
141176
|
-
|
|
141439
|
+
errorCodes18 = [
|
|
141177
141440
|
Diagnostics.Cannot_find_name_0.code,
|
|
141178
141441
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
141179
141442
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
@@ -141185,7 +141448,7 @@ ${lanes.join("\n")}
|
|
|
141185
141448
|
Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
|
|
141186
141449
|
];
|
|
141187
141450
|
registerCodeFix({
|
|
141188
|
-
errorCodes:
|
|
141451
|
+
errorCodes: errorCodes18,
|
|
141189
141452
|
getCodeActions(context) {
|
|
141190
141453
|
const { errorCode, preferences, sourceFile, span, program } = context;
|
|
141191
141454
|
const info = getFixInfos(
|
|
@@ -141220,7 +141483,7 @@ ${lanes.join("\n")}
|
|
|
141220
141483
|
host,
|
|
141221
141484
|
cancellationToken
|
|
141222
141485
|
);
|
|
141223
|
-
eachDiagnostic(context,
|
|
141486
|
+
eachDiagnostic(context, errorCodes18, (diag2) => importAdder.addImportFromDiagnostic(diag2, context));
|
|
141224
141487
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, importAdder.writeFixes));
|
|
141225
141488
|
}
|
|
141226
141489
|
});
|
|
@@ -141295,14 +141558,14 @@ ${lanes.join("\n")}
|
|
|
141295
141558
|
const contextualType = isExpression(node) ? checker.getContextualType(node) : void 0;
|
|
141296
141559
|
return contextualType || checker.getTypeAtLocation(node);
|
|
141297
141560
|
}
|
|
141298
|
-
var
|
|
141561
|
+
var fixId17, errorCodes19;
|
|
141299
141562
|
var init_fixAddMissingConstraint = __esm({
|
|
141300
141563
|
"src/services/codefixes/fixAddMissingConstraint.ts"() {
|
|
141301
141564
|
"use strict";
|
|
141302
141565
|
init_ts4();
|
|
141303
141566
|
init_ts_codefix();
|
|
141304
|
-
|
|
141305
|
-
|
|
141567
|
+
fixId17 = "addMissingConstraint";
|
|
141568
|
+
errorCodes19 = [
|
|
141306
141569
|
// We want errors this could be attached to:
|
|
141307
141570
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
141308
141571
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -141315,21 +141578,21 @@ ${lanes.join("\n")}
|
|
|
141315
141578
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
141316
141579
|
];
|
|
141317
141580
|
registerCodeFix({
|
|
141318
|
-
errorCodes:
|
|
141581
|
+
errorCodes: errorCodes19,
|
|
141319
141582
|
getCodeActions(context) {
|
|
141320
141583
|
const { sourceFile, span, program, preferences, host } = context;
|
|
141321
141584
|
const info = getInfo3(program, sourceFile, span);
|
|
141322
141585
|
if (info === void 0)
|
|
141323
141586
|
return;
|
|
141324
141587
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
141325
|
-
return [createCodeFixAction(
|
|
141588
|
+
return [createCodeFixAction(fixId17, changes, Diagnostics.Add_extends_constraint, fixId17, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
141326
141589
|
},
|
|
141327
|
-
fixIds: [
|
|
141590
|
+
fixIds: [fixId17],
|
|
141328
141591
|
getAllCodeActions: (context) => {
|
|
141329
141592
|
const { program, preferences, host } = context;
|
|
141330
141593
|
const seen = /* @__PURE__ */ new Map();
|
|
141331
141594
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
141332
|
-
eachDiagnostic(context,
|
|
141595
|
+
eachDiagnostic(context, errorCodes19, (diag2) => {
|
|
141333
141596
|
const info = getInfo3(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
141334
141597
|
if (info) {
|
|
141335
141598
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -141411,7 +141674,7 @@ ${lanes.join("\n")}
|
|
|
141411
141674
|
Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement));
|
|
141412
141675
|
return classElement;
|
|
141413
141676
|
}
|
|
141414
|
-
var fixName, fixAddOverrideId, fixRemoveOverrideId,
|
|
141677
|
+
var fixName, fixAddOverrideId, fixRemoveOverrideId, errorCodes20, errorCodeFixIdMap;
|
|
141415
141678
|
var init_fixOverrideModifier = __esm({
|
|
141416
141679
|
"src/services/codefixes/fixOverrideModifier.ts"() {
|
|
141417
141680
|
"use strict";
|
|
@@ -141420,7 +141683,7 @@ ${lanes.join("\n")}
|
|
|
141420
141683
|
fixName = "fixOverrideModifier";
|
|
141421
141684
|
fixAddOverrideId = "fixAddOverrideModifier";
|
|
141422
141685
|
fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
141423
|
-
|
|
141686
|
+
errorCodes20 = [
|
|
141424
141687
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
141425
141688
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
141426
141689
|
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
|
@@ -141484,20 +141747,20 @@ ${lanes.join("\n")}
|
|
|
141484
141747
|
}
|
|
141485
141748
|
};
|
|
141486
141749
|
registerCodeFix({
|
|
141487
|
-
errorCodes:
|
|
141750
|
+
errorCodes: errorCodes20,
|
|
141488
141751
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
141489
141752
|
const { errorCode, span } = context;
|
|
141490
141753
|
const info = errorCodeFixIdMap[errorCode];
|
|
141491
141754
|
if (!info)
|
|
141492
141755
|
return emptyArray;
|
|
141493
|
-
const { descriptions, fixId:
|
|
141756
|
+
const { descriptions, fixId: fixId52, fixAllDescriptions } = info;
|
|
141494
141757
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
141495
141758
|
return [
|
|
141496
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
141759
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId52, fixAllDescriptions)
|
|
141497
141760
|
];
|
|
141498
141761
|
},
|
|
141499
141762
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
141500
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141763
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes20, (changes, diag2) => {
|
|
141501
141764
|
const { code, start } = diag2;
|
|
141502
141765
|
const info = errorCodeFixIdMap[code];
|
|
141503
141766
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -141510,7 +141773,7 @@ ${lanes.join("\n")}
|
|
|
141510
141773
|
});
|
|
141511
141774
|
|
|
141512
141775
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
141513
|
-
function
|
|
141776
|
+
function doChange7(changes, sourceFile, node, preferences) {
|
|
141514
141777
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
141515
141778
|
const argumentsExpression = factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */);
|
|
141516
141779
|
changes.replaceNode(
|
|
@@ -141522,32 +141785,32 @@ ${lanes.join("\n")}
|
|
|
141522
141785
|
function getPropertyAccessExpression(sourceFile, pos) {
|
|
141523
141786
|
return cast(getTokenAtPosition(sourceFile, pos).parent, isPropertyAccessExpression);
|
|
141524
141787
|
}
|
|
141525
|
-
var
|
|
141788
|
+
var fixId18, errorCodes21;
|
|
141526
141789
|
var init_fixNoPropertyAccessFromIndexSignature = __esm({
|
|
141527
141790
|
"src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts"() {
|
|
141528
141791
|
"use strict";
|
|
141529
141792
|
init_ts4();
|
|
141530
141793
|
init_ts_codefix();
|
|
141531
|
-
|
|
141532
|
-
|
|
141794
|
+
fixId18 = "fixNoPropertyAccessFromIndexSignature";
|
|
141795
|
+
errorCodes21 = [
|
|
141533
141796
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
141534
141797
|
];
|
|
141535
141798
|
registerCodeFix({
|
|
141536
|
-
errorCodes:
|
|
141537
|
-
fixIds: [
|
|
141799
|
+
errorCodes: errorCodes21,
|
|
141800
|
+
fixIds: [fixId18],
|
|
141538
141801
|
getCodeActions(context) {
|
|
141539
141802
|
const { sourceFile, span, preferences } = context;
|
|
141540
141803
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
141541
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141542
|
-
return [createCodeFixAction(
|
|
141804
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange7(t, context.sourceFile, property, preferences));
|
|
141805
|
+
return [createCodeFixAction(fixId18, changes, [Diagnostics.Use_element_access_for_0, property.name.text], fixId18, Diagnostics.Use_element_access_for_all_undeclared_properties)];
|
|
141543
141806
|
},
|
|
141544
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141807
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => doChange7(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
141545
141808
|
});
|
|
141546
141809
|
}
|
|
141547
141810
|
});
|
|
141548
141811
|
|
|
141549
141812
|
// src/services/codefixes/fixImplicitThis.ts
|
|
141550
|
-
function
|
|
141813
|
+
function doChange8(changes, sourceFile, pos, checker) {
|
|
141551
141814
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
141552
141815
|
if (!isThis(token))
|
|
141553
141816
|
return void 0;
|
|
@@ -141588,27 +141851,27 @@ ${lanes.join("\n")}
|
|
|
141588
141851
|
}
|
|
141589
141852
|
}
|
|
141590
141853
|
}
|
|
141591
|
-
var
|
|
141854
|
+
var fixId19, errorCodes22;
|
|
141592
141855
|
var init_fixImplicitThis = __esm({
|
|
141593
141856
|
"src/services/codefixes/fixImplicitThis.ts"() {
|
|
141594
141857
|
"use strict";
|
|
141595
141858
|
init_ts4();
|
|
141596
141859
|
init_ts_codefix();
|
|
141597
|
-
|
|
141598
|
-
|
|
141860
|
+
fixId19 = "fixImplicitThis";
|
|
141861
|
+
errorCodes22 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
141599
141862
|
registerCodeFix({
|
|
141600
|
-
errorCodes:
|
|
141863
|
+
errorCodes: errorCodes22,
|
|
141601
141864
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
141602
141865
|
const { sourceFile, program, span } = context;
|
|
141603
141866
|
let diagnostic;
|
|
141604
141867
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
141605
|
-
diagnostic =
|
|
141868
|
+
diagnostic = doChange8(t, sourceFile, span.start, program.getTypeChecker());
|
|
141606
141869
|
});
|
|
141607
|
-
return diagnostic ? [createCodeFixAction(
|
|
141870
|
+
return diagnostic ? [createCodeFixAction(fixId19, changes, diagnostic, fixId19, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
141608
141871
|
},
|
|
141609
|
-
fixIds: [
|
|
141610
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141611
|
-
|
|
141872
|
+
fixIds: [fixId19],
|
|
141873
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => {
|
|
141874
|
+
doChange8(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
141612
141875
|
})
|
|
141613
141876
|
});
|
|
141614
141877
|
}
|
|
@@ -141651,7 +141914,7 @@ ${lanes.join("\n")}
|
|
|
141651
141914
|
}
|
|
141652
141915
|
return void 0;
|
|
141653
141916
|
}
|
|
141654
|
-
function
|
|
141917
|
+
function doChange9(changes, program, { exportName, node, moduleSourceFile }) {
|
|
141655
141918
|
const exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
141656
141919
|
if (exportDeclaration) {
|
|
141657
141920
|
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
@@ -141733,32 +141996,32 @@ ${lanes.join("\n")}
|
|
|
141733
141996
|
const variableStatement = isVariableDeclaration(declaration) ? tryCast(declaration.parent.parent, isVariableStatement) : void 0;
|
|
141734
141997
|
return variableStatement && length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
141735
141998
|
}
|
|
141736
|
-
var
|
|
141999
|
+
var fixId20, errorCodes23;
|
|
141737
142000
|
var init_fixImportNonExportedMember = __esm({
|
|
141738
142001
|
"src/services/codefixes/fixImportNonExportedMember.ts"() {
|
|
141739
142002
|
"use strict";
|
|
141740
142003
|
init_ts4();
|
|
141741
142004
|
init_ts_codefix();
|
|
141742
|
-
|
|
141743
|
-
|
|
142005
|
+
fixId20 = "fixImportNonExportedMember";
|
|
142006
|
+
errorCodes23 = [
|
|
141744
142007
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
141745
142008
|
];
|
|
141746
142009
|
registerCodeFix({
|
|
141747
|
-
errorCodes:
|
|
141748
|
-
fixIds: [
|
|
142010
|
+
errorCodes: errorCodes23,
|
|
142011
|
+
fixIds: [fixId20],
|
|
141749
142012
|
getCodeActions(context) {
|
|
141750
142013
|
const { sourceFile, span, program } = context;
|
|
141751
142014
|
const info = getInfo4(sourceFile, span.start, program);
|
|
141752
142015
|
if (info === void 0)
|
|
141753
142016
|
return void 0;
|
|
141754
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141755
|
-
return [createCodeFixAction(
|
|
142017
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange9(t, program, info));
|
|
142018
|
+
return [createCodeFixAction(fixId20, changes, [Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId20, Diagnostics.Export_all_referenced_locals)];
|
|
141756
142019
|
},
|
|
141757
142020
|
getAllCodeActions(context) {
|
|
141758
142021
|
const { program } = context;
|
|
141759
142022
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
141760
142023
|
const exports = /* @__PURE__ */ new Map();
|
|
141761
|
-
eachDiagnostic(context,
|
|
142024
|
+
eachDiagnostic(context, errorCodes23, (diag2) => {
|
|
141762
142025
|
const info = getInfo4(diag2.file, diag2.start, program);
|
|
141763
142026
|
if (info === void 0)
|
|
141764
142027
|
return void 0;
|
|
@@ -141803,7 +142066,7 @@ ${lanes.join("\n")}
|
|
|
141803
142066
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
141804
142067
|
return findAncestor(token, (t) => t.kind === 199 /* NamedTupleMember */);
|
|
141805
142068
|
}
|
|
141806
|
-
function
|
|
142069
|
+
function doChange10(changes, sourceFile, namedTupleMember) {
|
|
141807
142070
|
if (!namedTupleMember) {
|
|
141808
142071
|
return;
|
|
141809
142072
|
}
|
|
@@ -141830,26 +142093,26 @@ ${lanes.join("\n")}
|
|
|
141830
142093
|
}
|
|
141831
142094
|
changes.replaceNode(sourceFile, namedTupleMember, updated);
|
|
141832
142095
|
}
|
|
141833
|
-
var
|
|
142096
|
+
var fixId21, errorCodes24;
|
|
141834
142097
|
var init_fixIncorrectNamedTupleSyntax = __esm({
|
|
141835
142098
|
"src/services/codefixes/fixIncorrectNamedTupleSyntax.ts"() {
|
|
141836
142099
|
"use strict";
|
|
141837
142100
|
init_ts4();
|
|
141838
142101
|
init_ts_codefix();
|
|
141839
|
-
|
|
141840
|
-
|
|
142102
|
+
fixId21 = "fixIncorrectNamedTupleSyntax";
|
|
142103
|
+
errorCodes24 = [
|
|
141841
142104
|
Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type.code,
|
|
141842
142105
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
141843
142106
|
];
|
|
141844
142107
|
registerCodeFix({
|
|
141845
|
-
errorCodes:
|
|
142108
|
+
errorCodes: errorCodes24,
|
|
141846
142109
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
141847
142110
|
const { sourceFile, span } = context;
|
|
141848
142111
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
141849
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141850
|
-
return [createCodeFixAction(
|
|
142112
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange10(t, sourceFile, namedTupleMember));
|
|
142113
|
+
return [createCodeFixAction(fixId21, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId21, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
141851
142114
|
},
|
|
141852
|
-
fixIds: [
|
|
142115
|
+
fixIds: [fixId21]
|
|
141853
142116
|
});
|
|
141854
142117
|
}
|
|
141855
142118
|
});
|
|
@@ -141904,7 +142167,7 @@ ${lanes.join("\n")}
|
|
|
141904
142167
|
}
|
|
141905
142168
|
return suggestedSymbol === void 0 ? void 0 : { node, suggestedSymbol };
|
|
141906
142169
|
}
|
|
141907
|
-
function
|
|
142170
|
+
function doChange11(changes, sourceFile, node, suggestedSymbol, target) {
|
|
141908
142171
|
const suggestion = symbolName(suggestedSymbol);
|
|
141909
142172
|
if (!isIdentifierText(suggestion, target) && isPropertyAccessExpression(node.parent)) {
|
|
141910
142173
|
const valDecl = suggestedSymbol.valueDeclaration;
|
|
@@ -141938,14 +142201,14 @@ ${lanes.join("\n")}
|
|
|
141938
142201
|
return void 0;
|
|
141939
142202
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
141940
142203
|
}
|
|
141941
|
-
var
|
|
142204
|
+
var fixId22, errorCodes25;
|
|
141942
142205
|
var init_fixSpelling = __esm({
|
|
141943
142206
|
"src/services/codefixes/fixSpelling.ts"() {
|
|
141944
142207
|
"use strict";
|
|
141945
142208
|
init_ts4();
|
|
141946
142209
|
init_ts_codefix();
|
|
141947
|
-
|
|
141948
|
-
|
|
142210
|
+
fixId22 = "fixSpelling";
|
|
142211
|
+
errorCodes25 = [
|
|
141949
142212
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
141950
142213
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
141951
142214
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -141962,7 +142225,7 @@ ${lanes.join("\n")}
|
|
|
141962
142225
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
141963
142226
|
];
|
|
141964
142227
|
registerCodeFix({
|
|
141965
|
-
errorCodes:
|
|
142228
|
+
errorCodes: errorCodes25,
|
|
141966
142229
|
getCodeActions(context) {
|
|
141967
142230
|
const { sourceFile, errorCode } = context;
|
|
141968
142231
|
const info = getInfo5(sourceFile, context.span.start, context, errorCode);
|
|
@@ -141970,15 +142233,15 @@ ${lanes.join("\n")}
|
|
|
141970
142233
|
return void 0;
|
|
141971
142234
|
const { node, suggestedSymbol } = info;
|
|
141972
142235
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
141973
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141974
|
-
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)],
|
|
142236
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, sourceFile, node, suggestedSymbol, target));
|
|
142237
|
+
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId22, Diagnostics.Fix_all_detected_spelling_errors)];
|
|
141975
142238
|
},
|
|
141976
|
-
fixIds: [
|
|
141977
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142239
|
+
fixIds: [fixId22],
|
|
142240
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes25, (changes, diag2) => {
|
|
141978
142241
|
const info = getInfo5(diag2.file, diag2.start, context, diag2.code);
|
|
141979
142242
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
141980
142243
|
if (info)
|
|
141981
|
-
|
|
142244
|
+
doChange11(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
141982
142245
|
})
|
|
141983
142246
|
});
|
|
141984
142247
|
}
|
|
@@ -142162,7 +142425,7 @@ ${lanes.join("\n")}
|
|
|
142162
142425
|
}
|
|
142163
142426
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
142164
142427
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
142165
|
-
return createCodeFixAction(
|
|
142428
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
142166
142429
|
}
|
|
142167
142430
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
142168
142431
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -142174,29 +142437,29 @@ ${lanes.join("\n")}
|
|
|
142174
142437
|
/* withParen */
|
|
142175
142438
|
false
|
|
142176
142439
|
));
|
|
142177
|
-
return createCodeFixAction(
|
|
142440
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
|
142178
142441
|
}
|
|
142179
142442
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
142180
142443
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
142181
|
-
return createCodeFixAction(
|
|
142444
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal, fixIdWrapTheBlockWithParen, Diagnostics.Wrap_all_object_literal_with_parentheses);
|
|
142182
142445
|
}
|
|
142183
|
-
var
|
|
142446
|
+
var fixId23, fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen, errorCodes26;
|
|
142184
142447
|
var init_returnValueCorrect = __esm({
|
|
142185
142448
|
"src/services/codefixes/returnValueCorrect.ts"() {
|
|
142186
142449
|
"use strict";
|
|
142187
142450
|
init_ts4();
|
|
142188
142451
|
init_ts_codefix();
|
|
142189
|
-
|
|
142452
|
+
fixId23 = "returnValueCorrect";
|
|
142190
142453
|
fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
142191
142454
|
fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
142192
142455
|
fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
142193
|
-
|
|
142456
|
+
errorCodes26 = [
|
|
142194
142457
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
142195
142458
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
142196
142459
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
142197
142460
|
];
|
|
142198
142461
|
registerCodeFix({
|
|
142199
|
-
errorCodes:
|
|
142462
|
+
errorCodes: errorCodes26,
|
|
142200
142463
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
142201
142464
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
142202
142465
|
const { program, sourceFile, span: { start }, errorCode } = context;
|
|
@@ -142212,7 +142475,7 @@ ${lanes.join("\n")}
|
|
|
142212
142475
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
142213
142476
|
}
|
|
142214
142477
|
},
|
|
142215
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142478
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
142216
142479
|
const info = getInfo6(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
142217
142480
|
if (!info)
|
|
142218
142481
|
return void 0;
|
|
@@ -142778,7 +143041,7 @@ ${lanes.join("\n")}
|
|
|
142778
143041
|
}
|
|
142779
143042
|
return getSourceFileOfNode(node);
|
|
142780
143043
|
}
|
|
142781
|
-
var fixMissingMember, fixMissingProperties, fixMissingAttributes, fixMissingFunctionDeclaration,
|
|
143044
|
+
var fixMissingMember, fixMissingProperties, fixMissingAttributes, fixMissingFunctionDeclaration, errorCodes27;
|
|
142782
143045
|
var init_fixAddMissingMember = __esm({
|
|
142783
143046
|
"src/services/codefixes/fixAddMissingMember.ts"() {
|
|
142784
143047
|
"use strict";
|
|
@@ -142788,7 +143051,7 @@ ${lanes.join("\n")}
|
|
|
142788
143051
|
fixMissingProperties = "fixMissingProperties";
|
|
142789
143052
|
fixMissingAttributes = "fixMissingAttributes";
|
|
142790
143053
|
fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
142791
|
-
|
|
143054
|
+
errorCodes27 = [
|
|
142792
143055
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
142793
143056
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
142794
143057
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -142798,7 +143061,7 @@ ${lanes.join("\n")}
|
|
|
142798
143061
|
Diagnostics.Cannot_find_name_0.code
|
|
142799
143062
|
];
|
|
142800
143063
|
registerCodeFix({
|
|
142801
|
-
errorCodes:
|
|
143064
|
+
errorCodes: errorCodes27,
|
|
142802
143065
|
getCodeActions(context) {
|
|
142803
143066
|
const typeChecker = context.program.getTypeChecker();
|
|
142804
143067
|
const info = getInfo7(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -142825,21 +143088,21 @@ ${lanes.join("\n")}
|
|
|
142825
143088
|
},
|
|
142826
143089
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
142827
143090
|
getAllCodeActions: (context) => {
|
|
142828
|
-
const { program, fixId:
|
|
143091
|
+
const { program, fixId: fixId52 } = context;
|
|
142829
143092
|
const checker = program.getTypeChecker();
|
|
142830
143093
|
const seen = /* @__PURE__ */ new Map();
|
|
142831
143094
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
142832
143095
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142833
|
-
eachDiagnostic(context,
|
|
143096
|
+
eachDiagnostic(context, errorCodes27, (diag2) => {
|
|
142834
143097
|
const info = getInfo7(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
142835
143098
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
|
|
142836
143099
|
return;
|
|
142837
143100
|
}
|
|
142838
|
-
if (
|
|
143101
|
+
if (fixId52 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
142839
143102
|
addFunctionDeclaration(changes, context, info);
|
|
142840
|
-
} else if (
|
|
143103
|
+
} else if (fixId52 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
142841
143104
|
addObjectLiteralProperties(changes, context, info);
|
|
142842
|
-
} else if (
|
|
143105
|
+
} else if (fixId52 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
142843
143106
|
addJsxAttributes(changes, context, info);
|
|
142844
143107
|
} else {
|
|
142845
143108
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -142895,23 +143158,23 @@ ${lanes.join("\n")}
|
|
|
142895
143158
|
}
|
|
142896
143159
|
return token;
|
|
142897
143160
|
}
|
|
142898
|
-
var
|
|
143161
|
+
var fixId24, errorCodes28;
|
|
142899
143162
|
var init_fixAddMissingNewOperator = __esm({
|
|
142900
143163
|
"src/services/codefixes/fixAddMissingNewOperator.ts"() {
|
|
142901
143164
|
"use strict";
|
|
142902
143165
|
init_ts4();
|
|
142903
143166
|
init_ts_codefix();
|
|
142904
|
-
|
|
142905
|
-
|
|
143167
|
+
fixId24 = "addMissingNewOperator";
|
|
143168
|
+
errorCodes28 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
142906
143169
|
registerCodeFix({
|
|
142907
|
-
errorCodes:
|
|
143170
|
+
errorCodes: errorCodes28,
|
|
142908
143171
|
getCodeActions(context) {
|
|
142909
143172
|
const { sourceFile, span } = context;
|
|
142910
143173
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
142911
|
-
return [createCodeFixAction(
|
|
143174
|
+
return [createCodeFixAction(fixId24, changes, Diagnostics.Add_missing_new_operator_to_call, fixId24, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
142912
143175
|
},
|
|
142913
|
-
fixIds: [
|
|
142914
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143176
|
+
fixIds: [fixId24],
|
|
143177
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes28, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
142915
143178
|
});
|
|
142916
143179
|
}
|
|
142917
143180
|
});
|
|
@@ -142932,7 +143195,7 @@ ${lanes.join("\n")}
|
|
|
142932
143195
|
var _a2;
|
|
142933
143196
|
return diagCode === errorCodeCannotFindModule ? ts_JsTyping_exports.nodeCoreModules.has(packageName) ? "@types/node" : void 0 : ((_a2 = host.isKnownTypesPackageName) == null ? void 0 : _a2.call(host, packageName)) ? getTypesPackageName(packageName) : void 0;
|
|
142934
143197
|
}
|
|
142935
|
-
var fixName2, fixIdInstallTypesPackage, errorCodeCannotFindModule,
|
|
143198
|
+
var fixName2, fixIdInstallTypesPackage, errorCodeCannotFindModule, errorCodes29;
|
|
142936
143199
|
var init_fixCannotFindModule = __esm({
|
|
142937
143200
|
"src/services/codefixes/fixCannotFindModule.ts"() {
|
|
142938
143201
|
"use strict";
|
|
@@ -142941,12 +143204,12 @@ ${lanes.join("\n")}
|
|
|
142941
143204
|
fixName2 = "fixCannotFindModule";
|
|
142942
143205
|
fixIdInstallTypesPackage = "installTypesPackage";
|
|
142943
143206
|
errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
142944
|
-
|
|
143207
|
+
errorCodes29 = [
|
|
142945
143208
|
errorCodeCannotFindModule,
|
|
142946
143209
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
142947
143210
|
];
|
|
142948
143211
|
registerCodeFix({
|
|
142949
|
-
errorCodes:
|
|
143212
|
+
errorCodes: errorCodes29,
|
|
142950
143213
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
142951
143214
|
const { host, sourceFile, span: { start } } = context;
|
|
142952
143215
|
const packageName = tryGetImportedPackageName(sourceFile, start);
|
|
@@ -142965,7 +143228,7 @@ ${lanes.join("\n")}
|
|
|
142965
143228
|
},
|
|
142966
143229
|
fixIds: [fixIdInstallTypesPackage],
|
|
142967
143230
|
getAllCodeActions: (context) => {
|
|
142968
|
-
return codeFixAll(context,
|
|
143231
|
+
return codeFixAll(context, errorCodes29, (_changes, diag2, commands) => {
|
|
142969
143232
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
142970
143233
|
if (packageName === void 0)
|
|
142971
143234
|
return void 0;
|
|
@@ -143004,28 +143267,28 @@ ${lanes.join("\n")}
|
|
|
143004
143267
|
const flags = getSyntacticModifierFlags(first(symbol.getDeclarations()));
|
|
143005
143268
|
return !(flags & 8 /* Private */) && !!(flags & 256 /* Abstract */);
|
|
143006
143269
|
}
|
|
143007
|
-
var
|
|
143270
|
+
var errorCodes30, fixId25;
|
|
143008
143271
|
var init_fixClassDoesntImplementInheritedAbstractMember = __esm({
|
|
143009
143272
|
"src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts"() {
|
|
143010
143273
|
"use strict";
|
|
143011
143274
|
init_ts4();
|
|
143012
143275
|
init_ts_codefix();
|
|
143013
|
-
|
|
143276
|
+
errorCodes30 = [
|
|
143014
143277
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
143015
143278
|
Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code
|
|
143016
143279
|
];
|
|
143017
|
-
|
|
143280
|
+
fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
143018
143281
|
registerCodeFix({
|
|
143019
|
-
errorCodes:
|
|
143282
|
+
errorCodes: errorCodes30,
|
|
143020
143283
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
143021
143284
|
const { sourceFile, span } = context;
|
|
143022
143285
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
143023
|
-
return changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
143286
|
+
return changes.length === 0 ? void 0 : [createCodeFixAction(fixId25, changes, Diagnostics.Implement_inherited_abstract_class, fixId25, Diagnostics.Implement_all_inherited_abstract_classes)];
|
|
143024
143287
|
},
|
|
143025
|
-
fixIds: [
|
|
143288
|
+
fixIds: [fixId25],
|
|
143026
143289
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
143027
143290
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
143028
|
-
return codeFixAll(context,
|
|
143291
|
+
return codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
143029
143292
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
143030
143293
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
143031
143294
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -143037,7 +143300,7 @@ ${lanes.join("\n")}
|
|
|
143037
143300
|
});
|
|
143038
143301
|
|
|
143039
143302
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
143040
|
-
function
|
|
143303
|
+
function doChange12(changes, sourceFile, constructor, superCall) {
|
|
143041
143304
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
143042
143305
|
changes.delete(sourceFile, superCall);
|
|
143043
143306
|
}
|
|
@@ -143052,36 +143315,36 @@ ${lanes.join("\n")}
|
|
|
143052
143315
|
function findSuperCall(n) {
|
|
143053
143316
|
return isExpressionStatement(n) && isSuperCall(n.expression) ? n : isFunctionLike(n) ? void 0 : forEachChild(n, findSuperCall);
|
|
143054
143317
|
}
|
|
143055
|
-
var
|
|
143318
|
+
var fixId26, errorCodes31;
|
|
143056
143319
|
var init_fixClassSuperMustPrecedeThisAccess = __esm({
|
|
143057
143320
|
"src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts"() {
|
|
143058
143321
|
"use strict";
|
|
143059
143322
|
init_ts4();
|
|
143060
143323
|
init_ts_codefix();
|
|
143061
|
-
|
|
143062
|
-
|
|
143324
|
+
fixId26 = "classSuperMustPrecedeThisAccess";
|
|
143325
|
+
errorCodes31 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
143063
143326
|
registerCodeFix({
|
|
143064
|
-
errorCodes:
|
|
143327
|
+
errorCodes: errorCodes31,
|
|
143065
143328
|
getCodeActions(context) {
|
|
143066
143329
|
const { sourceFile, span } = context;
|
|
143067
143330
|
const nodes = getNodes(sourceFile, span.start);
|
|
143068
143331
|
if (!nodes)
|
|
143069
143332
|
return void 0;
|
|
143070
143333
|
const { constructor, superCall } = nodes;
|
|
143071
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143072
|
-
return [createCodeFixAction(
|
|
143334
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, sourceFile, constructor, superCall));
|
|
143335
|
+
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)];
|
|
143073
143336
|
},
|
|
143074
|
-
fixIds: [
|
|
143337
|
+
fixIds: [fixId26],
|
|
143075
143338
|
getAllCodeActions(context) {
|
|
143076
143339
|
const { sourceFile } = context;
|
|
143077
143340
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
143078
|
-
return codeFixAll(context,
|
|
143341
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
143079
143342
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
143080
143343
|
if (!nodes)
|
|
143081
143344
|
return;
|
|
143082
143345
|
const { constructor, superCall } = nodes;
|
|
143083
143346
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
143084
|
-
|
|
143347
|
+
doChange12(changes, sourceFile, constructor, superCall);
|
|
143085
143348
|
}
|
|
143086
143349
|
});
|
|
143087
143350
|
}
|
|
@@ -143095,7 +143358,7 @@ ${lanes.join("\n")}
|
|
|
143095
143358
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
143096
143359
|
return token.parent;
|
|
143097
143360
|
}
|
|
143098
|
-
function
|
|
143361
|
+
function doChange13(changes, sourceFile, ctr) {
|
|
143099
143362
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
143100
143363
|
factory.createSuper(),
|
|
143101
143364
|
/*typeArguments*/
|
|
@@ -143105,42 +143368,42 @@ ${lanes.join("\n")}
|
|
|
143105
143368
|
));
|
|
143106
143369
|
changes.insertNodeAtConstructorStart(sourceFile, ctr, superCall);
|
|
143107
143370
|
}
|
|
143108
|
-
var
|
|
143371
|
+
var fixId27, errorCodes32;
|
|
143109
143372
|
var init_fixConstructorForDerivedNeedSuperCall = __esm({
|
|
143110
143373
|
"src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts"() {
|
|
143111
143374
|
"use strict";
|
|
143112
143375
|
init_ts4();
|
|
143113
143376
|
init_ts_codefix();
|
|
143114
|
-
|
|
143115
|
-
|
|
143377
|
+
fixId27 = "constructorForDerivedNeedSuperCall";
|
|
143378
|
+
errorCodes32 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
143116
143379
|
registerCodeFix({
|
|
143117
|
-
errorCodes:
|
|
143380
|
+
errorCodes: errorCodes32,
|
|
143118
143381
|
getCodeActions(context) {
|
|
143119
143382
|
const { sourceFile, span } = context;
|
|
143120
143383
|
const ctr = getNode(sourceFile, span.start);
|
|
143121
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143122
|
-
return [createCodeFixAction(
|
|
143384
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange13(t, sourceFile, ctr));
|
|
143385
|
+
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
143123
143386
|
},
|
|
143124
|
-
fixIds: [
|
|
143125
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143387
|
+
fixIds: [fixId27],
|
|
143388
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes32, (changes, diag2) => doChange13(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
143126
143389
|
});
|
|
143127
143390
|
}
|
|
143128
143391
|
});
|
|
143129
143392
|
|
|
143130
143393
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
143131
|
-
function
|
|
143394
|
+
function doChange14(changeTracker, configFile) {
|
|
143132
143395
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
143133
143396
|
}
|
|
143134
|
-
var fixID,
|
|
143397
|
+
var fixID, errorCodes33;
|
|
143135
143398
|
var init_fixEnableJsxFlag = __esm({
|
|
143136
143399
|
"src/services/codefixes/fixEnableJsxFlag.ts"() {
|
|
143137
143400
|
"use strict";
|
|
143138
143401
|
init_ts4();
|
|
143139
143402
|
init_ts_codefix();
|
|
143140
143403
|
fixID = "fixEnableJsxFlag";
|
|
143141
|
-
|
|
143404
|
+
errorCodes33 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
143142
143405
|
registerCodeFix({
|
|
143143
|
-
errorCodes:
|
|
143406
|
+
errorCodes: errorCodes33,
|
|
143144
143407
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
143145
143408
|
const { configFile } = context.program.getCompilerOptions();
|
|
143146
143409
|
if (configFile === void 0) {
|
|
@@ -143148,19 +143411,19 @@ ${lanes.join("\n")}
|
|
|
143148
143411
|
}
|
|
143149
143412
|
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
143150
143413
|
context,
|
|
143151
|
-
(changeTracker) =>
|
|
143414
|
+
(changeTracker) => doChange14(changeTracker, configFile)
|
|
143152
143415
|
);
|
|
143153
143416
|
return [
|
|
143154
143417
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
143155
143418
|
];
|
|
143156
143419
|
},
|
|
143157
143420
|
fixIds: [fixID],
|
|
143158
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143421
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes) => {
|
|
143159
143422
|
const { configFile } = context.program.getCompilerOptions();
|
|
143160
143423
|
if (configFile === void 0) {
|
|
143161
143424
|
return void 0;
|
|
143162
143425
|
}
|
|
143163
|
-
|
|
143426
|
+
doChange14(changes, configFile);
|
|
143164
143427
|
})
|
|
143165
143428
|
});
|
|
143166
143429
|
}
|
|
@@ -143182,7 +143445,7 @@ ${lanes.join("\n")}
|
|
|
143182
143445
|
}
|
|
143183
143446
|
return void 0;
|
|
143184
143447
|
}
|
|
143185
|
-
function
|
|
143448
|
+
function doChange15(changes, sourceFile, arg, expression) {
|
|
143186
143449
|
const callExpression = factory.createCallExpression(
|
|
143187
143450
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
143188
143451
|
/*typeArguments*/
|
|
@@ -143200,33 +143463,33 @@ ${lanes.join("\n")}
|
|
|
143200
143463
|
const [_, suggestion] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [];
|
|
143201
143464
|
return suggestion;
|
|
143202
143465
|
}
|
|
143203
|
-
var
|
|
143466
|
+
var fixId28, errorCodes34;
|
|
143204
143467
|
var init_fixNaNEquality = __esm({
|
|
143205
143468
|
"src/services/codefixes/fixNaNEquality.ts"() {
|
|
143206
143469
|
"use strict";
|
|
143207
143470
|
init_ts4();
|
|
143208
143471
|
init_ts_codefix();
|
|
143209
|
-
|
|
143210
|
-
|
|
143472
|
+
fixId28 = "fixNaNEquality";
|
|
143473
|
+
errorCodes34 = [
|
|
143211
143474
|
Diagnostics.This_condition_will_always_return_0.code
|
|
143212
143475
|
];
|
|
143213
143476
|
registerCodeFix({
|
|
143214
|
-
errorCodes:
|
|
143477
|
+
errorCodes: errorCodes34,
|
|
143215
143478
|
getCodeActions(context) {
|
|
143216
143479
|
const { sourceFile, span, program } = context;
|
|
143217
143480
|
const info = getInfo8(program, sourceFile, span);
|
|
143218
143481
|
if (info === void 0)
|
|
143219
143482
|
return;
|
|
143220
143483
|
const { suggestion, expression, arg } = info;
|
|
143221
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143222
|
-
return [createCodeFixAction(
|
|
143484
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange15(t, sourceFile, arg, expression));
|
|
143485
|
+
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
143223
143486
|
},
|
|
143224
|
-
fixIds: [
|
|
143487
|
+
fixIds: [fixId28],
|
|
143225
143488
|
getAllCodeActions: (context) => {
|
|
143226
|
-
return codeFixAll(context,
|
|
143489
|
+
return codeFixAll(context, errorCodes34, (changes, diag2) => {
|
|
143227
143490
|
const info = getInfo8(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
143228
143491
|
if (info) {
|
|
143229
|
-
|
|
143492
|
+
doChange15(changes, diag2.file, info.arg, info.expression);
|
|
143230
143493
|
}
|
|
143231
143494
|
});
|
|
143232
143495
|
}
|
|
@@ -143282,32 +143545,32 @@ ${lanes.join("\n")}
|
|
|
143282
143545
|
});
|
|
143283
143546
|
|
|
143284
143547
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
143285
|
-
function
|
|
143548
|
+
function doChange16(changes, sourceFile, node) {
|
|
143286
143549
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
143287
143550
|
}
|
|
143288
143551
|
function getProperty2(sourceFile, pos) {
|
|
143289
143552
|
return cast(getTokenAtPosition(sourceFile, pos).parent, isShorthandPropertyAssignment);
|
|
143290
143553
|
}
|
|
143291
|
-
var
|
|
143554
|
+
var fixId29, errorCodes35;
|
|
143292
143555
|
var init_fixPropertyAssignment = __esm({
|
|
143293
143556
|
"src/services/codefixes/fixPropertyAssignment.ts"() {
|
|
143294
143557
|
"use strict";
|
|
143295
143558
|
init_ts4();
|
|
143296
143559
|
init_ts_codefix();
|
|
143297
|
-
|
|
143298
|
-
|
|
143560
|
+
fixId29 = "fixPropertyAssignment";
|
|
143561
|
+
errorCodes35 = [
|
|
143299
143562
|
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
|
|
143300
143563
|
];
|
|
143301
143564
|
registerCodeFix({
|
|
143302
|
-
errorCodes:
|
|
143303
|
-
fixIds: [
|
|
143565
|
+
errorCodes: errorCodes35,
|
|
143566
|
+
fixIds: [fixId29],
|
|
143304
143567
|
getCodeActions(context) {
|
|
143305
143568
|
const { sourceFile, span } = context;
|
|
143306
143569
|
const property = getProperty2(sourceFile, span.start);
|
|
143307
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143308
|
-
return [createCodeFixAction(
|
|
143570
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, context.sourceFile, property));
|
|
143571
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
143309
143572
|
},
|
|
143310
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143573
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes, diag2) => doChange16(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
143311
143574
|
});
|
|
143312
143575
|
}
|
|
143313
143576
|
});
|
|
@@ -143333,16 +143596,16 @@ ${lanes.join("\n")}
|
|
|
143333
143596
|
changes.deleteRange(sourceFile, { pos: implementsToken.getStart(), end });
|
|
143334
143597
|
}
|
|
143335
143598
|
}
|
|
143336
|
-
var
|
|
143599
|
+
var fixId30, errorCodes36;
|
|
143337
143600
|
var init_fixExtendsInterfaceBecomesImplements = __esm({
|
|
143338
143601
|
"src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts"() {
|
|
143339
143602
|
"use strict";
|
|
143340
143603
|
init_ts4();
|
|
143341
143604
|
init_ts_codefix();
|
|
143342
|
-
|
|
143343
|
-
|
|
143605
|
+
fixId30 = "extendsInterfaceBecomesImplements";
|
|
143606
|
+
errorCodes36 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
143344
143607
|
registerCodeFix({
|
|
143345
|
-
errorCodes:
|
|
143608
|
+
errorCodes: errorCodes36,
|
|
143346
143609
|
getCodeActions(context) {
|
|
143347
143610
|
const { sourceFile } = context;
|
|
143348
143611
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -143350,10 +143613,10 @@ ${lanes.join("\n")}
|
|
|
143350
143613
|
return void 0;
|
|
143351
143614
|
const { extendsToken, heritageClauses } = nodes;
|
|
143352
143615
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
143353
|
-
return [createCodeFixAction(
|
|
143616
|
+
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
143354
143617
|
},
|
|
143355
|
-
fixIds: [
|
|
143356
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143618
|
+
fixIds: [fixId30],
|
|
143619
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
143357
143620
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
143358
143621
|
if (nodes)
|
|
143359
143622
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -143369,39 +143632,39 @@ ${lanes.join("\n")}
|
|
|
143369
143632
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
143370
143633
|
}
|
|
143371
143634
|
}
|
|
143372
|
-
function
|
|
143635
|
+
function doChange17(changes, sourceFile, { node, className }) {
|
|
143373
143636
|
suppressLeadingAndTrailingTrivia(node);
|
|
143374
143637
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
143375
143638
|
}
|
|
143376
|
-
var
|
|
143639
|
+
var fixId31, didYouMeanStaticMemberCode, errorCodes37;
|
|
143377
143640
|
var init_fixForgottenThisPropertyAccess = __esm({
|
|
143378
143641
|
"src/services/codefixes/fixForgottenThisPropertyAccess.ts"() {
|
|
143379
143642
|
"use strict";
|
|
143380
143643
|
init_ts4();
|
|
143381
143644
|
init_ts_codefix();
|
|
143382
|
-
|
|
143645
|
+
fixId31 = "forgottenThisPropertyAccess";
|
|
143383
143646
|
didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
143384
|
-
|
|
143647
|
+
errorCodes37 = [
|
|
143385
143648
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
143386
143649
|
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,
|
|
143387
143650
|
didYouMeanStaticMemberCode
|
|
143388
143651
|
];
|
|
143389
143652
|
registerCodeFix({
|
|
143390
|
-
errorCodes:
|
|
143653
|
+
errorCodes: errorCodes37,
|
|
143391
143654
|
getCodeActions(context) {
|
|
143392
143655
|
const { sourceFile } = context;
|
|
143393
143656
|
const info = getInfo9(sourceFile, context.span.start, context.errorCode);
|
|
143394
143657
|
if (!info) {
|
|
143395
143658
|
return void 0;
|
|
143396
143659
|
}
|
|
143397
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143398
|
-
return [createCodeFixAction(
|
|
143660
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, info));
|
|
143661
|
+
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)];
|
|
143399
143662
|
},
|
|
143400
|
-
fixIds: [
|
|
143401
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143663
|
+
fixIds: [fixId31],
|
|
143664
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
143402
143665
|
const info = getInfo9(diag2.file, diag2.start, diag2.code);
|
|
143403
143666
|
if (info)
|
|
143404
|
-
|
|
143667
|
+
doChange17(changes, context.sourceFile, info);
|
|
143405
143668
|
})
|
|
143406
143669
|
});
|
|
143407
143670
|
}
|
|
@@ -143411,7 +143674,7 @@ ${lanes.join("\n")}
|
|
|
143411
143674
|
function isValidCharacter(character) {
|
|
143412
143675
|
return hasProperty(htmlEntity, character);
|
|
143413
143676
|
}
|
|
143414
|
-
function
|
|
143677
|
+
function doChange18(changes, preferences, sourceFile, start, useHtmlEntity) {
|
|
143415
143678
|
const character = sourceFile.getText()[start];
|
|
143416
143679
|
if (!isValidCharacter(character)) {
|
|
143417
143680
|
return;
|
|
@@ -143419,7 +143682,7 @@ ${lanes.join("\n")}
|
|
|
143419
143682
|
const replacement = useHtmlEntity ? htmlEntity[character] : `{${quote(sourceFile, preferences, character)}}`;
|
|
143420
143683
|
changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement);
|
|
143421
143684
|
}
|
|
143422
|
-
var fixIdExpression, fixIdHtmlEntity,
|
|
143685
|
+
var fixIdExpression, fixIdHtmlEntity, errorCodes38, htmlEntity;
|
|
143423
143686
|
var init_fixInvalidJsxCharacters = __esm({
|
|
143424
143687
|
"src/services/codefixes/fixInvalidJsxCharacters.ts"() {
|
|
143425
143688
|
"use strict";
|
|
@@ -143427,16 +143690,16 @@ ${lanes.join("\n")}
|
|
|
143427
143690
|
init_ts_codefix();
|
|
143428
143691
|
fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
143429
143692
|
fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
143430
|
-
|
|
143693
|
+
errorCodes38 = [
|
|
143431
143694
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
143432
143695
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
143433
143696
|
];
|
|
143434
143697
|
registerCodeFix({
|
|
143435
|
-
errorCodes:
|
|
143698
|
+
errorCodes: errorCodes38,
|
|
143436
143699
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
143437
143700
|
getCodeActions(context) {
|
|
143438
143701
|
const { sourceFile, preferences, span } = context;
|
|
143439
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143702
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
143440
143703
|
t,
|
|
143441
143704
|
preferences,
|
|
143442
143705
|
sourceFile,
|
|
@@ -143444,7 +143707,7 @@ ${lanes.join("\n")}
|
|
|
143444
143707
|
/* useHtmlEntity */
|
|
143445
143708
|
false
|
|
143446
143709
|
));
|
|
143447
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143710
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
143448
143711
|
t,
|
|
143449
143712
|
preferences,
|
|
143450
143713
|
sourceFile,
|
|
@@ -143458,7 +143721,7 @@ ${lanes.join("\n")}
|
|
|
143458
143721
|
];
|
|
143459
143722
|
},
|
|
143460
143723
|
getAllCodeActions(context) {
|
|
143461
|
-
return codeFixAll(context,
|
|
143724
|
+
return codeFixAll(context, errorCodes38, (changes, diagnostic) => doChange18(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
143462
143725
|
}
|
|
143463
143726
|
});
|
|
143464
143727
|
htmlEntity = {
|
|
@@ -143517,7 +143780,7 @@ ${lanes.join("\n")}
|
|
|
143517
143780
|
}
|
|
143518
143781
|
return void 0;
|
|
143519
143782
|
}
|
|
143520
|
-
var deleteUnmatchedParameter, renameUnmatchedParameter,
|
|
143783
|
+
var deleteUnmatchedParameter, renameUnmatchedParameter, errorCodes39;
|
|
143521
143784
|
var init_fixUnmatchedParameter = __esm({
|
|
143522
143785
|
"src/services/codefixes/fixUnmatchedParameter.ts"() {
|
|
143523
143786
|
"use strict";
|
|
@@ -143525,12 +143788,12 @@ ${lanes.join("\n")}
|
|
|
143525
143788
|
init_ts_codefix();
|
|
143526
143789
|
deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
143527
143790
|
renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
143528
|
-
|
|
143791
|
+
errorCodes39 = [
|
|
143529
143792
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
143530
143793
|
];
|
|
143531
143794
|
registerCodeFix({
|
|
143532
143795
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
143533
|
-
errorCodes:
|
|
143796
|
+
errorCodes: errorCodes39,
|
|
143534
143797
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
143535
143798
|
const { sourceFile, span } = context;
|
|
143536
143799
|
const actions2 = [];
|
|
@@ -143545,7 +143808,7 @@ ${lanes.join("\n")}
|
|
|
143545
143808
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
143546
143809
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
143547
143810
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
143548
|
-
eachDiagnostic(context,
|
|
143811
|
+
eachDiagnostic(context, errorCodes39, ({ file, start }) => {
|
|
143549
143812
|
const info = getInfo10(file, start);
|
|
143550
143813
|
if (info) {
|
|
143551
143814
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -143594,16 +143857,16 @@ ${lanes.join("\n")}
|
|
|
143594
143857
|
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
|
|
143595
143858
|
ts_refactor_exports.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
|
|
143596
143859
|
}
|
|
143597
|
-
var
|
|
143860
|
+
var fixId32, errorCodes40;
|
|
143598
143861
|
var init_fixUnreferenceableDecoratorMetadata = __esm({
|
|
143599
143862
|
"src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts"() {
|
|
143600
143863
|
"use strict";
|
|
143601
143864
|
init_ts4();
|
|
143602
143865
|
init_ts_codefix();
|
|
143603
|
-
|
|
143604
|
-
|
|
143866
|
+
fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
143867
|
+
errorCodes40 = [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];
|
|
143605
143868
|
registerCodeFix({
|
|
143606
|
-
errorCodes:
|
|
143869
|
+
errorCodes: errorCodes40,
|
|
143607
143870
|
getCodeActions: (context) => {
|
|
143608
143871
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
143609
143872
|
if (!importDeclaration)
|
|
@@ -143612,14 +143875,14 @@ ${lanes.join("\n")}
|
|
|
143612
143875
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
143613
143876
|
let actions2;
|
|
143614
143877
|
if (namespaceChanges.length) {
|
|
143615
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
143878
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
143616
143879
|
}
|
|
143617
143880
|
if (typeOnlyChanges.length) {
|
|
143618
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
143881
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
143619
143882
|
}
|
|
143620
143883
|
return actions2;
|
|
143621
143884
|
},
|
|
143622
|
-
fixIds: [
|
|
143885
|
+
fixIds: [fixId32]
|
|
143623
143886
|
});
|
|
143624
143887
|
}
|
|
143625
143888
|
});
|
|
@@ -143772,7 +144035,7 @@ ${lanes.join("\n")}
|
|
|
143772
144035
|
function mayDeleteExpression(node) {
|
|
143773
144036
|
return (isBinaryExpression(node.parent) && node.parent.left === node || (isPostfixUnaryExpression(node.parent) || isPrefixUnaryExpression(node.parent)) && node.parent.operand === node) && isExpressionStatement(node.parent.parent);
|
|
143774
144037
|
}
|
|
143775
|
-
var fixName3, fixIdPrefix, fixIdDelete, fixIdDeleteImports, fixIdInfer,
|
|
144038
|
+
var fixName3, fixIdPrefix, fixIdDelete, fixIdDeleteImports, fixIdInfer, errorCodes41;
|
|
143776
144039
|
var init_fixUnusedIdentifier = __esm({
|
|
143777
144040
|
"src/services/codefixes/fixUnusedIdentifier.ts"() {
|
|
143778
144041
|
"use strict";
|
|
@@ -143783,7 +144046,7 @@ ${lanes.join("\n")}
|
|
|
143783
144046
|
fixIdDelete = "unusedIdentifier_delete";
|
|
143784
144047
|
fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
143785
144048
|
fixIdInfer = "unusedIdentifier_infer";
|
|
143786
|
-
|
|
144049
|
+
errorCodes41 = [
|
|
143787
144050
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
143788
144051
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
143789
144052
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -143793,7 +144056,7 @@ ${lanes.join("\n")}
|
|
|
143793
144056
|
Diagnostics.All_type_parameters_are_unused.code
|
|
143794
144057
|
];
|
|
143795
144058
|
registerCodeFix({
|
|
143796
|
-
errorCodes:
|
|
144059
|
+
errorCodes: errorCodes41,
|
|
143797
144060
|
getCodeActions(context) {
|
|
143798
144061
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
143799
144062
|
const checker = program.getTypeChecker();
|
|
@@ -143879,7 +144142,7 @@ ${lanes.join("\n")}
|
|
|
143879
144142
|
const { sourceFile, program, cancellationToken } = context;
|
|
143880
144143
|
const checker = program.getTypeChecker();
|
|
143881
144144
|
const sourceFiles = program.getSourceFiles();
|
|
143882
|
-
return codeFixAll(context,
|
|
144145
|
+
return codeFixAll(context, errorCodes41, (changes, diag2) => {
|
|
143883
144146
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
143884
144147
|
switch (context.fixId) {
|
|
143885
144148
|
case fixIdPrefix:
|
|
@@ -143951,7 +144214,7 @@ ${lanes.join("\n")}
|
|
|
143951
144214
|
});
|
|
143952
144215
|
|
|
143953
144216
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
143954
|
-
function
|
|
144217
|
+
function doChange19(changes, sourceFile, start, length2, errorCode) {
|
|
143955
144218
|
const token = getTokenAtPosition(sourceFile, start);
|
|
143956
144219
|
const statement = findAncestor(token, isStatement);
|
|
143957
144220
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -143999,31 +144262,31 @@ ${lanes.join("\n")}
|
|
|
143999
144262
|
}
|
|
144000
144263
|
return last2;
|
|
144001
144264
|
}
|
|
144002
|
-
var
|
|
144265
|
+
var fixId33, errorCodes42;
|
|
144003
144266
|
var init_fixUnreachableCode = __esm({
|
|
144004
144267
|
"src/services/codefixes/fixUnreachableCode.ts"() {
|
|
144005
144268
|
"use strict";
|
|
144006
144269
|
init_ts4();
|
|
144007
144270
|
init_ts_codefix();
|
|
144008
|
-
|
|
144009
|
-
|
|
144271
|
+
fixId33 = "fixUnreachableCode";
|
|
144272
|
+
errorCodes42 = [Diagnostics.Unreachable_code_detected.code];
|
|
144010
144273
|
registerCodeFix({
|
|
144011
|
-
errorCodes:
|
|
144274
|
+
errorCodes: errorCodes42,
|
|
144012
144275
|
getCodeActions(context) {
|
|
144013
144276
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
144014
144277
|
if (syntacticDiagnostics.length)
|
|
144015
144278
|
return;
|
|
144016
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144017
|
-
return [createCodeFixAction(
|
|
144279
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
144280
|
+
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
144018
144281
|
},
|
|
144019
|
-
fixIds: [
|
|
144020
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144282
|
+
fixIds: [fixId33],
|
|
144283
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes42, (changes, diag2) => doChange19(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
144021
144284
|
});
|
|
144022
144285
|
}
|
|
144023
144286
|
});
|
|
144024
144287
|
|
|
144025
144288
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
144026
|
-
function
|
|
144289
|
+
function doChange20(changes, sourceFile, start) {
|
|
144027
144290
|
const token = getTokenAtPosition(sourceFile, start);
|
|
144028
144291
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
144029
144292
|
const pos = token.getStart(sourceFile);
|
|
@@ -144036,28 +144299,28 @@ ${lanes.join("\n")}
|
|
|
144036
144299
|
);
|
|
144037
144300
|
changes.deleteRange(sourceFile, { pos, end });
|
|
144038
144301
|
}
|
|
144039
|
-
var
|
|
144302
|
+
var fixId34, errorCodes43;
|
|
144040
144303
|
var init_fixUnusedLabel = __esm({
|
|
144041
144304
|
"src/services/codefixes/fixUnusedLabel.ts"() {
|
|
144042
144305
|
"use strict";
|
|
144043
144306
|
init_ts4();
|
|
144044
144307
|
init_ts_codefix();
|
|
144045
|
-
|
|
144046
|
-
|
|
144308
|
+
fixId34 = "fixUnusedLabel";
|
|
144309
|
+
errorCodes43 = [Diagnostics.Unused_label.code];
|
|
144047
144310
|
registerCodeFix({
|
|
144048
|
-
errorCodes:
|
|
144311
|
+
errorCodes: errorCodes43,
|
|
144049
144312
|
getCodeActions(context) {
|
|
144050
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144051
|
-
return [createCodeFixAction(
|
|
144313
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, context.sourceFile, context.span.start));
|
|
144314
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
144052
144315
|
},
|
|
144053
|
-
fixIds: [
|
|
144054
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144316
|
+
fixIds: [fixId34],
|
|
144317
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange20(changes, diag2.file, diag2.start))
|
|
144055
144318
|
});
|
|
144056
144319
|
}
|
|
144057
144320
|
});
|
|
144058
144321
|
|
|
144059
144322
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
144060
|
-
function
|
|
144323
|
+
function doChange21(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
144061
144324
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
144062
144325
|
newType,
|
|
144063
144326
|
/*enclosingDeclaration*/
|
|
@@ -144106,7 +144369,7 @@ ${lanes.join("\n")}
|
|
|
144106
144369
|
}
|
|
144107
144370
|
return checker.getTypeFromTypeNode(node);
|
|
144108
144371
|
}
|
|
144109
|
-
var fixIdPlain, fixIdNullable,
|
|
144372
|
+
var fixIdPlain, fixIdNullable, errorCodes44;
|
|
144110
144373
|
var init_fixJSDocTypes = __esm({
|
|
144111
144374
|
"src/services/codefixes/fixJSDocTypes.ts"() {
|
|
144112
144375
|
"use strict";
|
|
@@ -144114,13 +144377,13 @@ ${lanes.join("\n")}
|
|
|
144114
144377
|
init_ts_codefix();
|
|
144115
144378
|
fixIdPlain = "fixJSDocTypes_plain";
|
|
144116
144379
|
fixIdNullable = "fixJSDocTypes_nullable";
|
|
144117
|
-
|
|
144380
|
+
errorCodes44 = [
|
|
144118
144381
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
144119
144382
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
144120
144383
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
144121
144384
|
];
|
|
144122
144385
|
registerCodeFix({
|
|
144123
|
-
errorCodes:
|
|
144386
|
+
errorCodes: errorCodes44,
|
|
144124
144387
|
getCodeActions(context) {
|
|
144125
144388
|
const { sourceFile } = context;
|
|
144126
144389
|
const checker = context.program.getTypeChecker();
|
|
@@ -144134,22 +144397,22 @@ ${lanes.join("\n")}
|
|
|
144134
144397
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
144135
144398
|
}
|
|
144136
144399
|
return actions2;
|
|
144137
|
-
function fix(type2,
|
|
144138
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144139
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
144400
|
+
function fix(type2, fixId52, fixAllDescription) {
|
|
144401
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, typeNode, type2, checker));
|
|
144402
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
144140
144403
|
}
|
|
144141
144404
|
},
|
|
144142
144405
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
144143
144406
|
getAllCodeActions(context) {
|
|
144144
|
-
const { fixId:
|
|
144407
|
+
const { fixId: fixId52, program, sourceFile } = context;
|
|
144145
144408
|
const checker = program.getTypeChecker();
|
|
144146
|
-
return codeFixAll(context,
|
|
144409
|
+
return codeFixAll(context, errorCodes44, (changes, err) => {
|
|
144147
144410
|
const info = getInfo11(err.file, err.start, checker);
|
|
144148
144411
|
if (!info)
|
|
144149
144412
|
return;
|
|
144150
144413
|
const { typeNode, type } = info;
|
|
144151
|
-
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ &&
|
|
144152
|
-
|
|
144414
|
+
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
144415
|
+
doChange21(changes, sourceFile, typeNode, fixedType, checker);
|
|
144153
144416
|
});
|
|
144154
144417
|
}
|
|
144155
144418
|
});
|
|
@@ -144157,7 +144420,7 @@ ${lanes.join("\n")}
|
|
|
144157
144420
|
});
|
|
144158
144421
|
|
|
144159
144422
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
144160
|
-
function
|
|
144423
|
+
function doChange22(changes, sourceFile, name) {
|
|
144161
144424
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
144162
144425
|
}
|
|
144163
144426
|
function getCallName(sourceFile, start) {
|
|
@@ -144174,31 +144437,31 @@ ${lanes.join("\n")}
|
|
|
144174
144437
|
}
|
|
144175
144438
|
return void 0;
|
|
144176
144439
|
}
|
|
144177
|
-
var
|
|
144440
|
+
var fixId35, errorCodes45;
|
|
144178
144441
|
var init_fixMissingCallParentheses = __esm({
|
|
144179
144442
|
"src/services/codefixes/fixMissingCallParentheses.ts"() {
|
|
144180
144443
|
"use strict";
|
|
144181
144444
|
init_ts4();
|
|
144182
144445
|
init_ts_codefix();
|
|
144183
|
-
|
|
144184
|
-
|
|
144446
|
+
fixId35 = "fixMissingCallParentheses";
|
|
144447
|
+
errorCodes45 = [
|
|
144185
144448
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
144186
144449
|
];
|
|
144187
144450
|
registerCodeFix({
|
|
144188
|
-
errorCodes:
|
|
144189
|
-
fixIds: [
|
|
144451
|
+
errorCodes: errorCodes45,
|
|
144452
|
+
fixIds: [fixId35],
|
|
144190
144453
|
getCodeActions(context) {
|
|
144191
144454
|
const { sourceFile, span } = context;
|
|
144192
144455
|
const callName = getCallName(sourceFile, span.start);
|
|
144193
144456
|
if (!callName)
|
|
144194
144457
|
return;
|
|
144195
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144196
|
-
return [createCodeFixAction(
|
|
144458
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange22(t, context.sourceFile, callName));
|
|
144459
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
144197
144460
|
},
|
|
144198
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144461
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => {
|
|
144199
144462
|
const callName = getCallName(diag2.file, diag2.start);
|
|
144200
144463
|
if (callName)
|
|
144201
|
-
|
|
144464
|
+
doChange22(changes, diag2.file, callName);
|
|
144202
144465
|
})
|
|
144203
144466
|
});
|
|
144204
144467
|
}
|
|
@@ -144240,7 +144503,7 @@ ${lanes.join("\n")}
|
|
|
144240
144503
|
returnType: getReturnType(containingFunction)
|
|
144241
144504
|
};
|
|
144242
144505
|
}
|
|
144243
|
-
function
|
|
144506
|
+
function doChange23(changes, sourceFile, { insertBefore, returnType }) {
|
|
144244
144507
|
if (returnType) {
|
|
144245
144508
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
144246
144509
|
if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -144249,36 +144512,36 @@ ${lanes.join("\n")}
|
|
|
144249
144512
|
}
|
|
144250
144513
|
changes.insertModifierBefore(sourceFile, 132 /* AsyncKeyword */, insertBefore);
|
|
144251
144514
|
}
|
|
144252
|
-
var
|
|
144515
|
+
var fixId36, errorCodes46;
|
|
144253
144516
|
var init_fixAwaitInSyncFunction = __esm({
|
|
144254
144517
|
"src/services/codefixes/fixAwaitInSyncFunction.ts"() {
|
|
144255
144518
|
"use strict";
|
|
144256
144519
|
init_ts4();
|
|
144257
144520
|
init_ts_codefix();
|
|
144258
|
-
|
|
144259
|
-
|
|
144521
|
+
fixId36 = "fixAwaitInSyncFunction";
|
|
144522
|
+
errorCodes46 = [
|
|
144260
144523
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
144261
144524
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
144262
144525
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
144263
144526
|
];
|
|
144264
144527
|
registerCodeFix({
|
|
144265
|
-
errorCodes:
|
|
144528
|
+
errorCodes: errorCodes46,
|
|
144266
144529
|
getCodeActions(context) {
|
|
144267
144530
|
const { sourceFile, span } = context;
|
|
144268
144531
|
const nodes = getNodes3(sourceFile, span.start);
|
|
144269
144532
|
if (!nodes)
|
|
144270
144533
|
return void 0;
|
|
144271
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144272
|
-
return [createCodeFixAction(
|
|
144534
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, nodes));
|
|
144535
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
144273
144536
|
},
|
|
144274
|
-
fixIds: [
|
|
144537
|
+
fixIds: [fixId36],
|
|
144275
144538
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
144276
144539
|
const seen = /* @__PURE__ */ new Map();
|
|
144277
|
-
return codeFixAll(context,
|
|
144540
|
+
return codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
144278
144541
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
144279
144542
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
144280
144543
|
return;
|
|
144281
|
-
|
|
144544
|
+
doChange23(changes, context.sourceFile, nodes);
|
|
144282
144545
|
});
|
|
144283
144546
|
}
|
|
144284
144547
|
});
|
|
@@ -144286,7 +144549,7 @@ ${lanes.join("\n")}
|
|
|
144286
144549
|
});
|
|
144287
144550
|
|
|
144288
144551
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
144289
|
-
function
|
|
144552
|
+
function doChange24(file, start, length2, code, context) {
|
|
144290
144553
|
let startPosition;
|
|
144291
144554
|
let endPosition;
|
|
144292
144555
|
if (code === Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code) {
|
|
@@ -144313,28 +144576,28 @@ ${lanes.join("\n")}
|
|
|
144313
144576
|
}
|
|
144314
144577
|
return generateAccessorFromProperty(file, context.program, startPosition, endPosition, context, Diagnostics.Generate_get_and_set_accessors.message);
|
|
144315
144578
|
}
|
|
144316
|
-
var
|
|
144579
|
+
var errorCodes47, fixId37;
|
|
144317
144580
|
var init_fixPropertyOverrideAccessor = __esm({
|
|
144318
144581
|
"src/services/codefixes/fixPropertyOverrideAccessor.ts"() {
|
|
144319
144582
|
"use strict";
|
|
144320
144583
|
init_ts4();
|
|
144321
144584
|
init_ts_codefix();
|
|
144322
|
-
|
|
144585
|
+
errorCodes47 = [
|
|
144323
144586
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
144324
144587
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
144325
144588
|
];
|
|
144326
|
-
|
|
144589
|
+
fixId37 = "fixPropertyOverrideAccessor";
|
|
144327
144590
|
registerCodeFix({
|
|
144328
|
-
errorCodes:
|
|
144591
|
+
errorCodes: errorCodes47,
|
|
144329
144592
|
getCodeActions(context) {
|
|
144330
|
-
const edits =
|
|
144593
|
+
const edits = doChange24(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
144331
144594
|
if (edits) {
|
|
144332
|
-
return [createCodeFixAction(
|
|
144595
|
+
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
144333
144596
|
}
|
|
144334
144597
|
},
|
|
144335
|
-
fixIds: [
|
|
144336
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144337
|
-
const edits =
|
|
144598
|
+
fixIds: [fixId37],
|
|
144599
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
144600
|
+
const edits = doChange24(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
144338
144601
|
if (edits) {
|
|
144339
144602
|
for (const edit of edits) {
|
|
144340
144603
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -144381,7 +144644,7 @@ ${lanes.join("\n")}
|
|
|
144381
144644
|
}
|
|
144382
144645
|
return errorCode;
|
|
144383
144646
|
}
|
|
144384
|
-
function
|
|
144647
|
+
function doChange25(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
144385
144648
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) {
|
|
144386
144649
|
return void 0;
|
|
144387
144650
|
}
|
|
@@ -145045,7 +145308,7 @@ ${lanes.join("\n")}
|
|
|
145045
145308
|
const props = createMultiMap();
|
|
145046
145309
|
for (const anon2 of anons) {
|
|
145047
145310
|
for (const p of checker.getPropertiesOfType(anon2)) {
|
|
145048
|
-
props.add(p.
|
|
145311
|
+
props.add(p.escapedName, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType());
|
|
145049
145312
|
}
|
|
145050
145313
|
calls.push(...checker.getSignaturesOfType(anon2, 0 /* Call */));
|
|
145051
145314
|
constructs.push(...checker.getSignaturesOfType(anon2, 1 /* Construct */));
|
|
@@ -145275,14 +145538,14 @@ ${lanes.join("\n")}
|
|
|
145275
145538
|
}
|
|
145276
145539
|
}
|
|
145277
145540
|
}
|
|
145278
|
-
var
|
|
145541
|
+
var fixId38, errorCodes48;
|
|
145279
145542
|
var init_inferFromUsage = __esm({
|
|
145280
145543
|
"src/services/codefixes/inferFromUsage.ts"() {
|
|
145281
145544
|
"use strict";
|
|
145282
145545
|
init_ts4();
|
|
145283
145546
|
init_ts_codefix();
|
|
145284
|
-
|
|
145285
|
-
|
|
145547
|
+
fixId38 = "inferFromUsage";
|
|
145548
|
+
errorCodes48 = [
|
|
145286
145549
|
// Variable declarations
|
|
145287
145550
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
145288
145551
|
// Variable uses
|
|
@@ -145316,13 +145579,13 @@ ${lanes.join("\n")}
|
|
|
145316
145579
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
145317
145580
|
];
|
|
145318
145581
|
registerCodeFix({
|
|
145319
|
-
errorCodes:
|
|
145582
|
+
errorCodes: errorCodes48,
|
|
145320
145583
|
getCodeActions(context) {
|
|
145321
145584
|
const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
|
|
145322
145585
|
const token = getTokenAtPosition(sourceFile, start);
|
|
145323
145586
|
let declaration;
|
|
145324
145587
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
145325
|
-
declaration =
|
|
145588
|
+
declaration = doChange25(
|
|
145326
145589
|
changes2,
|
|
145327
145590
|
sourceFile,
|
|
145328
145591
|
token,
|
|
@@ -145336,14 +145599,14 @@ ${lanes.join("\n")}
|
|
|
145336
145599
|
);
|
|
145337
145600
|
});
|
|
145338
145601
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
145339
|
-
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
145602
|
+
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
|
|
145340
145603
|
},
|
|
145341
|
-
fixIds: [
|
|
145604
|
+
fixIds: [fixId38],
|
|
145342
145605
|
getAllCodeActions(context) {
|
|
145343
145606
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
145344
145607
|
const markSeen = nodeSeenTracker();
|
|
145345
|
-
return codeFixAll(context,
|
|
145346
|
-
|
|
145608
|
+
return codeFixAll(context, errorCodes48, (changes, err) => {
|
|
145609
|
+
doChange25(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
145347
145610
|
});
|
|
145348
145611
|
}
|
|
145349
145612
|
});
|
|
@@ -145374,22 +145637,22 @@ ${lanes.join("\n")}
|
|
|
145374
145637
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
145375
145638
|
}
|
|
145376
145639
|
}
|
|
145377
|
-
function
|
|
145640
|
+
function doChange26(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
145378
145641
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
145379
145642
|
}
|
|
145380
|
-
var
|
|
145643
|
+
var fixId39, errorCodes49;
|
|
145381
145644
|
var init_fixReturnTypeInAsyncFunction = __esm({
|
|
145382
145645
|
"src/services/codefixes/fixReturnTypeInAsyncFunction.ts"() {
|
|
145383
145646
|
"use strict";
|
|
145384
145647
|
init_ts4();
|
|
145385
145648
|
init_ts_codefix();
|
|
145386
|
-
|
|
145387
|
-
|
|
145649
|
+
fixId39 = "fixReturnTypeInAsyncFunction";
|
|
145650
|
+
errorCodes49 = [
|
|
145388
145651
|
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
|
|
145389
145652
|
];
|
|
145390
145653
|
registerCodeFix({
|
|
145391
|
-
errorCodes:
|
|
145392
|
-
fixIds: [
|
|
145654
|
+
errorCodes: errorCodes49,
|
|
145655
|
+
fixIds: [fixId39],
|
|
145393
145656
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
145394
145657
|
const { sourceFile, program, span } = context;
|
|
145395
145658
|
const checker = program.getTypeChecker();
|
|
@@ -145398,23 +145661,23 @@ ${lanes.join("\n")}
|
|
|
145398
145661
|
return void 0;
|
|
145399
145662
|
}
|
|
145400
145663
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
145401
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145664
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
145402
145665
|
return [createCodeFixAction(
|
|
145403
|
-
|
|
145666
|
+
fixId39,
|
|
145404
145667
|
changes,
|
|
145405
145668
|
[
|
|
145406
145669
|
Diagnostics.Replace_0_with_Promise_1,
|
|
145407
145670
|
checker.typeToString(returnType),
|
|
145408
145671
|
checker.typeToString(promisedType)
|
|
145409
145672
|
],
|
|
145410
|
-
|
|
145673
|
+
fixId39,
|
|
145411
145674
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
145412
145675
|
)];
|
|
145413
145676
|
},
|
|
145414
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145677
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
145415
145678
|
const info = getInfo12(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
145416
145679
|
if (info) {
|
|
145417
|
-
|
|
145680
|
+
doChange26(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
145418
145681
|
}
|
|
145419
145682
|
})
|
|
145420
145683
|
});
|
|
@@ -145428,20 +145691,20 @@ ${lanes.join("\n")}
|
|
|
145428
145691
|
changes.insertCommentBeforeLine(sourceFile, lineNumber, position, " @ts-ignore");
|
|
145429
145692
|
}
|
|
145430
145693
|
}
|
|
145431
|
-
var fixName4,
|
|
145694
|
+
var fixName4, fixId40, errorCodes50;
|
|
145432
145695
|
var init_disableJsDiagnostics = __esm({
|
|
145433
145696
|
"src/services/codefixes/disableJsDiagnostics.ts"() {
|
|
145434
145697
|
"use strict";
|
|
145435
145698
|
init_ts4();
|
|
145436
145699
|
init_ts_codefix();
|
|
145437
145700
|
fixName4 = "disableJsDiagnostics";
|
|
145438
|
-
|
|
145439
|
-
|
|
145701
|
+
fixId40 = "disableJsDiagnostics";
|
|
145702
|
+
errorCodes50 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
145440
145703
|
const diag2 = Diagnostics[key];
|
|
145441
145704
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
145442
145705
|
});
|
|
145443
145706
|
registerCodeFix({
|
|
145444
|
-
errorCodes:
|
|
145707
|
+
errorCodes: errorCodes50,
|
|
145445
145708
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
145446
145709
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
145447
145710
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -145459,14 +145722,14 @@ ${lanes.join("\n")}
|
|
|
145459
145722
|
)
|
|
145460
145723
|
];
|
|
145461
145724
|
if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
|
|
145462
|
-
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message,
|
|
145725
|
+
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId40, Diagnostics.Add_ts_ignore_to_all_error_messages));
|
|
145463
145726
|
}
|
|
145464
145727
|
return fixes;
|
|
145465
145728
|
},
|
|
145466
|
-
fixIds: [
|
|
145729
|
+
fixIds: [fixId40],
|
|
145467
145730
|
getAllCodeActions: (context) => {
|
|
145468
145731
|
const seenLines = /* @__PURE__ */ new Set();
|
|
145469
|
-
return codeFixAll(context,
|
|
145732
|
+
return codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
145470
145733
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
145471
145734
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
145472
145735
|
}
|
|
@@ -146563,7 +146826,7 @@ ${lanes.join("\n")}
|
|
|
146563
146826
|
}
|
|
146564
146827
|
return void 0;
|
|
146565
146828
|
}
|
|
146566
|
-
var fixName6, fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer,
|
|
146829
|
+
var fixName6, fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer, errorCodes51;
|
|
146567
146830
|
var init_fixStrictClassInitialization = __esm({
|
|
146568
146831
|
"src/services/codefixes/fixStrictClassInitialization.ts"() {
|
|
146569
146832
|
"use strict";
|
|
@@ -146573,9 +146836,9 @@ ${lanes.join("\n")}
|
|
|
146573
146836
|
fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
146574
146837
|
fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
146575
146838
|
fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
146576
|
-
|
|
146839
|
+
errorCodes51 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
146577
146840
|
registerCodeFix({
|
|
146578
|
-
errorCodes:
|
|
146841
|
+
errorCodes: errorCodes51,
|
|
146579
146842
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
146580
146843
|
const info = getInfo13(context.sourceFile, context.span.start);
|
|
146581
146844
|
if (!info)
|
|
@@ -146588,7 +146851,7 @@ ${lanes.join("\n")}
|
|
|
146588
146851
|
},
|
|
146589
146852
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
146590
146853
|
getAllCodeActions: (context) => {
|
|
146591
|
-
return codeFixAll(context,
|
|
146854
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
146592
146855
|
const info = getInfo13(diag2.file, diag2.start);
|
|
146593
146856
|
if (!info)
|
|
146594
146857
|
return;
|
|
@@ -146616,7 +146879,7 @@ ${lanes.join("\n")}
|
|
|
146616
146879
|
});
|
|
146617
146880
|
|
|
146618
146881
|
// src/services/codefixes/requireInTs.ts
|
|
146619
|
-
function
|
|
146882
|
+
function doChange27(changes, sourceFile, info) {
|
|
146620
146883
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
146621
146884
|
changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults ? factory.createImportEqualsDeclaration(
|
|
146622
146885
|
/*modifiers*/
|
|
@@ -146678,29 +146941,29 @@ ${lanes.join("\n")}
|
|
|
146678
146941
|
return factory.createNamedImports(importSpecifiers);
|
|
146679
146942
|
}
|
|
146680
146943
|
}
|
|
146681
|
-
var
|
|
146944
|
+
var fixId41, errorCodes52;
|
|
146682
146945
|
var init_requireInTs = __esm({
|
|
146683
146946
|
"src/services/codefixes/requireInTs.ts"() {
|
|
146684
146947
|
"use strict";
|
|
146685
146948
|
init_ts4();
|
|
146686
146949
|
init_ts_codefix();
|
|
146687
|
-
|
|
146688
|
-
|
|
146950
|
+
fixId41 = "requireInTs";
|
|
146951
|
+
errorCodes52 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
146689
146952
|
registerCodeFix({
|
|
146690
|
-
errorCodes:
|
|
146953
|
+
errorCodes: errorCodes52,
|
|
146691
146954
|
getCodeActions(context) {
|
|
146692
146955
|
const info = getInfo14(context.sourceFile, context.program, context.span.start);
|
|
146693
146956
|
if (!info) {
|
|
146694
146957
|
return void 0;
|
|
146695
146958
|
}
|
|
146696
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146697
|
-
return [createCodeFixAction(
|
|
146959
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, info));
|
|
146960
|
+
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
146698
146961
|
},
|
|
146699
|
-
fixIds: [
|
|
146700
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
146962
|
+
fixIds: [fixId41],
|
|
146963
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
146701
146964
|
const info = getInfo14(diag2.file, context.program, diag2.start);
|
|
146702
146965
|
if (info) {
|
|
146703
|
-
|
|
146966
|
+
doChange27(changes, context.sourceFile, info);
|
|
146704
146967
|
}
|
|
146705
146968
|
})
|
|
146706
146969
|
});
|
|
@@ -146720,7 +146983,7 @@ ${lanes.join("\n")}
|
|
|
146720
146983
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
146721
146984
|
}
|
|
146722
146985
|
}
|
|
146723
|
-
function
|
|
146986
|
+
function doChange28(changes, sourceFile, info, preferences) {
|
|
146724
146987
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
146725
146988
|
info.name,
|
|
146726
146989
|
/*namedImports*/
|
|
@@ -146729,29 +146992,29 @@ ${lanes.join("\n")}
|
|
|
146729
146992
|
getQuotePreference(sourceFile, preferences)
|
|
146730
146993
|
));
|
|
146731
146994
|
}
|
|
146732
|
-
var
|
|
146995
|
+
var fixId42, errorCodes53;
|
|
146733
146996
|
var init_useDefaultImport = __esm({
|
|
146734
146997
|
"src/services/codefixes/useDefaultImport.ts"() {
|
|
146735
146998
|
"use strict";
|
|
146736
146999
|
init_ts4();
|
|
146737
147000
|
init_ts_codefix();
|
|
146738
|
-
|
|
146739
|
-
|
|
147001
|
+
fixId42 = "useDefaultImport";
|
|
147002
|
+
errorCodes53 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
146740
147003
|
registerCodeFix({
|
|
146741
|
-
errorCodes:
|
|
147004
|
+
errorCodes: errorCodes53,
|
|
146742
147005
|
getCodeActions(context) {
|
|
146743
147006
|
const { sourceFile, span: { start } } = context;
|
|
146744
147007
|
const info = getInfo15(sourceFile, start);
|
|
146745
147008
|
if (!info)
|
|
146746
147009
|
return void 0;
|
|
146747
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146748
|
-
return [createCodeFixAction(
|
|
147010
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, sourceFile, info, context.preferences));
|
|
147011
|
+
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
146749
147012
|
},
|
|
146750
|
-
fixIds: [
|
|
146751
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147013
|
+
fixIds: [fixId42],
|
|
147014
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
146752
147015
|
const info = getInfo15(diag2.file, diag2.start);
|
|
146753
147016
|
if (info)
|
|
146754
|
-
|
|
147017
|
+
doChange28(changes, diag2.file, info, context.preferences);
|
|
146755
147018
|
})
|
|
146756
147019
|
});
|
|
146757
147020
|
}
|
|
@@ -146766,27 +147029,27 @@ ${lanes.join("\n")}
|
|
|
146766
147029
|
const newText = numericLiteral.getText(sourceFile) + "n";
|
|
146767
147030
|
changeTracker.replaceNode(sourceFile, numericLiteral, factory.createBigIntLiteral(newText));
|
|
146768
147031
|
}
|
|
146769
|
-
var
|
|
147032
|
+
var fixId43, errorCodes54;
|
|
146770
147033
|
var init_useBigintLiteral = __esm({
|
|
146771
147034
|
"src/services/codefixes/useBigintLiteral.ts"() {
|
|
146772
147035
|
"use strict";
|
|
146773
147036
|
init_ts4();
|
|
146774
147037
|
init_ts_codefix();
|
|
146775
|
-
|
|
146776
|
-
|
|
147038
|
+
fixId43 = "useBigintLiteral";
|
|
147039
|
+
errorCodes54 = [
|
|
146777
147040
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
146778
147041
|
];
|
|
146779
147042
|
registerCodeFix({
|
|
146780
|
-
errorCodes:
|
|
147043
|
+
errorCodes: errorCodes54,
|
|
146781
147044
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
146782
147045
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
146783
147046
|
if (changes.length > 0) {
|
|
146784
|
-
return [createCodeFixAction(
|
|
147047
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
146785
147048
|
}
|
|
146786
147049
|
},
|
|
146787
|
-
fixIds: [
|
|
147050
|
+
fixIds: [fixId43],
|
|
146788
147051
|
getAllCodeActions: (context) => {
|
|
146789
|
-
return codeFixAll(context,
|
|
147052
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
146790
147053
|
}
|
|
146791
147054
|
});
|
|
146792
147055
|
}
|
|
@@ -146799,7 +147062,7 @@ ${lanes.join("\n")}
|
|
|
146799
147062
|
Debug.assert(token.parent.kind === 202 /* ImportType */, "Token parent should be an ImportType");
|
|
146800
147063
|
return token.parent;
|
|
146801
147064
|
}
|
|
146802
|
-
function
|
|
147065
|
+
function doChange29(changes, sourceFile, importType) {
|
|
146803
147066
|
const newTypeNode = factory.updateImportTypeNode(
|
|
146804
147067
|
importType,
|
|
146805
147068
|
importType.argument,
|
|
@@ -146811,25 +147074,25 @@ ${lanes.join("\n")}
|
|
|
146811
147074
|
);
|
|
146812
147075
|
changes.replaceNode(sourceFile, importType, newTypeNode);
|
|
146813
147076
|
}
|
|
146814
|
-
var fixIdAddMissingTypeof,
|
|
147077
|
+
var fixIdAddMissingTypeof, fixId44, errorCodes55;
|
|
146815
147078
|
var init_fixAddModuleReferTypeMissingTypeof = __esm({
|
|
146816
147079
|
"src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts"() {
|
|
146817
147080
|
"use strict";
|
|
146818
147081
|
init_ts4();
|
|
146819
147082
|
init_ts_codefix();
|
|
146820
147083
|
fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
146821
|
-
|
|
146822
|
-
|
|
147084
|
+
fixId44 = fixIdAddMissingTypeof;
|
|
147085
|
+
errorCodes55 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
|
146823
147086
|
registerCodeFix({
|
|
146824
|
-
errorCodes:
|
|
147087
|
+
errorCodes: errorCodes55,
|
|
146825
147088
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
146826
147089
|
const { sourceFile, span } = context;
|
|
146827
147090
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
146828
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146829
|
-
return [createCodeFixAction(
|
|
147091
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, importType));
|
|
147092
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
146830
147093
|
},
|
|
146831
|
-
fixIds: [
|
|
146832
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147094
|
+
fixIds: [fixId44],
|
|
147095
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => doChange29(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
146833
147096
|
});
|
|
146834
147097
|
}
|
|
146835
147098
|
});
|
|
@@ -146848,7 +147111,7 @@ ${lanes.join("\n")}
|
|
|
146848
147111
|
return void 0;
|
|
146849
147112
|
return binaryExpr;
|
|
146850
147113
|
}
|
|
146851
|
-
function
|
|
147114
|
+
function doChange30(changeTracker, sf, node) {
|
|
146852
147115
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
146853
147116
|
if (jsx)
|
|
146854
147117
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -146871,30 +147134,30 @@ ${lanes.join("\n")}
|
|
|
146871
147134
|
return void 0;
|
|
146872
147135
|
}
|
|
146873
147136
|
}
|
|
146874
|
-
var fixID2,
|
|
147137
|
+
var fixID2, errorCodes56;
|
|
146875
147138
|
var init_wrapJsxInFragment = __esm({
|
|
146876
147139
|
"src/services/codefixes/wrapJsxInFragment.ts"() {
|
|
146877
147140
|
"use strict";
|
|
146878
147141
|
init_ts4();
|
|
146879
147142
|
init_ts_codefix();
|
|
146880
147143
|
fixID2 = "wrapJsxInFragment";
|
|
146881
|
-
|
|
147144
|
+
errorCodes56 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
146882
147145
|
registerCodeFix({
|
|
146883
|
-
errorCodes:
|
|
147146
|
+
errorCodes: errorCodes56,
|
|
146884
147147
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
146885
147148
|
const { sourceFile, span } = context;
|
|
146886
147149
|
const node = findNodeToFix(sourceFile, span.start);
|
|
146887
147150
|
if (!node)
|
|
146888
147151
|
return void 0;
|
|
146889
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147152
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, sourceFile, node));
|
|
146890
147153
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
146891
147154
|
},
|
|
146892
147155
|
fixIds: [fixID2],
|
|
146893
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147156
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
146894
147157
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
146895
147158
|
if (!node)
|
|
146896
147159
|
return void 0;
|
|
146897
|
-
|
|
147160
|
+
doChange30(changes, context.sourceFile, node);
|
|
146898
147161
|
})
|
|
146899
147162
|
});
|
|
146900
147163
|
}
|
|
@@ -146914,7 +147177,7 @@ ${lanes.join("\n")}
|
|
|
146914
147177
|
function createTypeAliasFromInterface(declaration, type) {
|
|
146915
147178
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
146916
147179
|
}
|
|
146917
|
-
function
|
|
147180
|
+
function doChange31(changes, sourceFile, { indexSignature, container }) {
|
|
146918
147181
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
146919
147182
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
146920
147183
|
const parameter = first(indexSignature.parameters);
|
|
@@ -146941,48 +147204,48 @@ ${lanes.join("\n")}
|
|
|
146941
147204
|
]);
|
|
146942
147205
|
changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType));
|
|
146943
147206
|
}
|
|
146944
|
-
var
|
|
147207
|
+
var fixId45, errorCodes57;
|
|
146945
147208
|
var init_convertToMappedObjectType = __esm({
|
|
146946
147209
|
"src/services/codefixes/convertToMappedObjectType.ts"() {
|
|
146947
147210
|
"use strict";
|
|
146948
147211
|
init_ts4();
|
|
146949
147212
|
init_ts_codefix();
|
|
146950
|
-
|
|
146951
|
-
|
|
147213
|
+
fixId45 = "fixConvertToMappedObjectType";
|
|
147214
|
+
errorCodes57 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
146952
147215
|
registerCodeFix({
|
|
146953
|
-
errorCodes:
|
|
147216
|
+
errorCodes: errorCodes57,
|
|
146954
147217
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
146955
147218
|
const { sourceFile, span } = context;
|
|
146956
147219
|
const info = getInfo16(sourceFile, span.start);
|
|
146957
147220
|
if (!info)
|
|
146958
147221
|
return void 0;
|
|
146959
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147222
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, info));
|
|
146960
147223
|
const name = idText(info.container.name);
|
|
146961
|
-
return [createCodeFixAction(
|
|
147224
|
+
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
146962
147225
|
},
|
|
146963
|
-
fixIds: [
|
|
146964
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147226
|
+
fixIds: [fixId45],
|
|
147227
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
146965
147228
|
const info = getInfo16(diag2.file, diag2.start);
|
|
146966
147229
|
if (info)
|
|
146967
|
-
|
|
147230
|
+
doChange31(changes, diag2.file, info);
|
|
146968
147231
|
})
|
|
146969
147232
|
});
|
|
146970
147233
|
}
|
|
146971
147234
|
});
|
|
146972
147235
|
|
|
146973
147236
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
146974
|
-
var
|
|
147237
|
+
var fixId46, errorCodes58;
|
|
146975
147238
|
var init_removeAccidentalCallParentheses = __esm({
|
|
146976
147239
|
"src/services/codefixes/removeAccidentalCallParentheses.ts"() {
|
|
146977
147240
|
"use strict";
|
|
146978
147241
|
init_ts4();
|
|
146979
147242
|
init_ts_codefix();
|
|
146980
|
-
|
|
146981
|
-
|
|
147243
|
+
fixId46 = "removeAccidentalCallParentheses";
|
|
147244
|
+
errorCodes58 = [
|
|
146982
147245
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
146983
147246
|
];
|
|
146984
147247
|
registerCodeFix({
|
|
146985
|
-
errorCodes:
|
|
147248
|
+
errorCodes: errorCodes58,
|
|
146986
147249
|
getCodeActions(context) {
|
|
146987
147250
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
146988
147251
|
if (!callExpression) {
|
|
@@ -146991,9 +147254,9 @@ ${lanes.join("\n")}
|
|
|
146991
147254
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
146992
147255
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
146993
147256
|
});
|
|
146994
|
-
return [createCodeFixActionWithoutFixAll(
|
|
147257
|
+
return [createCodeFixActionWithoutFixAll(fixId46, changes, Diagnostics.Remove_parentheses)];
|
|
146995
147258
|
},
|
|
146996
|
-
fixIds: [
|
|
147259
|
+
fixIds: [fixId46]
|
|
146997
147260
|
});
|
|
146998
147261
|
}
|
|
146999
147262
|
});
|
|
@@ -147022,27 +147285,27 @@ ${lanes.join("\n")}
|
|
|
147022
147285
|
}
|
|
147023
147286
|
changeTracker.replaceNode(sourceFile, expressionToReplace, awaitExpression.expression);
|
|
147024
147287
|
}
|
|
147025
|
-
var
|
|
147288
|
+
var fixId47, errorCodes59;
|
|
147026
147289
|
var init_removeUnnecessaryAwait = __esm({
|
|
147027
147290
|
"src/services/codefixes/removeUnnecessaryAwait.ts"() {
|
|
147028
147291
|
"use strict";
|
|
147029
147292
|
init_ts4();
|
|
147030
147293
|
init_ts_codefix();
|
|
147031
|
-
|
|
147032
|
-
|
|
147294
|
+
fixId47 = "removeUnnecessaryAwait";
|
|
147295
|
+
errorCodes59 = [
|
|
147033
147296
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
147034
147297
|
];
|
|
147035
147298
|
registerCodeFix({
|
|
147036
|
-
errorCodes:
|
|
147299
|
+
errorCodes: errorCodes59,
|
|
147037
147300
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
147038
147301
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
147039
147302
|
if (changes.length > 0) {
|
|
147040
|
-
return [createCodeFixAction(
|
|
147303
|
+
return [createCodeFixAction(fixId47, changes, Diagnostics.Remove_unnecessary_await, fixId47, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
147041
147304
|
}
|
|
147042
147305
|
},
|
|
147043
|
-
fixIds: [
|
|
147306
|
+
fixIds: [fixId47],
|
|
147044
147307
|
getAllCodeActions: (context) => {
|
|
147045
|
-
return codeFixAll(context,
|
|
147308
|
+
return codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
147046
147309
|
}
|
|
147047
147310
|
});
|
|
147048
147311
|
}
|
|
@@ -147084,26 +147347,26 @@ ${lanes.join("\n")}
|
|
|
147084
147347
|
importDeclaration.assertClause
|
|
147085
147348
|
));
|
|
147086
147349
|
}
|
|
147087
|
-
var
|
|
147350
|
+
var errorCodes60, fixId48;
|
|
147088
147351
|
var init_splitTypeOnlyImport = __esm({
|
|
147089
147352
|
"src/services/codefixes/splitTypeOnlyImport.ts"() {
|
|
147090
147353
|
"use strict";
|
|
147091
147354
|
init_ts4();
|
|
147092
147355
|
init_ts_codefix();
|
|
147093
|
-
|
|
147094
|
-
|
|
147356
|
+
errorCodes60 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
147357
|
+
fixId48 = "splitTypeOnlyImport";
|
|
147095
147358
|
registerCodeFix({
|
|
147096
|
-
errorCodes:
|
|
147097
|
-
fixIds: [
|
|
147359
|
+
errorCodes: errorCodes60,
|
|
147360
|
+
fixIds: [fixId48],
|
|
147098
147361
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
147099
147362
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
147100
147363
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
147101
147364
|
});
|
|
147102
147365
|
if (changes.length) {
|
|
147103
|
-
return [createCodeFixAction(
|
|
147366
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
147104
147367
|
}
|
|
147105
147368
|
},
|
|
147106
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147369
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, error) => {
|
|
147107
147370
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error), context);
|
|
147108
147371
|
})
|
|
147109
147372
|
});
|
|
@@ -147125,43 +147388,43 @@ ${lanes.join("\n")}
|
|
|
147125
147388
|
return;
|
|
147126
147389
|
return { symbol, token: constToken };
|
|
147127
147390
|
}
|
|
147128
|
-
function
|
|
147391
|
+
function doChange32(changes, sourceFile, token) {
|
|
147129
147392
|
changes.replaceNode(sourceFile, token, factory.createToken(119 /* LetKeyword */));
|
|
147130
147393
|
}
|
|
147131
|
-
var
|
|
147394
|
+
var fixId49, errorCodes61;
|
|
147132
147395
|
var init_convertConstToLet = __esm({
|
|
147133
147396
|
"src/services/codefixes/convertConstToLet.ts"() {
|
|
147134
147397
|
"use strict";
|
|
147135
147398
|
init_ts4();
|
|
147136
147399
|
init_ts_codefix();
|
|
147137
|
-
|
|
147138
|
-
|
|
147400
|
+
fixId49 = "fixConvertConstToLet";
|
|
147401
|
+
errorCodes61 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
147139
147402
|
registerCodeFix({
|
|
147140
|
-
errorCodes:
|
|
147403
|
+
errorCodes: errorCodes61,
|
|
147141
147404
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
147142
147405
|
const { sourceFile, span, program } = context;
|
|
147143
147406
|
const info = getInfo17(sourceFile, span.start, program);
|
|
147144
147407
|
if (info === void 0)
|
|
147145
147408
|
return;
|
|
147146
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147147
|
-
return [createCodeFixActionMaybeFixAll(
|
|
147409
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange32(t, sourceFile, info.token));
|
|
147410
|
+
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
147148
147411
|
},
|
|
147149
147412
|
getAllCodeActions: (context) => {
|
|
147150
147413
|
const { program } = context;
|
|
147151
147414
|
const seen = /* @__PURE__ */ new Map();
|
|
147152
147415
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
147153
|
-
eachDiagnostic(context,
|
|
147416
|
+
eachDiagnostic(context, errorCodes61, (diag2) => {
|
|
147154
147417
|
const info = getInfo17(diag2.file, diag2.start, program);
|
|
147155
147418
|
if (info) {
|
|
147156
147419
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
147157
|
-
return
|
|
147420
|
+
return doChange32(changes, diag2.file, info.token);
|
|
147158
147421
|
}
|
|
147159
147422
|
}
|
|
147160
147423
|
return void 0;
|
|
147161
147424
|
});
|
|
147162
147425
|
}));
|
|
147163
147426
|
},
|
|
147164
|
-
fixIds: [
|
|
147427
|
+
fixIds: [fixId49]
|
|
147165
147428
|
});
|
|
147166
147429
|
}
|
|
147167
147430
|
});
|
|
@@ -147171,40 +147434,40 @@ ${lanes.join("\n")}
|
|
|
147171
147434
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
147172
147435
|
return node.kind === 26 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
147173
147436
|
}
|
|
147174
|
-
function
|
|
147437
|
+
function doChange33(changes, sourceFile, { node }) {
|
|
147175
147438
|
const newNode = factory.createToken(27 /* CommaToken */);
|
|
147176
147439
|
changes.replaceNode(sourceFile, node, newNode);
|
|
147177
147440
|
}
|
|
147178
|
-
var
|
|
147441
|
+
var fixId50, expectedErrorCode, errorCodes62;
|
|
147179
147442
|
var init_fixExpectedComma = __esm({
|
|
147180
147443
|
"src/services/codefixes/fixExpectedComma.ts"() {
|
|
147181
147444
|
"use strict";
|
|
147182
147445
|
init_ts4();
|
|
147183
147446
|
init_ts_codefix();
|
|
147184
|
-
|
|
147447
|
+
fixId50 = "fixExpectedComma";
|
|
147185
147448
|
expectedErrorCode = Diagnostics._0_expected.code;
|
|
147186
|
-
|
|
147449
|
+
errorCodes62 = [expectedErrorCode];
|
|
147187
147450
|
registerCodeFix({
|
|
147188
|
-
errorCodes:
|
|
147451
|
+
errorCodes: errorCodes62,
|
|
147189
147452
|
getCodeActions(context) {
|
|
147190
147453
|
const { sourceFile } = context;
|
|
147191
147454
|
const info = getInfo18(sourceFile, context.span.start, context.errorCode);
|
|
147192
147455
|
if (!info)
|
|
147193
147456
|
return void 0;
|
|
147194
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147457
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange33(t, sourceFile, info));
|
|
147195
147458
|
return [createCodeFixAction(
|
|
147196
|
-
|
|
147459
|
+
fixId50,
|
|
147197
147460
|
changes,
|
|
147198
147461
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
147199
|
-
|
|
147462
|
+
fixId50,
|
|
147200
147463
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
147201
147464
|
)];
|
|
147202
147465
|
},
|
|
147203
|
-
fixIds: [
|
|
147204
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147466
|
+
fixIds: [fixId50],
|
|
147467
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, diag2) => {
|
|
147205
147468
|
const info = getInfo18(diag2.file, diag2.start, diag2.code);
|
|
147206
147469
|
if (info)
|
|
147207
|
-
|
|
147470
|
+
doChange33(changes, context.sourceFile, info);
|
|
147208
147471
|
})
|
|
147209
147472
|
});
|
|
147210
147473
|
}
|
|
@@ -147260,29 +147523,29 @@ ${lanes.join("\n")}
|
|
|
147260
147523
|
return node.typeArguments;
|
|
147261
147524
|
}
|
|
147262
147525
|
}
|
|
147263
|
-
var fixName7,
|
|
147526
|
+
var fixName7, fixId51, errorCodes63;
|
|
147264
147527
|
var init_fixAddVoidToPromise = __esm({
|
|
147265
147528
|
"src/services/codefixes/fixAddVoidToPromise.ts"() {
|
|
147266
147529
|
"use strict";
|
|
147267
147530
|
init_ts4();
|
|
147268
147531
|
init_ts_codefix();
|
|
147269
147532
|
fixName7 = "addVoidToPromise";
|
|
147270
|
-
|
|
147271
|
-
|
|
147533
|
+
fixId51 = "addVoidToPromise";
|
|
147534
|
+
errorCodes63 = [
|
|
147272
147535
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
147273
147536
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
147274
147537
|
];
|
|
147275
147538
|
registerCodeFix({
|
|
147276
|
-
errorCodes:
|
|
147277
|
-
fixIds: [
|
|
147539
|
+
errorCodes: errorCodes63,
|
|
147540
|
+
fixIds: [fixId51],
|
|
147278
147541
|
getCodeActions(context) {
|
|
147279
147542
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
147280
147543
|
if (changes.length > 0) {
|
|
147281
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
147544
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId51, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
147282
147545
|
}
|
|
147283
147546
|
},
|
|
147284
147547
|
getAllCodeActions(context) {
|
|
147285
|
-
return codeFixAll(context,
|
|
147548
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
147286
147549
|
}
|
|
147287
147550
|
});
|
|
147288
147551
|
}
|
|
@@ -147317,6 +147580,7 @@ ${lanes.join("\n")}
|
|
|
147317
147580
|
getFixes: () => getFixes,
|
|
147318
147581
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
147319
147582
|
getImportKind: () => getImportKind,
|
|
147583
|
+
getJSDocTypedefNode: () => getJSDocTypedefNode,
|
|
147320
147584
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
147321
147585
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
147322
147586
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -147351,6 +147615,7 @@ ${lanes.join("\n")}
|
|
|
147351
147615
|
init_correctQualifiedNameToIndexedAccessType();
|
|
147352
147616
|
init_convertToTypeOnlyExport();
|
|
147353
147617
|
init_convertToTypeOnlyImport();
|
|
147618
|
+
init_convertTypedefToType();
|
|
147354
147619
|
init_convertLiteralTypeToMappedType();
|
|
147355
147620
|
init_fixClassIncorrectlyImplementsInterface();
|
|
147356
147621
|
init_importFixes();
|
|
@@ -149167,7 +149432,8 @@ ${lanes.join("\n")}
|
|
|
149167
149432
|
}
|
|
149168
149433
|
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
|
149169
149434
|
const contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker);
|
|
149170
|
-
const
|
|
149435
|
+
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
149436
|
+
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
149171
149437
|
contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]),
|
|
149172
149438
|
(t) => t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : void 0
|
|
149173
149439
|
);
|
|
@@ -155779,8 +156045,7 @@ ${lanes.join("\n")}
|
|
|
155779
156045
|
function compareModuleSpecifiersWorker(m1, m2, comparer) {
|
|
155780
156046
|
const name1 = m1 === void 0 ? void 0 : getExternalModuleName2(m1);
|
|
155781
156047
|
const name2 = m2 === void 0 ? void 0 : getExternalModuleName2(m2);
|
|
155782
|
-
return compareBooleans(name1 === void 0, name2 === void 0) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) ||
|
|
155783
|
-
comparer(name1, name2);
|
|
156048
|
+
return compareBooleans(name1 === void 0, name2 === void 0) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) || comparer(name1, name2);
|
|
155784
156049
|
}
|
|
155785
156050
|
function getModuleSpecifierExpression(declaration) {
|
|
155786
156051
|
var _a2;
|
|
@@ -156500,7 +156765,7 @@ ${lanes.join("\n")}
|
|
|
156500
156765
|
return void 0;
|
|
156501
156766
|
}
|
|
156502
156767
|
}
|
|
156503
|
-
function
|
|
156768
|
+
function doChange34(exportingSourceFile, program, info, changes, cancellationToken) {
|
|
156504
156769
|
changeExport(exportingSourceFile, info, changes, program.getTypeChecker());
|
|
156505
156770
|
changeImports(program, info, changes, cancellationToken);
|
|
156506
156771
|
}
|
|
@@ -156696,7 +156961,7 @@ ${lanes.join("\n")}
|
|
|
156696
156961
|
Debug.assert(actionName2 === defaultToNamedAction.name || actionName2 === namedToDefaultAction.name, "Unexpected action name");
|
|
156697
156962
|
const info = getInfo19(context);
|
|
156698
156963
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156699
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
156964
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(context.file, context.program, info, t, context.cancellationToken));
|
|
156700
156965
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
156701
156966
|
}
|
|
156702
156967
|
});
|
|
@@ -156731,7 +156996,7 @@ ${lanes.join("\n")}
|
|
|
156731
156996
|
function getShouldUseDefault(program, importClause) {
|
|
156732
156997
|
return getAllowSyntheticDefaultImports(program.getCompilerOptions()) && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
156733
156998
|
}
|
|
156734
|
-
function
|
|
156999
|
+
function doChange35(sourceFile, program, changes, info) {
|
|
156735
157000
|
const checker = program.getTypeChecker();
|
|
156736
157001
|
if (info.convertTo === 0 /* Named */) {
|
|
156737
157002
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
@@ -156923,7 +157188,7 @@ ${lanes.join("\n")}
|
|
|
156923
157188
|
Debug.assert(some(getOwnValues(actions), (action) => action.name === actionName2), "Unexpected action name");
|
|
156924
157189
|
const info = getImportConversionInfo(context);
|
|
156925
157190
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156926
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157191
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(context.file, context.program, t, info));
|
|
156927
157192
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
156928
157193
|
}
|
|
156929
157194
|
});
|
|
@@ -157265,7 +157530,7 @@ ${lanes.join("\n")}
|
|
|
157265
157530
|
afterLast: afterEndNodeIndex === -1 ? void 0 : statements[afterEndNodeIndex]
|
|
157266
157531
|
};
|
|
157267
157532
|
}
|
|
157268
|
-
function
|
|
157533
|
+
function doChange36(oldFile, program, toMove, changes, host, preferences) {
|
|
157269
157534
|
const checker = program.getTypeChecker();
|
|
157270
157535
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
157271
157536
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
@@ -158035,7 +158300,7 @@ ${lanes.join("\n")}
|
|
|
158035
158300
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
158036
158301
|
Debug.assert(actionName2 === refactorName4, "Wrong refactor invoked");
|
|
158037
158302
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
158038
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158303
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(context.file, context.program, statements, t, context.host, context.preferences));
|
|
158039
158304
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
158040
158305
|
}
|
|
158041
158306
|
});
|
|
@@ -158697,12 +158962,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158697
158962
|
return void 0;
|
|
158698
158963
|
const groupedReferences = getGroupedReferences(functionDeclaration, program, cancellationToken);
|
|
158699
158964
|
if (groupedReferences.valid) {
|
|
158700
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158965
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(file, program, host, t, functionDeclaration, groupedReferences));
|
|
158701
158966
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
158702
158967
|
}
|
|
158703
158968
|
return { edits: [] };
|
|
158704
158969
|
}
|
|
158705
|
-
function
|
|
158970
|
+
function doChange37(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
|
|
158706
158971
|
const signature = groupedReferences.signature;
|
|
158707
158972
|
const newFunctionDeclarationParams = map(createNewParameters(functionDeclaration, program, host), (param) => getSynthesizedDeepClone(param));
|
|
158708
158973
|
if (signature) {
|
|
@@ -159495,7 +159760,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
159495
159760
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
159496
159761
|
const edits = ts_textChanges_exports.ChangeTracker.with(
|
|
159497
159762
|
context,
|
|
159498
|
-
(t) =>
|
|
159763
|
+
(t) => doChange38(context.file, context.program.getTypeChecker(), t, info, actionName2)
|
|
159499
159764
|
);
|
|
159500
159765
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
159501
159766
|
}
|
|
@@ -159651,7 +159916,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
159651
159916
|
}
|
|
159652
159917
|
return toConvert;
|
|
159653
159918
|
}
|
|
159654
|
-
function
|
|
159919
|
+
function doChange38(sourceFile, checker, changes, info, _actionName) {
|
|
159655
159920
|
const { finalExpression, occurrences, expression } = info;
|
|
159656
159921
|
const firstOccurrence = occurrences[occurrences.length - 1];
|
|
159657
159922
|
const convertedChain = convertOccurrences(checker, finalExpression, occurrences);
|
|
@@ -161387,7 +161652,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161387
161652
|
function getRefactorEditsToInferReturnType(context) {
|
|
161388
161653
|
const info = getInfo21(context);
|
|
161389
161654
|
if (info && !isRefactorErrorInfo(info)) {
|
|
161390
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
161655
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(context.file, t, info.declaration, info.returnTypeNode));
|
|
161391
161656
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
161392
161657
|
}
|
|
161393
161658
|
return void 0;
|
|
@@ -161412,7 +161677,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161412
161677
|
}
|
|
161413
161678
|
return emptyArray;
|
|
161414
161679
|
}
|
|
161415
|
-
function
|
|
161680
|
+
function doChange39(sourceFile, changes, declaration, typeNode) {
|
|
161416
161681
|
const closeParen = findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile);
|
|
161417
161682
|
const needParens = isArrowFunction(declaration) && closeParen === void 0;
|
|
161418
161683
|
const endNode2 = needParens ? first(declaration.parameters) : closeParen;
|
|
@@ -167869,7 +168134,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167869
168134
|
createTypeChecker: () => createTypeChecker,
|
|
167870
168135
|
createTypeReferenceDirectiveResolutionCache: () => createTypeReferenceDirectiveResolutionCache,
|
|
167871
168136
|
createTypeReferenceResolutionLoader: () => createTypeReferenceResolutionLoader,
|
|
167872
|
-
createUnderscoreEscapedMultiMap: () => createUnderscoreEscapedMultiMap,
|
|
167873
168137
|
createUnparsedSourceFile: () => createUnparsedSourceFile,
|
|
167874
168138
|
createWatchCompilerHost: () => createWatchCompilerHost2,
|
|
167875
168139
|
createWatchCompilerHostOfConfigFile: () => createWatchCompilerHostOfConfigFile,
|
|
@@ -169280,7 +169544,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169280
169544
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
169281
169545
|
noop: () => noop,
|
|
169282
169546
|
noopFileWatcher: () => noopFileWatcher,
|
|
169283
|
-
noopPush: () => noopPush,
|
|
169284
169547
|
normalizePath: () => normalizePath,
|
|
169285
169548
|
normalizeSlashes: () => normalizeSlashes,
|
|
169286
169549
|
not: () => not,
|