typescript 5.1.0-dev.20230301 → 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/lib/tsc.js +127 -65
- package/lib/tsserver.js +867 -603
- package/lib/tsserverlibrary.d.ts +2 -37
- package/lib/tsserverlibrary.js +926 -652
- package/lib/typescript.d.ts +0 -3
- package/lib/typescript.js +804 -542
- package/lib/typingsInstaller.js +50 -14
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -1882,7 +1882,6 @@ __export(server_exports, {
|
|
|
1882
1882
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
1883
1883
|
noop: () => noop,
|
|
1884
1884
|
noopFileWatcher: () => noopFileWatcher,
|
|
1885
|
-
noopPush: () => noopPush,
|
|
1886
1885
|
normalizePath: () => normalizePath,
|
|
1887
1886
|
normalizeSlashes: () => normalizeSlashes,
|
|
1888
1887
|
not: () => not,
|
|
@@ -2287,7 +2286,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2287
2286
|
|
|
2288
2287
|
// src/compiler/corePublic.ts
|
|
2289
2288
|
var versionMajorMinor = "5.1";
|
|
2290
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2289
|
+
var version = `${versionMajorMinor}.0-dev.20230302`;
|
|
2291
2290
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2292
2291
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2293
2292
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -3442,10 +3441,6 @@ function cast(value, test) {
|
|
|
3442
3441
|
}
|
|
3443
3442
|
function noop(_) {
|
|
3444
3443
|
}
|
|
3445
|
-
var noopPush = {
|
|
3446
|
-
push: noop,
|
|
3447
|
-
length: 0
|
|
3448
|
-
};
|
|
3449
3444
|
function returnFalse() {
|
|
3450
3445
|
return false;
|
|
3451
3446
|
}
|
|
@@ -10635,6 +10630,7 @@ var Diagnostics = {
|
|
|
10635
10630
|
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."),
|
|
10636
10631
|
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."),
|
|
10637
10632
|
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."),
|
|
10633
|
+
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."),
|
|
10638
10634
|
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."),
|
|
10639
10635
|
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}'."),
|
|
10640
10636
|
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."),
|
|
@@ -11030,6 +11026,8 @@ var Diagnostics = {
|
|
|
11030
11026
|
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."),
|
|
11031
11027
|
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."),
|
|
11032
11028
|
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."),
|
|
11029
|
+
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."),
|
|
11030
|
+
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."),
|
|
11033
11031
|
Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
11034
11032
|
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"),
|
|
11035
11033
|
Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
@@ -11244,6 +11242,8 @@ var Diagnostics = {
|
|
|
11244
11242
|
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}'"),
|
|
11245
11243
|
Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
|
|
11246
11244
|
Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
11245
|
+
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
|
|
11246
|
+
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
11247
11247
|
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."),
|
|
11248
11248
|
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'."),
|
|
11249
11249
|
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?"),
|
|
@@ -40952,20 +40952,14 @@ function getEffectiveTypeRoots(options, host) {
|
|
|
40952
40952
|
currentDirectory = host.getCurrentDirectory();
|
|
40953
40953
|
}
|
|
40954
40954
|
if (currentDirectory !== void 0) {
|
|
40955
|
-
return getDefaultTypeRoots(currentDirectory
|
|
40955
|
+
return getDefaultTypeRoots(currentDirectory);
|
|
40956
40956
|
}
|
|
40957
40957
|
}
|
|
40958
|
-
function getDefaultTypeRoots(currentDirectory
|
|
40959
|
-
if (!host.directoryExists) {
|
|
40960
|
-
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
40961
|
-
}
|
|
40958
|
+
function getDefaultTypeRoots(currentDirectory) {
|
|
40962
40959
|
let typeRoots;
|
|
40963
40960
|
forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
|
|
40964
40961
|
const atTypes = combinePaths(directory, nodeModulesAtTypes);
|
|
40965
|
-
|
|
40966
|
-
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
40967
|
-
}
|
|
40968
|
-
return void 0;
|
|
40962
|
+
(typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
|
|
40969
40963
|
});
|
|
40970
40964
|
return typeRoots;
|
|
40971
40965
|
}
|
|
@@ -41102,10 +41096,22 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
41102
41096
|
}
|
|
41103
41097
|
return firstDefined(typeRoots, (typeRoot) => {
|
|
41104
41098
|
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
41105
|
-
const
|
|
41106
|
-
const directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
41099
|
+
const directoryExists = directoryProbablyExists(typeRoot, host);
|
|
41107
41100
|
if (!directoryExists && traceEnabled) {
|
|
41108
|
-
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it,
|
|
41101
|
+
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
41102
|
+
}
|
|
41103
|
+
if (options.typeRoots) {
|
|
41104
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
|
|
41105
|
+
if (resolvedFromFile) {
|
|
41106
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
41107
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
41108
|
+
packageDirectory,
|
|
41109
|
+
/*onlyRecordFailures*/
|
|
41110
|
+
false,
|
|
41111
|
+
moduleResolutionState
|
|
41112
|
+
) : void 0;
|
|
41113
|
+
return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
|
|
41114
|
+
}
|
|
41109
41115
|
}
|
|
41110
41116
|
return resolvedTypeScriptOnly(
|
|
41111
41117
|
loadNodeModuleFromDirectory(
|
|
@@ -41125,33 +41131,37 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
41125
41131
|
function secondaryLookup() {
|
|
41126
41132
|
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
|
|
41127
41133
|
if (initialLocationForSecondaryLookup !== void 0) {
|
|
41128
|
-
if (traceEnabled) {
|
|
41129
|
-
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
41130
|
-
}
|
|
41131
41134
|
let result2;
|
|
41132
|
-
if (!
|
|
41133
|
-
|
|
41134
|
-
|
|
41135
|
-
|
|
41136
|
-
|
|
41137
|
-
|
|
41138
|
-
|
|
41139
|
-
|
|
41140
|
-
|
|
41141
|
-
|
|
41142
|
-
|
|
41143
|
-
|
|
41144
|
-
|
|
41145
|
-
|
|
41146
|
-
|
|
41147
|
-
|
|
41148
|
-
|
|
41149
|
-
|
|
41150
|
-
|
|
41151
|
-
|
|
41152
|
-
|
|
41153
|
-
|
|
41154
|
-
|
|
41135
|
+
if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
|
|
41136
|
+
if (traceEnabled) {
|
|
41137
|
+
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
41138
|
+
}
|
|
41139
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
41140
|
+
const searchResult = loadModuleFromNearestNodeModulesDirectory(
|
|
41141
|
+
4 /* Declaration */,
|
|
41142
|
+
typeReferenceDirectiveName,
|
|
41143
|
+
initialLocationForSecondaryLookup,
|
|
41144
|
+
moduleResolutionState,
|
|
41145
|
+
/*cache*/
|
|
41146
|
+
void 0,
|
|
41147
|
+
/*redirectedReference*/
|
|
41148
|
+
void 0
|
|
41149
|
+
);
|
|
41150
|
+
result2 = searchResult && searchResult.value;
|
|
41151
|
+
} else {
|
|
41152
|
+
const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
|
|
41153
|
+
result2 = nodeLoadModuleByRelativeName(
|
|
41154
|
+
4 /* Declaration */,
|
|
41155
|
+
candidate,
|
|
41156
|
+
/*onlyRecordFailures*/
|
|
41157
|
+
false,
|
|
41158
|
+
moduleResolutionState,
|
|
41159
|
+
/*considerPackageJson*/
|
|
41160
|
+
true
|
|
41161
|
+
);
|
|
41162
|
+
}
|
|
41163
|
+
} else if (traceEnabled) {
|
|
41164
|
+
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
|
|
41155
41165
|
}
|
|
41156
41166
|
return resolvedTypeScriptOnly(result2);
|
|
41157
41167
|
} else {
|
|
@@ -41983,6 +41993,9 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
41983
41993
|
}
|
|
41984
41994
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
41985
41995
|
}
|
|
41996
|
+
if (extensions2 & 4 /* Declaration */) {
|
|
41997
|
+
resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
|
|
41998
|
+
}
|
|
41986
41999
|
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
41987
42000
|
} else {
|
|
41988
42001
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
@@ -42163,6 +42176,7 @@ function tryFile(fileName, onlyRecordFailures, state) {
|
|
|
42163
42176
|
return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
|
|
42164
42177
|
}
|
|
42165
42178
|
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
42179
|
+
var _a2;
|
|
42166
42180
|
if (!onlyRecordFailures) {
|
|
42167
42181
|
if (state.host.fileExists(fileName)) {
|
|
42168
42182
|
if (state.traceEnabled) {
|
|
@@ -42175,7 +42189,7 @@ function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
|
42175
42189
|
}
|
|
42176
42190
|
}
|
|
42177
42191
|
}
|
|
42178
|
-
state.failedLookupLocations.push(fileName);
|
|
42192
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
|
|
42179
42193
|
return void 0;
|
|
42180
42194
|
}
|
|
42181
42195
|
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
|
|
@@ -42290,8 +42304,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
|
|
|
42290
42304
|
host,
|
|
42291
42305
|
compilerOptions: options,
|
|
42292
42306
|
traceEnabled: isTraceEnabled(options, host),
|
|
42293
|
-
failedLookupLocations:
|
|
42294
|
-
affectingLocations:
|
|
42307
|
+
failedLookupLocations: void 0,
|
|
42308
|
+
affectingLocations: void 0,
|
|
42295
42309
|
packageJsonInfoCache,
|
|
42296
42310
|
features: 0 /* None */,
|
|
42297
42311
|
conditions: emptyArray,
|
|
@@ -42325,24 +42339,24 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
|
|
|
42325
42339
|
return packageJsonInfo.contents.versionPaths || void 0;
|
|
42326
42340
|
}
|
|
42327
42341
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
42328
|
-
var _a2, _b, _c;
|
|
42342
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
42329
42343
|
const { host, traceEnabled } = state;
|
|
42330
42344
|
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
|
42331
42345
|
if (onlyRecordFailures) {
|
|
42332
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42346
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
|
|
42333
42347
|
return void 0;
|
|
42334
42348
|
}
|
|
42335
|
-
const existing = (
|
|
42349
|
+
const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
42336
42350
|
if (existing !== void 0) {
|
|
42337
42351
|
if (typeof existing !== "boolean") {
|
|
42338
42352
|
if (traceEnabled)
|
|
42339
42353
|
trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
|
|
42340
|
-
state.affectingLocations.push(packageJsonPath);
|
|
42354
|
+
(_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
|
|
42341
42355
|
return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
|
|
42342
42356
|
} else {
|
|
42343
42357
|
if (existing && traceEnabled)
|
|
42344
42358
|
trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
|
|
42345
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42359
|
+
(_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
|
|
42346
42360
|
return void 0;
|
|
42347
42361
|
}
|
|
42348
42362
|
}
|
|
@@ -42353,15 +42367,15 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
|
42353
42367
|
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
42354
42368
|
}
|
|
42355
42369
|
const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
|
|
42356
|
-
(
|
|
42357
|
-
state.affectingLocations.push(packageJsonPath);
|
|
42370
|
+
(_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
|
|
42371
|
+
(_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
|
|
42358
42372
|
return result;
|
|
42359
42373
|
} else {
|
|
42360
42374
|
if (directoryExists && traceEnabled) {
|
|
42361
42375
|
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
42362
42376
|
}
|
|
42363
|
-
(
|
|
42364
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42377
|
+
(_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
|
|
42378
|
+
(_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
|
|
42365
42379
|
}
|
|
42366
42380
|
}
|
|
42367
42381
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
@@ -43182,11 +43196,13 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
43182
43196
|
state
|
|
43183
43197
|
));
|
|
43184
43198
|
});
|
|
43185
|
-
if (resolved2)
|
|
43199
|
+
if (resolved2)
|
|
43186
43200
|
return resolved2;
|
|
43187
|
-
}
|
|
43188
43201
|
if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
|
|
43189
|
-
|
|
43202
|
+
let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
|
|
43203
|
+
if (extensions & 4 /* Declaration */)
|
|
43204
|
+
resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
|
|
43205
|
+
return resolved3;
|
|
43190
43206
|
}
|
|
43191
43207
|
} else {
|
|
43192
43208
|
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
|
@@ -43200,6 +43216,31 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
43200
43216
|
}
|
|
43201
43217
|
}
|
|
43202
43218
|
}
|
|
43219
|
+
function resolveFromTypeRoot(moduleName, state) {
|
|
43220
|
+
if (!state.compilerOptions.typeRoots)
|
|
43221
|
+
return;
|
|
43222
|
+
for (const typeRoot of state.compilerOptions.typeRoots) {
|
|
43223
|
+
const candidate = combinePaths(typeRoot, moduleName);
|
|
43224
|
+
const directoryExists = directoryProbablyExists(typeRoot, state.host);
|
|
43225
|
+
if (!directoryExists && state.traceEnabled) {
|
|
43226
|
+
trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
43227
|
+
}
|
|
43228
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
|
|
43229
|
+
if (resolvedFromFile) {
|
|
43230
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
43231
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
43232
|
+
packageDirectory,
|
|
43233
|
+
/*onlyRecordFailures*/
|
|
43234
|
+
false,
|
|
43235
|
+
state
|
|
43236
|
+
) : void 0;
|
|
43237
|
+
return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
|
|
43238
|
+
}
|
|
43239
|
+
const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
|
|
43240
|
+
if (resolved)
|
|
43241
|
+
return toSearchResult(resolved);
|
|
43242
|
+
}
|
|
43243
|
+
}
|
|
43203
43244
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
43204
43245
|
return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
|
|
43205
43246
|
}
|
|
@@ -56198,7 +56239,11 @@ function createTypeChecker(host) {
|
|
|
56198
56239
|
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
|
56199
56240
|
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
|
56200
56241
|
} else {
|
|
56201
|
-
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
56242
|
+
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
56243
|
+
type,
|
|
56244
|
+
/*isProperty*/
|
|
56245
|
+
true
|
|
56246
|
+
) : type;
|
|
56202
56247
|
}
|
|
56203
56248
|
}
|
|
56204
56249
|
function getTypeOfEnumMember(symbol) {
|
|
@@ -64899,6 +64944,7 @@ function createTypeChecker(host) {
|
|
|
64899
64944
|
} else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64900
64945
|
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64901
64946
|
if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
|
|
64947
|
+
instantiateType(source2.objectType, reportUnreliableMapper);
|
|
64902
64948
|
result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
|
|
64903
64949
|
}
|
|
64904
64950
|
if (result2) {
|
|
@@ -68044,7 +68090,7 @@ function createTypeChecker(host) {
|
|
|
68044
68090
|
);
|
|
68045
68091
|
}
|
|
68046
68092
|
function isInAmbientOrTypeNode(node) {
|
|
68047
|
-
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
|
68093
|
+
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
|
68048
68094
|
}
|
|
68049
68095
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
68050
68096
|
switch (node.kind) {
|
|
@@ -71192,6 +71238,16 @@ function createTypeChecker(host) {
|
|
|
71192
71238
|
const symbol = getSymbolOfDeclaration(element);
|
|
71193
71239
|
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
71194
71240
|
}
|
|
71241
|
+
if (hasDynamicName(element)) {
|
|
71242
|
+
const name = getNameOfDeclaration(element);
|
|
71243
|
+
if (name && isComputedPropertyName(name)) {
|
|
71244
|
+
const exprType = checkExpression(name.expression);
|
|
71245
|
+
const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
|
|
71246
|
+
if (propType) {
|
|
71247
|
+
return propType;
|
|
71248
|
+
}
|
|
71249
|
+
}
|
|
71250
|
+
}
|
|
71195
71251
|
if (element.name) {
|
|
71196
71252
|
const nameType = getLiteralTypeFromPropertyName(element.name);
|
|
71197
71253
|
return mapType(
|
|
@@ -75965,7 +76021,7 @@ function createTypeChecker(host) {
|
|
|
75965
76021
|
}
|
|
75966
76022
|
function getNonArrayRestType(signature) {
|
|
75967
76023
|
const restType = getEffectiveRestType(signature);
|
|
75968
|
-
return restType && !isArrayType(restType) && !isTypeAny(restType)
|
|
76024
|
+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
|
|
75969
76025
|
}
|
|
75970
76026
|
function getTypeOfFirstParameterOfSignature(signature) {
|
|
75971
76027
|
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
|
|
@@ -80779,6 +80835,9 @@ function createTypeChecker(host) {
|
|
|
80779
80835
|
return;
|
|
80780
80836
|
}
|
|
80781
80837
|
if (isBindingPattern(node.name)) {
|
|
80838
|
+
if (isInAmbientOrTypeNode(node)) {
|
|
80839
|
+
return;
|
|
80840
|
+
}
|
|
80782
80841
|
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
|
|
80783
80842
|
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
|
80784
80843
|
if (needCheckInitializer || needCheckWidenedType) {
|
|
@@ -123398,7 +123457,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123398
123457
|
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
123399
123458
|
}
|
|
123400
123459
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
123401
|
-
return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
123460
|
+
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
123402
123461
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
123403
123462
|
if (cachedDirectoryStructureHost) {
|
|
123404
123463
|
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
|
@@ -123409,7 +123468,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123409
123468
|
if (dirPath) {
|
|
123410
123469
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
123411
123470
|
}
|
|
123412
|
-
}, 1 /* Recursive */);
|
|
123471
|
+
}, 1 /* Recursive */) : noopFileWatcher;
|
|
123413
123472
|
}
|
|
123414
123473
|
function updateTypeRootsWatch() {
|
|
123415
123474
|
const options = resolutionHost.getCompilationSettings();
|
|
@@ -123417,7 +123476,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123417
123476
|
closeTypeRootsWatch();
|
|
123418
123477
|
return;
|
|
123419
123478
|
}
|
|
123420
|
-
const typeRoots = getEffectiveTypeRoots(options, {
|
|
123479
|
+
const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
|
|
123421
123480
|
if (typeRoots) {
|
|
123422
123481
|
mutateMap(
|
|
123423
123482
|
typeRootsWatches,
|
|
@@ -123431,7 +123490,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123431
123490
|
closeTypeRootsWatch();
|
|
123432
123491
|
}
|
|
123433
123492
|
}
|
|
123434
|
-
function
|
|
123493
|
+
function canWatchTypeRootPath(nodeTypesDirectory) {
|
|
123494
|
+
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
123495
|
+
return true;
|
|
123435
123496
|
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
|
123436
123497
|
const dirPath = resolutionHost.toPath(dir);
|
|
123437
123498
|
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
@@ -133236,6 +133297,10 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
133236
133297
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
133237
133298
|
}
|
|
133238
133299
|
}
|
|
133300
|
+
const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
|
|
133301
|
+
if (jsdocTypedefNode) {
|
|
133302
|
+
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
133303
|
+
}
|
|
133239
133304
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
133240
133305
|
diags.push(createDiagnosticForNode(node.name || node, Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types));
|
|
133241
133306
|
}
|
|
@@ -135260,7 +135325,6 @@ var invalidOperationsInSyntacticMode = [
|
|
|
135260
135325
|
"getTypeDefinitionAtPosition",
|
|
135261
135326
|
"getReferencesAtPosition",
|
|
135262
135327
|
"findReferences",
|
|
135263
|
-
"getOccurrencesAtPosition",
|
|
135264
135328
|
"getDocumentHighlights",
|
|
135265
135329
|
"getNavigateToItems",
|
|
135266
135330
|
"getRenameInfo",
|
|
@@ -135683,18 +135747,6 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
135683
135747
|
synchronizeHostData();
|
|
135684
135748
|
return ts_FindAllReferences_exports.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
135685
135749
|
}
|
|
135686
|
-
function getOccurrencesAtPosition(fileName, position) {
|
|
135687
|
-
return flatMap(
|
|
135688
|
-
getDocumentHighlights(fileName, position, [fileName]),
|
|
135689
|
-
(entry) => entry.highlightSpans.map((highlightSpan) => ({
|
|
135690
|
-
fileName: entry.fileName,
|
|
135691
|
-
textSpan: highlightSpan.textSpan,
|
|
135692
|
-
isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */,
|
|
135693
|
-
...highlightSpan.isInString && { isInString: true },
|
|
135694
|
-
...highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan }
|
|
135695
|
-
}))
|
|
135696
|
-
);
|
|
135697
|
-
}
|
|
135698
135750
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
135699
135751
|
const normalizedFileName = normalizePath(fileName);
|
|
135700
135752
|
Debug.assert(filesToSearch.some((f) => normalizePath(f) === normalizedFileName));
|
|
@@ -135887,22 +135939,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
135887
135939
|
}
|
|
135888
135940
|
return [];
|
|
135889
135941
|
}
|
|
135890
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
135942
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes64, formatOptions, preferences = emptyOptions) {
|
|
135891
135943
|
synchronizeHostData();
|
|
135892
135944
|
const sourceFile = getValidSourceFile(fileName);
|
|
135893
135945
|
const span = createTextSpanFromBounds(start2, end);
|
|
135894
135946
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
135895
|
-
return flatMap(deduplicate(
|
|
135947
|
+
return flatMap(deduplicate(errorCodes64, equateValues, compareValues), (errorCode) => {
|
|
135896
135948
|
cancellationToken.throwIfCancellationRequested();
|
|
135897
135949
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
135898
135950
|
});
|
|
135899
135951
|
}
|
|
135900
|
-
function getCombinedCodeFix(scope,
|
|
135952
|
+
function getCombinedCodeFix(scope, fixId52, formatOptions, preferences = emptyOptions) {
|
|
135901
135953
|
synchronizeHostData();
|
|
135902
135954
|
Debug.assert(scope.type === "file");
|
|
135903
135955
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
135904
135956
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
135905
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
135957
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId52, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
135906
135958
|
}
|
|
135907
135959
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
135908
135960
|
var _a3;
|
|
@@ -136324,7 +136376,6 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
136324
136376
|
getReferencesAtPosition,
|
|
136325
136377
|
findReferences,
|
|
136326
136378
|
getFileReferences,
|
|
136327
|
-
getOccurrencesAtPosition,
|
|
136328
136379
|
getDocumentHighlights,
|
|
136329
136380
|
getNameOrDottedNameSpan,
|
|
136330
136381
|
getBreakpointStatementAtPosition,
|
|
@@ -137043,12 +137094,6 @@ var LanguageServiceShimObject = class extends ShimBase {
|
|
|
137043
137094
|
() => this.languageService.getFileReferences(fileName)
|
|
137044
137095
|
);
|
|
137045
137096
|
}
|
|
137046
|
-
getOccurrencesAtPosition(fileName, position) {
|
|
137047
|
-
return this.forwardJSONCall(
|
|
137048
|
-
`getOccurrencesAtPosition('${fileName}', ${position})`,
|
|
137049
|
-
() => this.languageService.getOccurrencesAtPosition(fileName, position)
|
|
137050
|
-
);
|
|
137051
|
-
}
|
|
137052
137097
|
getDocumentHighlights(fileName, position, filesToSearch) {
|
|
137053
137098
|
return this.forwardJSONCall(
|
|
137054
137099
|
`getDocumentHighlights('${fileName}', ${position})`,
|
|
@@ -138657,6 +138702,7 @@ __export(ts_codefix_exports, {
|
|
|
138657
138702
|
getFixes: () => getFixes,
|
|
138658
138703
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
138659
138704
|
getImportKind: () => getImportKind,
|
|
138705
|
+
getJSDocTypedefNode: () => getJSDocTypedefNode,
|
|
138660
138706
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
138661
138707
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
138662
138708
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -138686,23 +138732,23 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description2) {
|
|
|
138686
138732
|
void 0
|
|
138687
138733
|
);
|
|
138688
138734
|
}
|
|
138689
|
-
function createCodeFixAction(fixName8, changes, description2,
|
|
138690
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
138735
|
+
function createCodeFixAction(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
138736
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, diagnosticToString(fixAllDescription), command);
|
|
138691
138737
|
}
|
|
138692
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description2,
|
|
138693
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
138738
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
138739
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
138694
138740
|
}
|
|
138695
|
-
function createCodeFixActionWorker(fixName8, description2, changes,
|
|
138696
|
-
return { fixName: fixName8, description: description2, changes, fixId:
|
|
138741
|
+
function createCodeFixActionWorker(fixName8, description2, changes, fixId52, fixAllDescription, command) {
|
|
138742
|
+
return { fixName: fixName8, description: description2, changes, fixId: fixId52, fixAllDescription, commands: command ? [command] : void 0 };
|
|
138697
138743
|
}
|
|
138698
138744
|
function registerCodeFix(reg) {
|
|
138699
138745
|
for (const error of reg.errorCodes) {
|
|
138700
138746
|
errorCodeToFixes.add(String(error), reg);
|
|
138701
138747
|
}
|
|
138702
138748
|
if (reg.fixIds) {
|
|
138703
|
-
for (const
|
|
138704
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
138705
|
-
fixIdToRegistration.set(
|
|
138749
|
+
for (const fixId52 of reg.fixIds) {
|
|
138750
|
+
Debug.assert(!fixIdToRegistration.has(fixId52));
|
|
138751
|
+
fixIdToRegistration.set(fixId52, reg);
|
|
138706
138752
|
}
|
|
138707
138753
|
}
|
|
138708
138754
|
}
|
|
@@ -138710,17 +138756,17 @@ function getSupportedErrorCodes() {
|
|
|
138710
138756
|
return arrayFrom(errorCodeToFixes.keys());
|
|
138711
138757
|
}
|
|
138712
138758
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
138713
|
-
const { errorCodes:
|
|
138759
|
+
const { errorCodes: errorCodes64 } = registration;
|
|
138714
138760
|
let maybeFixableDiagnostics = 0;
|
|
138715
138761
|
for (const diag2 of diagnostics) {
|
|
138716
|
-
if (contains(
|
|
138762
|
+
if (contains(errorCodes64, diag2.code))
|
|
138717
138763
|
maybeFixableDiagnostics++;
|
|
138718
138764
|
if (maybeFixableDiagnostics > 1)
|
|
138719
138765
|
break;
|
|
138720
138766
|
}
|
|
138721
138767
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
138722
|
-
return ({ fixId:
|
|
138723
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
138768
|
+
return ({ fixId: fixId52, fixAllDescription, ...action }) => {
|
|
138769
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId52, fixAllDescription };
|
|
138724
138770
|
};
|
|
138725
138771
|
}
|
|
138726
138772
|
function getFixes(context) {
|
|
@@ -138737,14 +138783,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
138737
138783
|
function createFileTextChanges(fileName, textChanges2) {
|
|
138738
138784
|
return { fileName, textChanges: textChanges2 };
|
|
138739
138785
|
}
|
|
138740
|
-
function codeFixAll(context,
|
|
138786
|
+
function codeFixAll(context, errorCodes64, use) {
|
|
138741
138787
|
const commands = [];
|
|
138742
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
138788
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes64, (diag2) => use(t, diag2, commands)));
|
|
138743
138789
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
138744
138790
|
}
|
|
138745
|
-
function eachDiagnostic(context,
|
|
138791
|
+
function eachDiagnostic(context, errorCodes64, cb) {
|
|
138746
138792
|
for (const diag2 of getDiagnostics(context)) {
|
|
138747
|
-
if (contains(
|
|
138793
|
+
if (contains(errorCodes64, diag2.code)) {
|
|
138748
138794
|
cb(diag2);
|
|
138749
138795
|
}
|
|
138750
138796
|
}
|
|
@@ -141199,61 +141245,268 @@ function getTypeExportSpecifiers(originExportSpecifier, context) {
|
|
|
141199
141245
|
}
|
|
141200
141246
|
|
|
141201
141247
|
// src/services/codefixes/convertToTypeOnlyImport.ts
|
|
141202
|
-
var errorCodes14 = [
|
|
141248
|
+
var errorCodes14 = [
|
|
141249
|
+
Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error.code,
|
|
141250
|
+
Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code
|
|
141251
|
+
];
|
|
141203
141252
|
var fixId13 = "convertToTypeOnlyImport";
|
|
141204
141253
|
registerCodeFix({
|
|
141205
141254
|
errorCodes: errorCodes14,
|
|
141206
141255
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
141207
|
-
const
|
|
141208
|
-
|
|
141209
|
-
|
|
141210
|
-
});
|
|
141211
|
-
if (changes.length) {
|
|
141256
|
+
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
141257
|
+
if (declaration) {
|
|
141258
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(t, context.sourceFile, declaration));
|
|
141212
141259
|
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
141213
141260
|
}
|
|
141261
|
+
return void 0;
|
|
141214
141262
|
},
|
|
141215
141263
|
fixIds: [fixId13],
|
|
141216
141264
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
141217
141265
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
141218
|
-
const
|
|
141219
|
-
|
|
141266
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
141267
|
+
if (declaration) {
|
|
141268
|
+
doChange4(changes, diag2.file, declaration);
|
|
141269
|
+
}
|
|
141220
141270
|
});
|
|
141221
141271
|
}
|
|
141222
141272
|
});
|
|
141223
|
-
function
|
|
141224
|
-
|
|
141273
|
+
function getDeclaration2(sourceFile, pos) {
|
|
141274
|
+
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
141275
|
+
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
141225
141276
|
}
|
|
141226
|
-
function
|
|
141227
|
-
if (
|
|
141277
|
+
function doChange4(changes, sourceFile, declaration) {
|
|
141278
|
+
if (isImportSpecifier(declaration)) {
|
|
141279
|
+
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
141280
|
+
declaration,
|
|
141281
|
+
/*isTypeOnly*/
|
|
141282
|
+
true,
|
|
141283
|
+
declaration.propertyName,
|
|
141284
|
+
declaration.name
|
|
141285
|
+
));
|
|
141286
|
+
} else {
|
|
141287
|
+
const importClause = declaration.importClause;
|
|
141288
|
+
if (importClause.name && importClause.namedBindings) {
|
|
141289
|
+
changes.replaceNodeWithNodes(sourceFile, declaration, [
|
|
141290
|
+
factory.createImportDeclaration(
|
|
141291
|
+
getSynthesizedDeepClones(
|
|
141292
|
+
declaration.modifiers,
|
|
141293
|
+
/*includeTrivia*/
|
|
141294
|
+
true
|
|
141295
|
+
),
|
|
141296
|
+
factory.createImportClause(
|
|
141297
|
+
/*isTypeOnly*/
|
|
141298
|
+
true,
|
|
141299
|
+
getSynthesizedDeepClone(
|
|
141300
|
+
importClause.name,
|
|
141301
|
+
/*includeTrivia*/
|
|
141302
|
+
true
|
|
141303
|
+
),
|
|
141304
|
+
/*namedBindings*/
|
|
141305
|
+
void 0
|
|
141306
|
+
),
|
|
141307
|
+
getSynthesizedDeepClone(
|
|
141308
|
+
declaration.moduleSpecifier,
|
|
141309
|
+
/*includeTrivia*/
|
|
141310
|
+
true
|
|
141311
|
+
),
|
|
141312
|
+
getSynthesizedDeepClone(
|
|
141313
|
+
declaration.assertClause,
|
|
141314
|
+
/*includeTrivia*/
|
|
141315
|
+
true
|
|
141316
|
+
)
|
|
141317
|
+
),
|
|
141318
|
+
factory.createImportDeclaration(
|
|
141319
|
+
getSynthesizedDeepClones(
|
|
141320
|
+
declaration.modifiers,
|
|
141321
|
+
/*includeTrivia*/
|
|
141322
|
+
true
|
|
141323
|
+
),
|
|
141324
|
+
factory.createImportClause(
|
|
141325
|
+
/*isTypeOnly*/
|
|
141326
|
+
true,
|
|
141327
|
+
/*name*/
|
|
141328
|
+
void 0,
|
|
141329
|
+
getSynthesizedDeepClone(
|
|
141330
|
+
importClause.namedBindings,
|
|
141331
|
+
/*includeTrivia*/
|
|
141332
|
+
true
|
|
141333
|
+
)
|
|
141334
|
+
),
|
|
141335
|
+
getSynthesizedDeepClone(
|
|
141336
|
+
declaration.moduleSpecifier,
|
|
141337
|
+
/*includeTrivia*/
|
|
141338
|
+
true
|
|
141339
|
+
),
|
|
141340
|
+
getSynthesizedDeepClone(
|
|
141341
|
+
declaration.assertClause,
|
|
141342
|
+
/*includeTrivia*/
|
|
141343
|
+
true
|
|
141344
|
+
)
|
|
141345
|
+
)
|
|
141346
|
+
]);
|
|
141347
|
+
} else {
|
|
141348
|
+
const importDeclaration = factory.updateImportDeclaration(
|
|
141349
|
+
declaration,
|
|
141350
|
+
declaration.modifiers,
|
|
141351
|
+
factory.updateImportClause(
|
|
141352
|
+
importClause,
|
|
141353
|
+
/*isTypeOnly*/
|
|
141354
|
+
true,
|
|
141355
|
+
importClause.name,
|
|
141356
|
+
importClause.namedBindings
|
|
141357
|
+
),
|
|
141358
|
+
declaration.moduleSpecifier,
|
|
141359
|
+
declaration.assertClause
|
|
141360
|
+
);
|
|
141361
|
+
changes.replaceNode(sourceFile, declaration, importDeclaration);
|
|
141362
|
+
}
|
|
141363
|
+
}
|
|
141364
|
+
}
|
|
141365
|
+
|
|
141366
|
+
// src/services/codefixes/convertTypedefToType.ts
|
|
141367
|
+
var fixId14 = "convertTypedefToType";
|
|
141368
|
+
var errorCodes15 = [Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type.code];
|
|
141369
|
+
registerCodeFix({
|
|
141370
|
+
fixIds: [fixId14],
|
|
141371
|
+
errorCodes: errorCodes15,
|
|
141372
|
+
getCodeActions(context) {
|
|
141373
|
+
const node = getTokenAtPosition(
|
|
141374
|
+
context.sourceFile,
|
|
141375
|
+
context.span.start
|
|
141376
|
+
);
|
|
141377
|
+
if (!node)
|
|
141378
|
+
return;
|
|
141379
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange5(t, node, context.sourceFile));
|
|
141380
|
+
if (changes.length > 0) {
|
|
141381
|
+
return [
|
|
141382
|
+
createCodeFixAction(
|
|
141383
|
+
fixId14,
|
|
141384
|
+
changes,
|
|
141385
|
+
Diagnostics.Convert_typedef_to_TypeScript_type,
|
|
141386
|
+
fixId14,
|
|
141387
|
+
Diagnostics.Convert_all_typedef_to_TypeScript_types
|
|
141388
|
+
)
|
|
141389
|
+
];
|
|
141390
|
+
}
|
|
141391
|
+
},
|
|
141392
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
|
|
141393
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
141394
|
+
if (node)
|
|
141395
|
+
doChange5(changes, node, diag2.file);
|
|
141396
|
+
})
|
|
141397
|
+
});
|
|
141398
|
+
function doChange5(changes, node, sourceFile) {
|
|
141399
|
+
if (isJSDocTypedefTag(node)) {
|
|
141400
|
+
fixSingleTypeDef(changes, node, sourceFile);
|
|
141401
|
+
}
|
|
141402
|
+
}
|
|
141403
|
+
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
141404
|
+
if (!typeDefNode)
|
|
141405
|
+
return;
|
|
141406
|
+
const declaration = createDeclaration(typeDefNode);
|
|
141407
|
+
if (!declaration)
|
|
141408
|
+
return;
|
|
141409
|
+
const comment = typeDefNode.parent;
|
|
141410
|
+
changes.replaceNode(
|
|
141411
|
+
sourceFile,
|
|
141412
|
+
comment,
|
|
141413
|
+
declaration
|
|
141414
|
+
);
|
|
141415
|
+
}
|
|
141416
|
+
function createDeclaration(tag) {
|
|
141417
|
+
var _a2;
|
|
141418
|
+
const { typeExpression } = tag;
|
|
141419
|
+
if (!typeExpression)
|
|
141420
|
+
return;
|
|
141421
|
+
const typeName = (_a2 = tag.name) == null ? void 0 : _a2.getText();
|
|
141422
|
+
if (!typeName)
|
|
141228
141423
|
return;
|
|
141424
|
+
if (typeExpression.kind === 325 /* JSDocTypeLiteral */) {
|
|
141425
|
+
return createInterfaceForTypeLiteral(typeName, typeExpression);
|
|
141229
141426
|
}
|
|
141230
|
-
|
|
141231
|
-
|
|
141232
|
-
|
|
141233
|
-
|
|
141234
|
-
|
|
141235
|
-
|
|
141236
|
-
|
|
141237
|
-
|
|
141238
|
-
|
|
141239
|
-
|
|
141240
|
-
|
|
141241
|
-
|
|
141242
|
-
|
|
141243
|
-
|
|
141244
|
-
|
|
141245
|
-
|
|
141246
|
-
|
|
141247
|
-
|
|
141248
|
-
|
|
141427
|
+
if (typeExpression.kind === 312 /* JSDocTypeExpression */) {
|
|
141428
|
+
return createTypeAliasForTypeExpression(typeName, typeExpression);
|
|
141429
|
+
}
|
|
141430
|
+
}
|
|
141431
|
+
function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
141432
|
+
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
141433
|
+
if (!some(propertySignatures))
|
|
141434
|
+
return;
|
|
141435
|
+
const interfaceDeclaration = factory.createInterfaceDeclaration(
|
|
141436
|
+
/*modifiers*/
|
|
141437
|
+
void 0,
|
|
141438
|
+
typeName,
|
|
141439
|
+
/*typeParameters*/
|
|
141440
|
+
void 0,
|
|
141441
|
+
/*heritageClauses*/
|
|
141442
|
+
void 0,
|
|
141443
|
+
propertySignatures
|
|
141444
|
+
);
|
|
141445
|
+
return interfaceDeclaration;
|
|
141446
|
+
}
|
|
141447
|
+
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
141448
|
+
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
141449
|
+
if (!typeReference)
|
|
141450
|
+
return;
|
|
141451
|
+
const declaration = factory.createTypeAliasDeclaration(
|
|
141452
|
+
/*modifiers*/
|
|
141453
|
+
void 0,
|
|
141454
|
+
factory.createIdentifier(typeName),
|
|
141455
|
+
/*typeParameters*/
|
|
141456
|
+
void 0,
|
|
141457
|
+
typeReference
|
|
141458
|
+
);
|
|
141459
|
+
return declaration;
|
|
141460
|
+
}
|
|
141461
|
+
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
141462
|
+
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
141463
|
+
if (!some(propertyTags))
|
|
141464
|
+
return;
|
|
141465
|
+
const getSignature = (tag) => {
|
|
141466
|
+
var _a2;
|
|
141467
|
+
const name = getPropertyName(tag);
|
|
141468
|
+
const type = (_a2 = tag.typeExpression) == null ? void 0 : _a2.type;
|
|
141469
|
+
const isOptional = tag.isBracketed;
|
|
141470
|
+
let typeReference;
|
|
141471
|
+
if (type && isJSDocTypeLiteral(type)) {
|
|
141472
|
+
const signatures = createSignatureFromTypeLiteral(type);
|
|
141473
|
+
typeReference = factory.createTypeLiteralNode(signatures);
|
|
141474
|
+
} else if (type) {
|
|
141475
|
+
typeReference = getSynthesizedDeepClone(type);
|
|
141476
|
+
}
|
|
141477
|
+
if (typeReference && name) {
|
|
141478
|
+
const questionToken = isOptional ? factory.createToken(57 /* QuestionToken */) : void 0;
|
|
141479
|
+
const prop = factory.createPropertySignature(
|
|
141480
|
+
/*modifiers*/
|
|
141481
|
+
void 0,
|
|
141482
|
+
name,
|
|
141483
|
+
questionToken,
|
|
141484
|
+
typeReference
|
|
141485
|
+
);
|
|
141486
|
+
return prop;
|
|
141487
|
+
}
|
|
141488
|
+
};
|
|
141489
|
+
const props = mapDefined(propertyTags, getSignature);
|
|
141490
|
+
return props;
|
|
141491
|
+
}
|
|
141492
|
+
function getPropertyName(tag) {
|
|
141493
|
+
return tag.name.kind === 79 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
141494
|
+
}
|
|
141495
|
+
function getJSDocTypedefNode(node) {
|
|
141496
|
+
if (hasJSDocNodes(node)) {
|
|
141497
|
+
return forEach(node.jsDoc, (node2) => {
|
|
141498
|
+
var _a2;
|
|
141499
|
+
return (_a2 = node2.tags) == null ? void 0 : _a2.find(isJSDocTypedefTag);
|
|
141500
|
+
});
|
|
141249
141501
|
}
|
|
141502
|
+
return void 0;
|
|
141250
141503
|
}
|
|
141251
141504
|
|
|
141252
141505
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
141253
|
-
var
|
|
141254
|
-
var
|
|
141506
|
+
var fixId15 = "convertLiteralTypeToMappedType";
|
|
141507
|
+
var 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];
|
|
141255
141508
|
registerCodeFix({
|
|
141256
|
-
errorCodes:
|
|
141509
|
+
errorCodes: errorCodes16,
|
|
141257
141510
|
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
|
|
141258
141511
|
const { sourceFile, span } = context;
|
|
141259
141512
|
const info = getInfo2(sourceFile, span.start);
|
|
@@ -141261,14 +141514,14 @@ registerCodeFix({
|
|
|
141261
141514
|
return void 0;
|
|
141262
141515
|
}
|
|
141263
141516
|
const { name, constraint } = info;
|
|
141264
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141265
|
-
return [createCodeFixAction(
|
|
141517
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange6(t, sourceFile, info));
|
|
141518
|
+
return [createCodeFixAction(fixId15, changes, [Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId15, Diagnostics.Convert_all_type_literals_to_mapped_type)];
|
|
141266
141519
|
},
|
|
141267
|
-
fixIds: [
|
|
141268
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141520
|
+
fixIds: [fixId15],
|
|
141521
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes16, (changes, diag2) => {
|
|
141269
141522
|
const info = getInfo2(diag2.file, diag2.start);
|
|
141270
141523
|
if (info) {
|
|
141271
|
-
|
|
141524
|
+
doChange6(changes, diag2.file, info);
|
|
141272
141525
|
}
|
|
141273
141526
|
})
|
|
141274
141527
|
});
|
|
@@ -141286,7 +141539,7 @@ function getInfo2(sourceFile, pos) {
|
|
|
141286
141539
|
}
|
|
141287
141540
|
return void 0;
|
|
141288
141541
|
}
|
|
141289
|
-
function
|
|
141542
|
+
function doChange6(changes, sourceFile, { container, typeNode, constraint, name }) {
|
|
141290
141543
|
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
|
|
141291
141544
|
/*readonlyToken*/
|
|
141292
141545
|
void 0,
|
|
@@ -141307,25 +141560,25 @@ function doChange4(changes, sourceFile, { container, typeNode, constraint, name
|
|
|
141307
141560
|
}
|
|
141308
141561
|
|
|
141309
141562
|
// src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts
|
|
141310
|
-
var
|
|
141563
|
+
var errorCodes17 = [
|
|
141311
141564
|
Diagnostics.Class_0_incorrectly_implements_interface_1.code,
|
|
141312
141565
|
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code
|
|
141313
141566
|
];
|
|
141314
|
-
var
|
|
141567
|
+
var fixId16 = "fixClassIncorrectlyImplementsInterface";
|
|
141315
141568
|
registerCodeFix({
|
|
141316
|
-
errorCodes:
|
|
141569
|
+
errorCodes: errorCodes17,
|
|
141317
141570
|
getCodeActions(context) {
|
|
141318
141571
|
const { sourceFile, span } = context;
|
|
141319
141572
|
const classDeclaration = getClass(sourceFile, span.start);
|
|
141320
141573
|
return mapDefined(getEffectiveImplementsTypeNodes(classDeclaration), (implementedTypeNode) => {
|
|
141321
141574
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences));
|
|
141322
|
-
return changes.length === 0 ? void 0 : createCodeFixAction(
|
|
141575
|
+
return changes.length === 0 ? void 0 : createCodeFixAction(fixId16, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId16, Diagnostics.Implement_all_unimplemented_interfaces);
|
|
141323
141576
|
});
|
|
141324
141577
|
},
|
|
141325
|
-
fixIds: [
|
|
141578
|
+
fixIds: [fixId16],
|
|
141326
141579
|
getAllCodeActions(context) {
|
|
141327
141580
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
141328
|
-
return codeFixAll(context,
|
|
141581
|
+
return codeFixAll(context, errorCodes17, (changes, diag2) => {
|
|
141329
141582
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
141330
141583
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
141331
141584
|
for (const implementedTypeNode of getEffectiveImplementsTypeNodes(classDeclaration)) {
|
|
@@ -141390,7 +141643,7 @@ function getHeritageClauseSymbolTable(classDeclaration, checker) {
|
|
|
141390
141643
|
// src/services/codefixes/importFixes.ts
|
|
141391
141644
|
var importFixName = "import";
|
|
141392
141645
|
var importFixId = "fixMissingImport";
|
|
141393
|
-
var
|
|
141646
|
+
var errorCodes18 = [
|
|
141394
141647
|
Diagnostics.Cannot_find_name_0.code,
|
|
141395
141648
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
141396
141649
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
@@ -141402,7 +141655,7 @@ var errorCodes17 = [
|
|
|
141402
141655
|
Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
|
|
141403
141656
|
];
|
|
141404
141657
|
registerCodeFix({
|
|
141405
|
-
errorCodes:
|
|
141658
|
+
errorCodes: errorCodes18,
|
|
141406
141659
|
getCodeActions(context) {
|
|
141407
141660
|
const { errorCode, preferences, sourceFile, span, program } = context;
|
|
141408
141661
|
const info = getFixInfos(
|
|
@@ -141437,7 +141690,7 @@ registerCodeFix({
|
|
|
141437
141690
|
host,
|
|
141438
141691
|
cancellationToken
|
|
141439
141692
|
);
|
|
141440
|
-
eachDiagnostic(context,
|
|
141693
|
+
eachDiagnostic(context, errorCodes18, (diag2) => importAdder.addImportFromDiagnostic(diag2, context));
|
|
141441
141694
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, importAdder.writeFixes));
|
|
141442
141695
|
}
|
|
141443
141696
|
});
|
|
@@ -142603,8 +142856,8 @@ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitali
|
|
|
142603
142856
|
}
|
|
142604
142857
|
|
|
142605
142858
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
142606
|
-
var
|
|
142607
|
-
var
|
|
142859
|
+
var fixId17 = "addMissingConstraint";
|
|
142860
|
+
var errorCodes19 = [
|
|
142608
142861
|
// We want errors this could be attached to:
|
|
142609
142862
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
142610
142863
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -142617,21 +142870,21 @@ var errorCodes18 = [
|
|
|
142617
142870
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
142618
142871
|
];
|
|
142619
142872
|
registerCodeFix({
|
|
142620
|
-
errorCodes:
|
|
142873
|
+
errorCodes: errorCodes19,
|
|
142621
142874
|
getCodeActions(context) {
|
|
142622
142875
|
const { sourceFile, span, program, preferences, host } = context;
|
|
142623
142876
|
const info = getInfo3(program, sourceFile, span);
|
|
142624
142877
|
if (info === void 0)
|
|
142625
142878
|
return;
|
|
142626
142879
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
142627
|
-
return [createCodeFixAction(
|
|
142880
|
+
return [createCodeFixAction(fixId17, changes, Diagnostics.Add_extends_constraint, fixId17, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
142628
142881
|
},
|
|
142629
|
-
fixIds: [
|
|
142882
|
+
fixIds: [fixId17],
|
|
142630
142883
|
getAllCodeActions: (context) => {
|
|
142631
142884
|
const { program, preferences, host } = context;
|
|
142632
142885
|
const seen = /* @__PURE__ */ new Map();
|
|
142633
142886
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142634
|
-
eachDiagnostic(context,
|
|
142887
|
+
eachDiagnostic(context, errorCodes19, (diag2) => {
|
|
142635
142888
|
const info = getInfo3(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
142636
142889
|
if (info) {
|
|
142637
142890
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -142715,7 +142968,7 @@ function tryGetConstraintType(checker, node) {
|
|
|
142715
142968
|
var fixName = "fixOverrideModifier";
|
|
142716
142969
|
var fixAddOverrideId = "fixAddOverrideModifier";
|
|
142717
142970
|
var fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
142718
|
-
var
|
|
142971
|
+
var errorCodes20 = [
|
|
142719
142972
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
142720
142973
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
142721
142974
|
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
|
@@ -142779,20 +143032,20 @@ var errorCodeFixIdMap = {
|
|
|
142779
143032
|
}
|
|
142780
143033
|
};
|
|
142781
143034
|
registerCodeFix({
|
|
142782
|
-
errorCodes:
|
|
143035
|
+
errorCodes: errorCodes20,
|
|
142783
143036
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
142784
143037
|
const { errorCode, span } = context;
|
|
142785
143038
|
const info = errorCodeFixIdMap[errorCode];
|
|
142786
143039
|
if (!info)
|
|
142787
143040
|
return emptyArray;
|
|
142788
|
-
const { descriptions, fixId:
|
|
143041
|
+
const { descriptions, fixId: fixId52, fixAllDescriptions } = info;
|
|
142789
143042
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
142790
143043
|
return [
|
|
142791
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
143044
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId52, fixAllDescriptions)
|
|
142792
143045
|
];
|
|
142793
143046
|
},
|
|
142794
143047
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
142795
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143048
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes20, (changes, diag2) => {
|
|
142796
143049
|
const { code, start: start2 } = diag2;
|
|
142797
143050
|
const info = errorCodeFixIdMap[code];
|
|
142798
143051
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -142869,22 +143122,22 @@ function findContainerClassElementLike(sourceFile, pos) {
|
|
|
142869
143122
|
}
|
|
142870
143123
|
|
|
142871
143124
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
142872
|
-
var
|
|
142873
|
-
var
|
|
143125
|
+
var fixId18 = "fixNoPropertyAccessFromIndexSignature";
|
|
143126
|
+
var errorCodes21 = [
|
|
142874
143127
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
142875
143128
|
];
|
|
142876
143129
|
registerCodeFix({
|
|
142877
|
-
errorCodes:
|
|
142878
|
-
fixIds: [
|
|
143130
|
+
errorCodes: errorCodes21,
|
|
143131
|
+
fixIds: [fixId18],
|
|
142879
143132
|
getCodeActions(context) {
|
|
142880
143133
|
const { sourceFile, span, preferences } = context;
|
|
142881
143134
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
142882
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
142883
|
-
return [createCodeFixAction(
|
|
143135
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange7(t, context.sourceFile, property, preferences));
|
|
143136
|
+
return [createCodeFixAction(fixId18, changes, [Diagnostics.Use_element_access_for_0, property.name.text], fixId18, Diagnostics.Use_element_access_for_all_undeclared_properties)];
|
|
142884
143137
|
},
|
|
142885
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143138
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => doChange7(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
142886
143139
|
});
|
|
142887
|
-
function
|
|
143140
|
+
function doChange7(changes, sourceFile, node, preferences) {
|
|
142888
143141
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
142889
143142
|
const argumentsExpression = factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */);
|
|
142890
143143
|
changes.replaceNode(
|
|
@@ -142898,24 +143151,24 @@ function getPropertyAccessExpression(sourceFile, pos) {
|
|
|
142898
143151
|
}
|
|
142899
143152
|
|
|
142900
143153
|
// src/services/codefixes/fixImplicitThis.ts
|
|
142901
|
-
var
|
|
142902
|
-
var
|
|
143154
|
+
var fixId19 = "fixImplicitThis";
|
|
143155
|
+
var errorCodes22 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
142903
143156
|
registerCodeFix({
|
|
142904
|
-
errorCodes:
|
|
143157
|
+
errorCodes: errorCodes22,
|
|
142905
143158
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
142906
143159
|
const { sourceFile, program, span } = context;
|
|
142907
143160
|
let diagnostic;
|
|
142908
143161
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
142909
|
-
diagnostic =
|
|
143162
|
+
diagnostic = doChange8(t, sourceFile, span.start, program.getTypeChecker());
|
|
142910
143163
|
});
|
|
142911
|
-
return diagnostic ? [createCodeFixAction(
|
|
143164
|
+
return diagnostic ? [createCodeFixAction(fixId19, changes, diagnostic, fixId19, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
142912
143165
|
},
|
|
142913
|
-
fixIds: [
|
|
142914
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142915
|
-
|
|
143166
|
+
fixIds: [fixId19],
|
|
143167
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => {
|
|
143168
|
+
doChange8(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
142916
143169
|
})
|
|
142917
143170
|
});
|
|
142918
|
-
function
|
|
143171
|
+
function doChange8(changes, sourceFile, pos, checker) {
|
|
142919
143172
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
142920
143173
|
if (!isThis(token))
|
|
142921
143174
|
return void 0;
|
|
@@ -142958,26 +143211,26 @@ function doChange6(changes, sourceFile, pos, checker) {
|
|
|
142958
143211
|
}
|
|
142959
143212
|
|
|
142960
143213
|
// src/services/codefixes/fixImportNonExportedMember.ts
|
|
142961
|
-
var
|
|
142962
|
-
var
|
|
143214
|
+
var fixId20 = "fixImportNonExportedMember";
|
|
143215
|
+
var errorCodes23 = [
|
|
142963
143216
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
142964
143217
|
];
|
|
142965
143218
|
registerCodeFix({
|
|
142966
|
-
errorCodes:
|
|
142967
|
-
fixIds: [
|
|
143219
|
+
errorCodes: errorCodes23,
|
|
143220
|
+
fixIds: [fixId20],
|
|
142968
143221
|
getCodeActions(context) {
|
|
142969
143222
|
const { sourceFile, span, program } = context;
|
|
142970
143223
|
const info = getInfo4(sourceFile, span.start, program);
|
|
142971
143224
|
if (info === void 0)
|
|
142972
143225
|
return void 0;
|
|
142973
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
142974
|
-
return [createCodeFixAction(
|
|
143226
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange9(t, program, info));
|
|
143227
|
+
return [createCodeFixAction(fixId20, changes, [Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId20, Diagnostics.Export_all_referenced_locals)];
|
|
142975
143228
|
},
|
|
142976
143229
|
getAllCodeActions(context) {
|
|
142977
143230
|
const { program } = context;
|
|
142978
143231
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142979
143232
|
const exports = /* @__PURE__ */ new Map();
|
|
142980
|
-
eachDiagnostic(context,
|
|
143233
|
+
eachDiagnostic(context, errorCodes23, (diag2) => {
|
|
142981
143234
|
const info = getInfo4(diag2.file, diag2.start, program);
|
|
142982
143235
|
if (info === void 0)
|
|
142983
143236
|
return void 0;
|
|
@@ -143050,7 +143303,7 @@ function getInfo4(sourceFile, pos, program) {
|
|
|
143050
143303
|
}
|
|
143051
143304
|
return void 0;
|
|
143052
143305
|
}
|
|
143053
|
-
function
|
|
143306
|
+
function doChange9(changes, program, { exportName, node, moduleSourceFile }) {
|
|
143054
143307
|
const exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
143055
143308
|
if (exportDeclaration) {
|
|
143056
143309
|
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
@@ -143134,26 +143387,26 @@ function getNodeOfSymbol(symbol) {
|
|
|
143134
143387
|
}
|
|
143135
143388
|
|
|
143136
143389
|
// src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
|
|
143137
|
-
var
|
|
143138
|
-
var
|
|
143390
|
+
var fixId21 = "fixIncorrectNamedTupleSyntax";
|
|
143391
|
+
var errorCodes24 = [
|
|
143139
143392
|
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,
|
|
143140
143393
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
143141
143394
|
];
|
|
143142
143395
|
registerCodeFix({
|
|
143143
|
-
errorCodes:
|
|
143396
|
+
errorCodes: errorCodes24,
|
|
143144
143397
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
143145
143398
|
const { sourceFile, span } = context;
|
|
143146
143399
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
143147
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143148
|
-
return [createCodeFixAction(
|
|
143400
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange10(t, sourceFile, namedTupleMember));
|
|
143401
|
+
return [createCodeFixAction(fixId21, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId21, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
143149
143402
|
},
|
|
143150
|
-
fixIds: [
|
|
143403
|
+
fixIds: [fixId21]
|
|
143151
143404
|
});
|
|
143152
143405
|
function getNamedTupleMember(sourceFile, pos) {
|
|
143153
143406
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
143154
143407
|
return findAncestor(token, (t) => t.kind === 199 /* NamedTupleMember */);
|
|
143155
143408
|
}
|
|
143156
|
-
function
|
|
143409
|
+
function doChange10(changes, sourceFile, namedTupleMember) {
|
|
143157
143410
|
if (!namedTupleMember) {
|
|
143158
143411
|
return;
|
|
143159
143412
|
}
|
|
@@ -143182,8 +143435,8 @@ function doChange8(changes, sourceFile, namedTupleMember) {
|
|
|
143182
143435
|
}
|
|
143183
143436
|
|
|
143184
143437
|
// src/services/codefixes/fixSpelling.ts
|
|
143185
|
-
var
|
|
143186
|
-
var
|
|
143438
|
+
var fixId22 = "fixSpelling";
|
|
143439
|
+
var errorCodes25 = [
|
|
143187
143440
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143188
143441
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143189
143442
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -143200,7 +143453,7 @@ var errorCodes24 = [
|
|
|
143200
143453
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
143201
143454
|
];
|
|
143202
143455
|
registerCodeFix({
|
|
143203
|
-
errorCodes:
|
|
143456
|
+
errorCodes: errorCodes25,
|
|
143204
143457
|
getCodeActions(context) {
|
|
143205
143458
|
const { sourceFile, errorCode } = context;
|
|
143206
143459
|
const info = getInfo5(sourceFile, context.span.start, context, errorCode);
|
|
@@ -143208,15 +143461,15 @@ registerCodeFix({
|
|
|
143208
143461
|
return void 0;
|
|
143209
143462
|
const { node, suggestedSymbol } = info;
|
|
143210
143463
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
143211
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143212
|
-
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)],
|
|
143464
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, sourceFile, node, suggestedSymbol, target));
|
|
143465
|
+
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId22, Diagnostics.Fix_all_detected_spelling_errors)];
|
|
143213
143466
|
},
|
|
143214
|
-
fixIds: [
|
|
143215
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143467
|
+
fixIds: [fixId22],
|
|
143468
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes25, (changes, diag2) => {
|
|
143216
143469
|
const info = getInfo5(diag2.file, diag2.start, context, diag2.code);
|
|
143217
143470
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
143218
143471
|
if (info)
|
|
143219
|
-
|
|
143472
|
+
doChange11(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
143220
143473
|
})
|
|
143221
143474
|
});
|
|
143222
143475
|
function getInfo5(sourceFile, pos, context, errorCode) {
|
|
@@ -143268,7 +143521,7 @@ function getInfo5(sourceFile, pos, context, errorCode) {
|
|
|
143268
143521
|
}
|
|
143269
143522
|
return suggestedSymbol === void 0 ? void 0 : { node, suggestedSymbol };
|
|
143270
143523
|
}
|
|
143271
|
-
function
|
|
143524
|
+
function doChange11(changes, sourceFile, node, suggestedSymbol, target) {
|
|
143272
143525
|
const suggestion = symbolName(suggestedSymbol);
|
|
143273
143526
|
if (!isIdentifierText(suggestion, target) && isPropertyAccessExpression(node.parent)) {
|
|
143274
143527
|
const valDecl = suggestedSymbol.valueDeclaration;
|
|
@@ -143304,17 +143557,17 @@ function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importD
|
|
|
143304
143557
|
}
|
|
143305
143558
|
|
|
143306
143559
|
// src/services/codefixes/returnValueCorrect.ts
|
|
143307
|
-
var
|
|
143560
|
+
var fixId23 = "returnValueCorrect";
|
|
143308
143561
|
var fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
143309
143562
|
var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
143310
143563
|
var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
143311
|
-
var
|
|
143564
|
+
var errorCodes26 = [
|
|
143312
143565
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
143313
143566
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
143314
143567
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
143315
143568
|
];
|
|
143316
143569
|
registerCodeFix({
|
|
143317
|
-
errorCodes:
|
|
143570
|
+
errorCodes: errorCodes26,
|
|
143318
143571
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
143319
143572
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
143320
143573
|
const { program, sourceFile, span: { start: start2 }, errorCode } = context;
|
|
@@ -143330,7 +143583,7 @@ registerCodeFix({
|
|
|
143330
143583
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
143331
143584
|
}
|
|
143332
143585
|
},
|
|
143333
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143586
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
143334
143587
|
const info = getInfo6(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
143335
143588
|
if (!info)
|
|
143336
143589
|
return void 0;
|
|
@@ -143538,7 +143791,7 @@ function wrapBlockWithParen(changes, sourceFile, declaration, expression) {
|
|
|
143538
143791
|
}
|
|
143539
143792
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
143540
143793
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
143541
|
-
return createCodeFixAction(
|
|
143794
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
143542
143795
|
}
|
|
143543
143796
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
143544
143797
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -143550,11 +143803,11 @@ function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration,
|
|
|
143550
143803
|
/* withParen */
|
|
143551
143804
|
false
|
|
143552
143805
|
));
|
|
143553
|
-
return createCodeFixAction(
|
|
143806
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
|
143554
143807
|
}
|
|
143555
143808
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
143556
143809
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
143557
|
-
return createCodeFixAction(
|
|
143810
|
+
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);
|
|
143558
143811
|
}
|
|
143559
143812
|
|
|
143560
143813
|
// src/services/codefixes/fixAddMissingMember.ts
|
|
@@ -143562,7 +143815,7 @@ var fixMissingMember = "fixMissingMember";
|
|
|
143562
143815
|
var fixMissingProperties = "fixMissingProperties";
|
|
143563
143816
|
var fixMissingAttributes = "fixMissingAttributes";
|
|
143564
143817
|
var fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
143565
|
-
var
|
|
143818
|
+
var errorCodes27 = [
|
|
143566
143819
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
143567
143820
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143568
143821
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -143572,7 +143825,7 @@ var errorCodes26 = [
|
|
|
143572
143825
|
Diagnostics.Cannot_find_name_0.code
|
|
143573
143826
|
];
|
|
143574
143827
|
registerCodeFix({
|
|
143575
|
-
errorCodes:
|
|
143828
|
+
errorCodes: errorCodes27,
|
|
143576
143829
|
getCodeActions(context) {
|
|
143577
143830
|
const typeChecker = context.program.getTypeChecker();
|
|
143578
143831
|
const info = getInfo7(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -143599,21 +143852,21 @@ registerCodeFix({
|
|
|
143599
143852
|
},
|
|
143600
143853
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
143601
143854
|
getAllCodeActions: (context) => {
|
|
143602
|
-
const { program, fixId:
|
|
143855
|
+
const { program, fixId: fixId52 } = context;
|
|
143603
143856
|
const checker = program.getTypeChecker();
|
|
143604
143857
|
const seen = /* @__PURE__ */ new Map();
|
|
143605
143858
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
143606
143859
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
143607
|
-
eachDiagnostic(context,
|
|
143860
|
+
eachDiagnostic(context, errorCodes27, (diag2) => {
|
|
143608
143861
|
const info = getInfo7(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
143609
143862
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
|
|
143610
143863
|
return;
|
|
143611
143864
|
}
|
|
143612
|
-
if (
|
|
143865
|
+
if (fixId52 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
143613
143866
|
addFunctionDeclaration(changes, context, info);
|
|
143614
|
-
} else if (
|
|
143867
|
+
} else if (fixId52 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
143615
143868
|
addObjectLiteralProperties(changes, context, info);
|
|
143616
|
-
} else if (
|
|
143869
|
+
} else if (fixId52 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
143617
143870
|
addJsxAttributes(changes, context, info);
|
|
143618
143871
|
} else {
|
|
143619
143872
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -144185,17 +144438,17 @@ function findScope(node) {
|
|
|
144185
144438
|
}
|
|
144186
144439
|
|
|
144187
144440
|
// src/services/codefixes/fixAddMissingNewOperator.ts
|
|
144188
|
-
var
|
|
144189
|
-
var
|
|
144441
|
+
var fixId24 = "addMissingNewOperator";
|
|
144442
|
+
var errorCodes28 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
144190
144443
|
registerCodeFix({
|
|
144191
|
-
errorCodes:
|
|
144444
|
+
errorCodes: errorCodes28,
|
|
144192
144445
|
getCodeActions(context) {
|
|
144193
144446
|
const { sourceFile, span } = context;
|
|
144194
144447
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
144195
|
-
return [createCodeFixAction(
|
|
144448
|
+
return [createCodeFixAction(fixId24, changes, Diagnostics.Add_missing_new_operator_to_call, fixId24, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
144196
144449
|
},
|
|
144197
|
-
fixIds: [
|
|
144198
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144450
|
+
fixIds: [fixId24],
|
|
144451
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes28, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
144199
144452
|
});
|
|
144200
144453
|
function addMissingNewOperator(changes, sourceFile, span) {
|
|
144201
144454
|
const call = cast(findAncestorMatchingSpan2(sourceFile, span), isCallExpression);
|
|
@@ -144215,12 +144468,12 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
144215
144468
|
var fixName2 = "fixCannotFindModule";
|
|
144216
144469
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
144217
144470
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
144218
|
-
var
|
|
144471
|
+
var errorCodes29 = [
|
|
144219
144472
|
errorCodeCannotFindModule,
|
|
144220
144473
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
144221
144474
|
];
|
|
144222
144475
|
registerCodeFix({
|
|
144223
|
-
errorCodes:
|
|
144476
|
+
errorCodes: errorCodes29,
|
|
144224
144477
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
144225
144478
|
const { host, sourceFile, span: { start: start2 } } = context;
|
|
144226
144479
|
const packageName = tryGetImportedPackageName(sourceFile, start2);
|
|
@@ -144239,7 +144492,7 @@ registerCodeFix({
|
|
|
144239
144492
|
},
|
|
144240
144493
|
fixIds: [fixIdInstallTypesPackage],
|
|
144241
144494
|
getAllCodeActions: (context) => {
|
|
144242
|
-
return codeFixAll(context,
|
|
144495
|
+
return codeFixAll(context, errorCodes29, (_changes, diag2, commands) => {
|
|
144243
144496
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
144244
144497
|
if (packageName === void 0)
|
|
144245
144498
|
return void 0;
|
|
@@ -144274,22 +144527,22 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
144274
144527
|
}
|
|
144275
144528
|
|
|
144276
144529
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
144277
|
-
var
|
|
144530
|
+
var errorCodes30 = [
|
|
144278
144531
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
144279
144532
|
Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code
|
|
144280
144533
|
];
|
|
144281
|
-
var
|
|
144534
|
+
var fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
144282
144535
|
registerCodeFix({
|
|
144283
|
-
errorCodes:
|
|
144536
|
+
errorCodes: errorCodes30,
|
|
144284
144537
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
144285
144538
|
const { sourceFile, span } = context;
|
|
144286
144539
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
144287
|
-
return changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
144540
|
+
return changes.length === 0 ? void 0 : [createCodeFixAction(fixId25, changes, Diagnostics.Implement_inherited_abstract_class, fixId25, Diagnostics.Implement_all_inherited_abstract_classes)];
|
|
144288
144541
|
},
|
|
144289
|
-
fixIds: [
|
|
144542
|
+
fixIds: [fixId25],
|
|
144290
144543
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
144291
144544
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
144292
|
-
return codeFixAll(context,
|
|
144545
|
+
return codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
144293
144546
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
144294
144547
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
144295
144548
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -144316,35 +144569,35 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
144316
144569
|
}
|
|
144317
144570
|
|
|
144318
144571
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
144319
|
-
var
|
|
144320
|
-
var
|
|
144572
|
+
var fixId26 = "classSuperMustPrecedeThisAccess";
|
|
144573
|
+
var errorCodes31 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
144321
144574
|
registerCodeFix({
|
|
144322
|
-
errorCodes:
|
|
144575
|
+
errorCodes: errorCodes31,
|
|
144323
144576
|
getCodeActions(context) {
|
|
144324
144577
|
const { sourceFile, span } = context;
|
|
144325
144578
|
const nodes = getNodes(sourceFile, span.start);
|
|
144326
144579
|
if (!nodes)
|
|
144327
144580
|
return void 0;
|
|
144328
144581
|
const { constructor, superCall } = nodes;
|
|
144329
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144330
|
-
return [createCodeFixAction(
|
|
144582
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, sourceFile, constructor, superCall));
|
|
144583
|
+
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)];
|
|
144331
144584
|
},
|
|
144332
|
-
fixIds: [
|
|
144585
|
+
fixIds: [fixId26],
|
|
144333
144586
|
getAllCodeActions(context) {
|
|
144334
144587
|
const { sourceFile } = context;
|
|
144335
144588
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
144336
|
-
return codeFixAll(context,
|
|
144589
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
144337
144590
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
144338
144591
|
if (!nodes)
|
|
144339
144592
|
return;
|
|
144340
144593
|
const { constructor, superCall } = nodes;
|
|
144341
144594
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
144342
|
-
|
|
144595
|
+
doChange12(changes, sourceFile, constructor, superCall);
|
|
144343
144596
|
}
|
|
144344
144597
|
});
|
|
144345
144598
|
}
|
|
144346
144599
|
});
|
|
144347
|
-
function
|
|
144600
|
+
function doChange12(changes, sourceFile, constructor, superCall) {
|
|
144348
144601
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
144349
144602
|
changes.delete(sourceFile, superCall);
|
|
144350
144603
|
}
|
|
@@ -144361,25 +144614,25 @@ function findSuperCall(n) {
|
|
|
144361
144614
|
}
|
|
144362
144615
|
|
|
144363
144616
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
144364
|
-
var
|
|
144365
|
-
var
|
|
144617
|
+
var fixId27 = "constructorForDerivedNeedSuperCall";
|
|
144618
|
+
var errorCodes32 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
144366
144619
|
registerCodeFix({
|
|
144367
|
-
errorCodes:
|
|
144620
|
+
errorCodes: errorCodes32,
|
|
144368
144621
|
getCodeActions(context) {
|
|
144369
144622
|
const { sourceFile, span } = context;
|
|
144370
144623
|
const ctr = getNode(sourceFile, span.start);
|
|
144371
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144372
|
-
return [createCodeFixAction(
|
|
144624
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange13(t, sourceFile, ctr));
|
|
144625
|
+
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
144373
144626
|
},
|
|
144374
|
-
fixIds: [
|
|
144375
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144627
|
+
fixIds: [fixId27],
|
|
144628
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes32, (changes, diag2) => doChange13(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
144376
144629
|
});
|
|
144377
144630
|
function getNode(sourceFile, pos) {
|
|
144378
144631
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
144379
144632
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
144380
144633
|
return token.parent;
|
|
144381
144634
|
}
|
|
144382
|
-
function
|
|
144635
|
+
function doChange13(changes, sourceFile, ctr) {
|
|
144383
144636
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
144384
144637
|
factory.createSuper(),
|
|
144385
144638
|
/*typeArguments*/
|
|
@@ -144392,9 +144645,9 @@ function doChange11(changes, sourceFile, ctr) {
|
|
|
144392
144645
|
|
|
144393
144646
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
144394
144647
|
var fixID = "fixEnableJsxFlag";
|
|
144395
|
-
var
|
|
144648
|
+
var errorCodes33 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
144396
144649
|
registerCodeFix({
|
|
144397
|
-
errorCodes:
|
|
144650
|
+
errorCodes: errorCodes33,
|
|
144398
144651
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
144399
144652
|
const { configFile } = context.program.getCompilerOptions();
|
|
144400
144653
|
if (configFile === void 0) {
|
|
@@ -144402,47 +144655,47 @@ registerCodeFix({
|
|
|
144402
144655
|
}
|
|
144403
144656
|
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
144404
144657
|
context,
|
|
144405
|
-
(changeTracker) =>
|
|
144658
|
+
(changeTracker) => doChange14(changeTracker, configFile)
|
|
144406
144659
|
);
|
|
144407
144660
|
return [
|
|
144408
144661
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
144409
144662
|
];
|
|
144410
144663
|
},
|
|
144411
144664
|
fixIds: [fixID],
|
|
144412
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144665
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes) => {
|
|
144413
144666
|
const { configFile } = context.program.getCompilerOptions();
|
|
144414
144667
|
if (configFile === void 0) {
|
|
144415
144668
|
return void 0;
|
|
144416
144669
|
}
|
|
144417
|
-
|
|
144670
|
+
doChange14(changes, configFile);
|
|
144418
144671
|
})
|
|
144419
144672
|
});
|
|
144420
|
-
function
|
|
144673
|
+
function doChange14(changeTracker, configFile) {
|
|
144421
144674
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
144422
144675
|
}
|
|
144423
144676
|
|
|
144424
144677
|
// src/services/codefixes/fixNaNEquality.ts
|
|
144425
|
-
var
|
|
144426
|
-
var
|
|
144678
|
+
var fixId28 = "fixNaNEquality";
|
|
144679
|
+
var errorCodes34 = [
|
|
144427
144680
|
Diagnostics.This_condition_will_always_return_0.code
|
|
144428
144681
|
];
|
|
144429
144682
|
registerCodeFix({
|
|
144430
|
-
errorCodes:
|
|
144683
|
+
errorCodes: errorCodes34,
|
|
144431
144684
|
getCodeActions(context) {
|
|
144432
144685
|
const { sourceFile, span, program } = context;
|
|
144433
144686
|
const info = getInfo8(program, sourceFile, span);
|
|
144434
144687
|
if (info === void 0)
|
|
144435
144688
|
return;
|
|
144436
144689
|
const { suggestion, expression, arg } = info;
|
|
144437
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144438
|
-
return [createCodeFixAction(
|
|
144690
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange15(t, sourceFile, arg, expression));
|
|
144691
|
+
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
144439
144692
|
},
|
|
144440
|
-
fixIds: [
|
|
144693
|
+
fixIds: [fixId28],
|
|
144441
144694
|
getAllCodeActions: (context) => {
|
|
144442
|
-
return codeFixAll(context,
|
|
144695
|
+
return codeFixAll(context, errorCodes34, (changes, diag2) => {
|
|
144443
144696
|
const info = getInfo8(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
144444
144697
|
if (info) {
|
|
144445
|
-
|
|
144698
|
+
doChange15(changes, diag2.file, info.arg, info.expression);
|
|
144446
144699
|
}
|
|
144447
144700
|
});
|
|
144448
144701
|
}
|
|
@@ -144462,7 +144715,7 @@ function getInfo8(program, sourceFile, span) {
|
|
|
144462
144715
|
}
|
|
144463
144716
|
return void 0;
|
|
144464
144717
|
}
|
|
144465
|
-
function
|
|
144718
|
+
function doChange15(changes, sourceFile, arg, expression) {
|
|
144466
144719
|
const callExpression = factory.createCallExpression(
|
|
144467
144720
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
144468
144721
|
/*typeArguments*/
|
|
@@ -144522,22 +144775,22 @@ registerCodeFix({
|
|
|
144522
144775
|
});
|
|
144523
144776
|
|
|
144524
144777
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
144525
|
-
var
|
|
144526
|
-
var
|
|
144778
|
+
var fixId29 = "fixPropertyAssignment";
|
|
144779
|
+
var errorCodes35 = [
|
|
144527
144780
|
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
|
|
144528
144781
|
];
|
|
144529
144782
|
registerCodeFix({
|
|
144530
|
-
errorCodes:
|
|
144531
|
-
fixIds: [
|
|
144783
|
+
errorCodes: errorCodes35,
|
|
144784
|
+
fixIds: [fixId29],
|
|
144532
144785
|
getCodeActions(context) {
|
|
144533
144786
|
const { sourceFile, span } = context;
|
|
144534
144787
|
const property = getProperty2(sourceFile, span.start);
|
|
144535
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144536
|
-
return [createCodeFixAction(
|
|
144788
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, context.sourceFile, property));
|
|
144789
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
144537
144790
|
},
|
|
144538
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144791
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes, diag2) => doChange16(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
144539
144792
|
});
|
|
144540
|
-
function
|
|
144793
|
+
function doChange16(changes, sourceFile, node) {
|
|
144541
144794
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
144542
144795
|
}
|
|
144543
144796
|
function getProperty2(sourceFile, pos) {
|
|
@@ -144545,10 +144798,10 @@ function getProperty2(sourceFile, pos) {
|
|
|
144545
144798
|
}
|
|
144546
144799
|
|
|
144547
144800
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
144548
|
-
var
|
|
144549
|
-
var
|
|
144801
|
+
var fixId30 = "extendsInterfaceBecomesImplements";
|
|
144802
|
+
var errorCodes36 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
144550
144803
|
registerCodeFix({
|
|
144551
|
-
errorCodes:
|
|
144804
|
+
errorCodes: errorCodes36,
|
|
144552
144805
|
getCodeActions(context) {
|
|
144553
144806
|
const { sourceFile } = context;
|
|
144554
144807
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -144556,10 +144809,10 @@ registerCodeFix({
|
|
|
144556
144809
|
return void 0;
|
|
144557
144810
|
const { extendsToken, heritageClauses } = nodes;
|
|
144558
144811
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
144559
|
-
return [createCodeFixAction(
|
|
144812
|
+
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
144560
144813
|
},
|
|
144561
|
-
fixIds: [
|
|
144562
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144814
|
+
fixIds: [fixId30],
|
|
144815
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
144563
144816
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
144564
144817
|
if (nodes)
|
|
144565
144818
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -144587,29 +144840,29 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
144587
144840
|
}
|
|
144588
144841
|
|
|
144589
144842
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
144590
|
-
var
|
|
144843
|
+
var fixId31 = "forgottenThisPropertyAccess";
|
|
144591
144844
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
144592
|
-
var
|
|
144845
|
+
var errorCodes37 = [
|
|
144593
144846
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
144594
144847
|
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,
|
|
144595
144848
|
didYouMeanStaticMemberCode
|
|
144596
144849
|
];
|
|
144597
144850
|
registerCodeFix({
|
|
144598
|
-
errorCodes:
|
|
144851
|
+
errorCodes: errorCodes37,
|
|
144599
144852
|
getCodeActions(context) {
|
|
144600
144853
|
const { sourceFile } = context;
|
|
144601
144854
|
const info = getInfo9(sourceFile, context.span.start, context.errorCode);
|
|
144602
144855
|
if (!info) {
|
|
144603
144856
|
return void 0;
|
|
144604
144857
|
}
|
|
144605
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144606
|
-
return [createCodeFixAction(
|
|
144858
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, info));
|
|
144859
|
+
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)];
|
|
144607
144860
|
},
|
|
144608
|
-
fixIds: [
|
|
144609
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144861
|
+
fixIds: [fixId31],
|
|
144862
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
144610
144863
|
const info = getInfo9(diag2.file, diag2.start, diag2.code);
|
|
144611
144864
|
if (info)
|
|
144612
|
-
|
|
144865
|
+
doChange17(changes, context.sourceFile, info);
|
|
144613
144866
|
})
|
|
144614
144867
|
});
|
|
144615
144868
|
function getInfo9(sourceFile, pos, diagCode) {
|
|
@@ -144618,7 +144871,7 @@ function getInfo9(sourceFile, pos, diagCode) {
|
|
|
144618
144871
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
144619
144872
|
}
|
|
144620
144873
|
}
|
|
144621
|
-
function
|
|
144874
|
+
function doChange17(changes, sourceFile, { node, className }) {
|
|
144622
144875
|
suppressLeadingAndTrailingTrivia(node);
|
|
144623
144876
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
144624
144877
|
}
|
|
@@ -144626,16 +144879,16 @@ function doChange15(changes, sourceFile, { node, className }) {
|
|
|
144626
144879
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
144627
144880
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
144628
144881
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
144629
|
-
var
|
|
144882
|
+
var errorCodes38 = [
|
|
144630
144883
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
144631
144884
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
144632
144885
|
];
|
|
144633
144886
|
registerCodeFix({
|
|
144634
|
-
errorCodes:
|
|
144887
|
+
errorCodes: errorCodes38,
|
|
144635
144888
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
144636
144889
|
getCodeActions(context) {
|
|
144637
144890
|
const { sourceFile, preferences, span } = context;
|
|
144638
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144891
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
144639
144892
|
t,
|
|
144640
144893
|
preferences,
|
|
144641
144894
|
sourceFile,
|
|
@@ -144643,7 +144896,7 @@ registerCodeFix({
|
|
|
144643
144896
|
/* useHtmlEntity */
|
|
144644
144897
|
false
|
|
144645
144898
|
));
|
|
144646
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144899
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
144647
144900
|
t,
|
|
144648
144901
|
preferences,
|
|
144649
144902
|
sourceFile,
|
|
@@ -144657,7 +144910,7 @@ registerCodeFix({
|
|
|
144657
144910
|
];
|
|
144658
144911
|
},
|
|
144659
144912
|
getAllCodeActions(context) {
|
|
144660
|
-
return codeFixAll(context,
|
|
144913
|
+
return codeFixAll(context, errorCodes38, (changes, diagnostic) => doChange18(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
144661
144914
|
}
|
|
144662
144915
|
});
|
|
144663
144916
|
var htmlEntity = {
|
|
@@ -144667,7 +144920,7 @@ var htmlEntity = {
|
|
|
144667
144920
|
function isValidCharacter(character) {
|
|
144668
144921
|
return hasProperty(htmlEntity, character);
|
|
144669
144922
|
}
|
|
144670
|
-
function
|
|
144923
|
+
function doChange18(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
144671
144924
|
const character = sourceFile.getText()[start2];
|
|
144672
144925
|
if (!isValidCharacter(character)) {
|
|
144673
144926
|
return;
|
|
@@ -144679,12 +144932,12 @@ function doChange16(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
|
144679
144932
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
144680
144933
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
144681
144934
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
144682
|
-
var
|
|
144935
|
+
var errorCodes39 = [
|
|
144683
144936
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
144684
144937
|
];
|
|
144685
144938
|
registerCodeFix({
|
|
144686
144939
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
144687
|
-
errorCodes:
|
|
144940
|
+
errorCodes: errorCodes39,
|
|
144688
144941
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
144689
144942
|
const { sourceFile, span } = context;
|
|
144690
144943
|
const actions2 = [];
|
|
@@ -144699,7 +144952,7 @@ registerCodeFix({
|
|
|
144699
144952
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
144700
144953
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
144701
144954
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
144702
|
-
eachDiagnostic(context,
|
|
144955
|
+
eachDiagnostic(context, errorCodes39, ({ file, start: start2 }) => {
|
|
144703
144956
|
const info = getInfo10(file, start2);
|
|
144704
144957
|
if (info) {
|
|
144705
144958
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -144764,10 +145017,10 @@ function getInfo10(sourceFile, pos) {
|
|
|
144764
145017
|
}
|
|
144765
145018
|
|
|
144766
145019
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
144767
|
-
var
|
|
144768
|
-
var
|
|
145020
|
+
var fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
145021
|
+
var 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];
|
|
144769
145022
|
registerCodeFix({
|
|
144770
|
-
errorCodes:
|
|
145023
|
+
errorCodes: errorCodes40,
|
|
144771
145024
|
getCodeActions: (context) => {
|
|
144772
145025
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
144773
145026
|
if (!importDeclaration)
|
|
@@ -144776,14 +145029,14 @@ registerCodeFix({
|
|
|
144776
145029
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
144777
145030
|
let actions2;
|
|
144778
145031
|
if (namespaceChanges.length) {
|
|
144779
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
145032
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
144780
145033
|
}
|
|
144781
145034
|
if (typeOnlyChanges.length) {
|
|
144782
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
145035
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
144783
145036
|
}
|
|
144784
145037
|
return actions2;
|
|
144785
145038
|
},
|
|
144786
|
-
fixIds: [
|
|
145039
|
+
fixIds: [fixId32]
|
|
144787
145040
|
});
|
|
144788
145041
|
function getImportDeclaration(sourceFile, program, start2) {
|
|
144789
145042
|
const identifier = tryCast(getTokenAtPosition(sourceFile, start2), isIdentifier);
|
|
@@ -144822,7 +145075,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
144822
145075
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
144823
145076
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
144824
145077
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
144825
|
-
var
|
|
145078
|
+
var errorCodes41 = [
|
|
144826
145079
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
144827
145080
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
144828
145081
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -144832,7 +145085,7 @@ var errorCodes40 = [
|
|
|
144832
145085
|
Diagnostics.All_type_parameters_are_unused.code
|
|
144833
145086
|
];
|
|
144834
145087
|
registerCodeFix({
|
|
144835
|
-
errorCodes:
|
|
145088
|
+
errorCodes: errorCodes41,
|
|
144836
145089
|
getCodeActions(context) {
|
|
144837
145090
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
144838
145091
|
const checker = program.getTypeChecker();
|
|
@@ -144918,7 +145171,7 @@ registerCodeFix({
|
|
|
144918
145171
|
const { sourceFile, program, cancellationToken } = context;
|
|
144919
145172
|
const checker = program.getTypeChecker();
|
|
144920
145173
|
const sourceFiles = program.getSourceFiles();
|
|
144921
|
-
return codeFixAll(context,
|
|
145174
|
+
return codeFixAll(context, errorCodes41, (changes, diag2) => {
|
|
144922
145175
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
144923
145176
|
switch (context.fixId) {
|
|
144924
145177
|
case fixIdPrefix:
|
|
@@ -145135,21 +145388,21 @@ function mayDeleteExpression(node) {
|
|
|
145135
145388
|
}
|
|
145136
145389
|
|
|
145137
145390
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
145138
|
-
var
|
|
145139
|
-
var
|
|
145391
|
+
var fixId33 = "fixUnreachableCode";
|
|
145392
|
+
var errorCodes42 = [Diagnostics.Unreachable_code_detected.code];
|
|
145140
145393
|
registerCodeFix({
|
|
145141
|
-
errorCodes:
|
|
145394
|
+
errorCodes: errorCodes42,
|
|
145142
145395
|
getCodeActions(context) {
|
|
145143
145396
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
145144
145397
|
if (syntacticDiagnostics.length)
|
|
145145
145398
|
return;
|
|
145146
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145147
|
-
return [createCodeFixAction(
|
|
145399
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
145400
|
+
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
145148
145401
|
},
|
|
145149
|
-
fixIds: [
|
|
145150
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145402
|
+
fixIds: [fixId33],
|
|
145403
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes42, (changes, diag2) => doChange19(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
145151
145404
|
});
|
|
145152
|
-
function
|
|
145405
|
+
function doChange19(changes, sourceFile, start2, length2, errorCode) {
|
|
145153
145406
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145154
145407
|
const statement = findAncestor(token, isStatement);
|
|
145155
145408
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -145199,18 +145452,18 @@ function lastWhere(a, pred) {
|
|
|
145199
145452
|
}
|
|
145200
145453
|
|
|
145201
145454
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
145202
|
-
var
|
|
145203
|
-
var
|
|
145455
|
+
var fixId34 = "fixUnusedLabel";
|
|
145456
|
+
var errorCodes43 = [Diagnostics.Unused_label.code];
|
|
145204
145457
|
registerCodeFix({
|
|
145205
|
-
errorCodes:
|
|
145458
|
+
errorCodes: errorCodes43,
|
|
145206
145459
|
getCodeActions(context) {
|
|
145207
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145208
|
-
return [createCodeFixAction(
|
|
145460
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, context.sourceFile, context.span.start));
|
|
145461
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
145209
145462
|
},
|
|
145210
|
-
fixIds: [
|
|
145211
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145463
|
+
fixIds: [fixId34],
|
|
145464
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange20(changes, diag2.file, diag2.start))
|
|
145212
145465
|
});
|
|
145213
|
-
function
|
|
145466
|
+
function doChange20(changes, sourceFile, start2) {
|
|
145214
145467
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145215
145468
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
145216
145469
|
const pos = token.getStart(sourceFile);
|
|
@@ -145227,13 +145480,13 @@ function doChange18(changes, sourceFile, start2) {
|
|
|
145227
145480
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
145228
145481
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
145229
145482
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
145230
|
-
var
|
|
145483
|
+
var errorCodes44 = [
|
|
145231
145484
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
145232
145485
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
145233
145486
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
145234
145487
|
];
|
|
145235
145488
|
registerCodeFix({
|
|
145236
|
-
errorCodes:
|
|
145489
|
+
errorCodes: errorCodes44,
|
|
145237
145490
|
getCodeActions(context) {
|
|
145238
145491
|
const { sourceFile } = context;
|
|
145239
145492
|
const checker = context.program.getTypeChecker();
|
|
@@ -145247,26 +145500,26 @@ registerCodeFix({
|
|
|
145247
145500
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
145248
145501
|
}
|
|
145249
145502
|
return actions2;
|
|
145250
|
-
function fix(type2,
|
|
145251
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145252
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
145503
|
+
function fix(type2, fixId52, fixAllDescription) {
|
|
145504
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, typeNode, type2, checker));
|
|
145505
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
145253
145506
|
}
|
|
145254
145507
|
},
|
|
145255
145508
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
145256
145509
|
getAllCodeActions(context) {
|
|
145257
|
-
const { fixId:
|
|
145510
|
+
const { fixId: fixId52, program, sourceFile } = context;
|
|
145258
145511
|
const checker = program.getTypeChecker();
|
|
145259
|
-
return codeFixAll(context,
|
|
145512
|
+
return codeFixAll(context, errorCodes44, (changes, err) => {
|
|
145260
145513
|
const info = getInfo11(err.file, err.start, checker);
|
|
145261
145514
|
if (!info)
|
|
145262
145515
|
return;
|
|
145263
145516
|
const { typeNode, type } = info;
|
|
145264
|
-
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ &&
|
|
145265
|
-
|
|
145517
|
+
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
145518
|
+
doChange21(changes, sourceFile, typeNode, fixedType, checker);
|
|
145266
145519
|
});
|
|
145267
145520
|
}
|
|
145268
145521
|
});
|
|
145269
|
-
function
|
|
145522
|
+
function doChange21(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
145270
145523
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
145271
145524
|
newType,
|
|
145272
145525
|
/*enclosingDeclaration*/
|
|
@@ -145317,28 +145570,28 @@ function getType(checker, node) {
|
|
|
145317
145570
|
}
|
|
145318
145571
|
|
|
145319
145572
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
145320
|
-
var
|
|
145321
|
-
var
|
|
145573
|
+
var fixId35 = "fixMissingCallParentheses";
|
|
145574
|
+
var errorCodes45 = [
|
|
145322
145575
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
145323
145576
|
];
|
|
145324
145577
|
registerCodeFix({
|
|
145325
|
-
errorCodes:
|
|
145326
|
-
fixIds: [
|
|
145578
|
+
errorCodes: errorCodes45,
|
|
145579
|
+
fixIds: [fixId35],
|
|
145327
145580
|
getCodeActions(context) {
|
|
145328
145581
|
const { sourceFile, span } = context;
|
|
145329
145582
|
const callName = getCallName(sourceFile, span.start);
|
|
145330
145583
|
if (!callName)
|
|
145331
145584
|
return;
|
|
145332
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145333
|
-
return [createCodeFixAction(
|
|
145585
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange22(t, context.sourceFile, callName));
|
|
145586
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
145334
145587
|
},
|
|
145335
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145588
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => {
|
|
145336
145589
|
const callName = getCallName(diag2.file, diag2.start);
|
|
145337
145590
|
if (callName)
|
|
145338
|
-
|
|
145591
|
+
doChange22(changes, diag2.file, callName);
|
|
145339
145592
|
})
|
|
145340
145593
|
});
|
|
145341
|
-
function
|
|
145594
|
+
function doChange22(changes, sourceFile, name) {
|
|
145342
145595
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
145343
145596
|
}
|
|
145344
145597
|
function getCallName(sourceFile, start2) {
|
|
@@ -145357,30 +145610,30 @@ function getCallName(sourceFile, start2) {
|
|
|
145357
145610
|
}
|
|
145358
145611
|
|
|
145359
145612
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
145360
|
-
var
|
|
145361
|
-
var
|
|
145613
|
+
var fixId36 = "fixAwaitInSyncFunction";
|
|
145614
|
+
var errorCodes46 = [
|
|
145362
145615
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
145363
145616
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
145364
145617
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
145365
145618
|
];
|
|
145366
145619
|
registerCodeFix({
|
|
145367
|
-
errorCodes:
|
|
145620
|
+
errorCodes: errorCodes46,
|
|
145368
145621
|
getCodeActions(context) {
|
|
145369
145622
|
const { sourceFile, span } = context;
|
|
145370
145623
|
const nodes = getNodes3(sourceFile, span.start);
|
|
145371
145624
|
if (!nodes)
|
|
145372
145625
|
return void 0;
|
|
145373
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145374
|
-
return [createCodeFixAction(
|
|
145626
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, nodes));
|
|
145627
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
145375
145628
|
},
|
|
145376
|
-
fixIds: [
|
|
145629
|
+
fixIds: [fixId36],
|
|
145377
145630
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
145378
145631
|
const seen = /* @__PURE__ */ new Map();
|
|
145379
|
-
return codeFixAll(context,
|
|
145632
|
+
return codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
145380
145633
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
145381
145634
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
145382
145635
|
return;
|
|
145383
|
-
|
|
145636
|
+
doChange23(changes, context.sourceFile, nodes);
|
|
145384
145637
|
});
|
|
145385
145638
|
}
|
|
145386
145639
|
});
|
|
@@ -145419,7 +145672,7 @@ function getNodes3(sourceFile, start2) {
|
|
|
145419
145672
|
returnType: getReturnType(containingFunction)
|
|
145420
145673
|
};
|
|
145421
145674
|
}
|
|
145422
|
-
function
|
|
145675
|
+
function doChange23(changes, sourceFile, { insertBefore, returnType }) {
|
|
145423
145676
|
if (returnType) {
|
|
145424
145677
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
145425
145678
|
if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -145430,22 +145683,22 @@ function doChange21(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
145430
145683
|
}
|
|
145431
145684
|
|
|
145432
145685
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
145433
|
-
var
|
|
145686
|
+
var errorCodes47 = [
|
|
145434
145687
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
145435
145688
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
145436
145689
|
];
|
|
145437
|
-
var
|
|
145690
|
+
var fixId37 = "fixPropertyOverrideAccessor";
|
|
145438
145691
|
registerCodeFix({
|
|
145439
|
-
errorCodes:
|
|
145692
|
+
errorCodes: errorCodes47,
|
|
145440
145693
|
getCodeActions(context) {
|
|
145441
|
-
const edits =
|
|
145694
|
+
const edits = doChange24(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
145442
145695
|
if (edits) {
|
|
145443
|
-
return [createCodeFixAction(
|
|
145696
|
+
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
145444
145697
|
}
|
|
145445
145698
|
},
|
|
145446
|
-
fixIds: [
|
|
145447
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145448
|
-
const edits =
|
|
145699
|
+
fixIds: [fixId37],
|
|
145700
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
145701
|
+
const edits = doChange24(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
145449
145702
|
if (edits) {
|
|
145450
145703
|
for (const edit of edits) {
|
|
145451
145704
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -145453,7 +145706,7 @@ registerCodeFix({
|
|
|
145453
145706
|
}
|
|
145454
145707
|
})
|
|
145455
145708
|
});
|
|
145456
|
-
function
|
|
145709
|
+
function doChange24(file, start2, length2, code, context) {
|
|
145457
145710
|
let startPosition;
|
|
145458
145711
|
let endPosition;
|
|
145459
145712
|
if (code === Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code) {
|
|
@@ -145482,8 +145735,8 @@ function doChange22(file, start2, length2, code, context) {
|
|
|
145482
145735
|
}
|
|
145483
145736
|
|
|
145484
145737
|
// src/services/codefixes/inferFromUsage.ts
|
|
145485
|
-
var
|
|
145486
|
-
var
|
|
145738
|
+
var fixId38 = "inferFromUsage";
|
|
145739
|
+
var errorCodes48 = [
|
|
145487
145740
|
// Variable declarations
|
|
145488
145741
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
145489
145742
|
// Variable uses
|
|
@@ -145517,13 +145770,13 @@ var errorCodes47 = [
|
|
|
145517
145770
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
145518
145771
|
];
|
|
145519
145772
|
registerCodeFix({
|
|
145520
|
-
errorCodes:
|
|
145773
|
+
errorCodes: errorCodes48,
|
|
145521
145774
|
getCodeActions(context) {
|
|
145522
145775
|
const { sourceFile, program, span: { start: start2 }, errorCode, cancellationToken, host, preferences } = context;
|
|
145523
145776
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145524
145777
|
let declaration;
|
|
145525
145778
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
145526
|
-
declaration =
|
|
145779
|
+
declaration = doChange25(
|
|
145527
145780
|
changes2,
|
|
145528
145781
|
sourceFile,
|
|
145529
145782
|
token,
|
|
@@ -145537,14 +145790,14 @@ registerCodeFix({
|
|
|
145537
145790
|
);
|
|
145538
145791
|
});
|
|
145539
145792
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
145540
|
-
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
145793
|
+
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
|
|
145541
145794
|
},
|
|
145542
|
-
fixIds: [
|
|
145795
|
+
fixIds: [fixId38],
|
|
145543
145796
|
getAllCodeActions(context) {
|
|
145544
145797
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
145545
145798
|
const markSeen = nodeSeenTracker();
|
|
145546
|
-
return codeFixAll(context,
|
|
145547
|
-
|
|
145799
|
+
return codeFixAll(context, errorCodes48, (changes, err) => {
|
|
145800
|
+
doChange25(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
145548
145801
|
});
|
|
145549
145802
|
}
|
|
145550
145803
|
});
|
|
@@ -145583,7 +145836,7 @@ function mapSuggestionDiagnostic(errorCode) {
|
|
|
145583
145836
|
}
|
|
145584
145837
|
return errorCode;
|
|
145585
145838
|
}
|
|
145586
|
-
function
|
|
145839
|
+
function doChange25(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
145587
145840
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) {
|
|
145588
145841
|
return void 0;
|
|
145589
145842
|
}
|
|
@@ -146479,13 +146732,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
146479
146732
|
}
|
|
146480
146733
|
|
|
146481
146734
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
146482
|
-
var
|
|
146483
|
-
var
|
|
146735
|
+
var fixId39 = "fixReturnTypeInAsyncFunction";
|
|
146736
|
+
var errorCodes49 = [
|
|
146484
146737
|
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
|
|
146485
146738
|
];
|
|
146486
146739
|
registerCodeFix({
|
|
146487
|
-
errorCodes:
|
|
146488
|
-
fixIds: [
|
|
146740
|
+
errorCodes: errorCodes49,
|
|
146741
|
+
fixIds: [fixId39],
|
|
146489
146742
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
146490
146743
|
const { sourceFile, program, span } = context;
|
|
146491
146744
|
const checker = program.getTypeChecker();
|
|
@@ -146494,23 +146747,23 @@ registerCodeFix({
|
|
|
146494
146747
|
return void 0;
|
|
146495
146748
|
}
|
|
146496
146749
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
146497
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146750
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
146498
146751
|
return [createCodeFixAction(
|
|
146499
|
-
|
|
146752
|
+
fixId39,
|
|
146500
146753
|
changes,
|
|
146501
146754
|
[
|
|
146502
146755
|
Diagnostics.Replace_0_with_Promise_1,
|
|
146503
146756
|
checker.typeToString(returnType),
|
|
146504
146757
|
checker.typeToString(promisedType)
|
|
146505
146758
|
],
|
|
146506
|
-
|
|
146759
|
+
fixId39,
|
|
146507
146760
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
146508
146761
|
)];
|
|
146509
146762
|
},
|
|
146510
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
146763
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
146511
146764
|
const info = getInfo12(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
146512
146765
|
if (info) {
|
|
146513
|
-
|
|
146766
|
+
doChange26(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
146514
146767
|
}
|
|
146515
146768
|
})
|
|
146516
146769
|
});
|
|
@@ -146537,19 +146790,19 @@ function getInfo12(sourceFile, checker, pos) {
|
|
|
146537
146790
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
146538
146791
|
}
|
|
146539
146792
|
}
|
|
146540
|
-
function
|
|
146793
|
+
function doChange26(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
146541
146794
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
146542
146795
|
}
|
|
146543
146796
|
|
|
146544
146797
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
146545
146798
|
var fixName4 = "disableJsDiagnostics";
|
|
146546
|
-
var
|
|
146547
|
-
var
|
|
146799
|
+
var fixId40 = "disableJsDiagnostics";
|
|
146800
|
+
var errorCodes50 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
146548
146801
|
const diag2 = Diagnostics[key];
|
|
146549
146802
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
146550
146803
|
});
|
|
146551
146804
|
registerCodeFix({
|
|
146552
|
-
errorCodes:
|
|
146805
|
+
errorCodes: errorCodes50,
|
|
146553
146806
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
146554
146807
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
146555
146808
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -146567,14 +146820,14 @@ registerCodeFix({
|
|
|
146567
146820
|
)
|
|
146568
146821
|
];
|
|
146569
146822
|
if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
|
|
146570
|
-
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message,
|
|
146823
|
+
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));
|
|
146571
146824
|
}
|
|
146572
146825
|
return fixes;
|
|
146573
146826
|
},
|
|
146574
|
-
fixIds: [
|
|
146827
|
+
fixIds: [fixId40],
|
|
146575
146828
|
getAllCodeActions: (context) => {
|
|
146576
146829
|
const seenLines = /* @__PURE__ */ new Set();
|
|
146577
|
-
return codeFixAll(context,
|
|
146830
|
+
return codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
146578
146831
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
146579
146832
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
146580
146833
|
}
|
|
@@ -147554,9 +147807,9 @@ var fixName6 = "strictClassInitialization";
|
|
|
147554
147807
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
147555
147808
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
147556
147809
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
147557
|
-
var
|
|
147810
|
+
var errorCodes51 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
147558
147811
|
registerCodeFix({
|
|
147559
|
-
errorCodes:
|
|
147812
|
+
errorCodes: errorCodes51,
|
|
147560
147813
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
147561
147814
|
const info = getInfo13(context.sourceFile, context.span.start);
|
|
147562
147815
|
if (!info)
|
|
@@ -147569,7 +147822,7 @@ registerCodeFix({
|
|
|
147569
147822
|
},
|
|
147570
147823
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
147571
147824
|
getAllCodeActions: (context) => {
|
|
147572
|
-
return codeFixAll(context,
|
|
147825
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
147573
147826
|
const info = getInfo13(diag2.file, diag2.start);
|
|
147574
147827
|
if (!info)
|
|
147575
147828
|
return;
|
|
@@ -147699,27 +147952,27 @@ function getDefaultValueFromType(checker, type) {
|
|
|
147699
147952
|
}
|
|
147700
147953
|
|
|
147701
147954
|
// src/services/codefixes/requireInTs.ts
|
|
147702
|
-
var
|
|
147703
|
-
var
|
|
147955
|
+
var fixId41 = "requireInTs";
|
|
147956
|
+
var errorCodes52 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
147704
147957
|
registerCodeFix({
|
|
147705
|
-
errorCodes:
|
|
147958
|
+
errorCodes: errorCodes52,
|
|
147706
147959
|
getCodeActions(context) {
|
|
147707
147960
|
const info = getInfo14(context.sourceFile, context.program, context.span.start);
|
|
147708
147961
|
if (!info) {
|
|
147709
147962
|
return void 0;
|
|
147710
147963
|
}
|
|
147711
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147712
|
-
return [createCodeFixAction(
|
|
147964
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, info));
|
|
147965
|
+
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
147713
147966
|
},
|
|
147714
|
-
fixIds: [
|
|
147715
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147967
|
+
fixIds: [fixId41],
|
|
147968
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
147716
147969
|
const info = getInfo14(diag2.file, context.program, diag2.start);
|
|
147717
147970
|
if (info) {
|
|
147718
|
-
|
|
147971
|
+
doChange27(changes, context.sourceFile, info);
|
|
147719
147972
|
}
|
|
147720
147973
|
})
|
|
147721
147974
|
});
|
|
147722
|
-
function
|
|
147975
|
+
function doChange27(changes, sourceFile, info) {
|
|
147723
147976
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
147724
147977
|
changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults ? factory.createImportEqualsDeclaration(
|
|
147725
147978
|
/*modifiers*/
|
|
@@ -147783,23 +148036,23 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
147783
148036
|
}
|
|
147784
148037
|
|
|
147785
148038
|
// src/services/codefixes/useDefaultImport.ts
|
|
147786
|
-
var
|
|
147787
|
-
var
|
|
148039
|
+
var fixId42 = "useDefaultImport";
|
|
148040
|
+
var errorCodes53 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
147788
148041
|
registerCodeFix({
|
|
147789
|
-
errorCodes:
|
|
148042
|
+
errorCodes: errorCodes53,
|
|
147790
148043
|
getCodeActions(context) {
|
|
147791
148044
|
const { sourceFile, span: { start: start2 } } = context;
|
|
147792
148045
|
const info = getInfo15(sourceFile, start2);
|
|
147793
148046
|
if (!info)
|
|
147794
148047
|
return void 0;
|
|
147795
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147796
|
-
return [createCodeFixAction(
|
|
148048
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, sourceFile, info, context.preferences));
|
|
148049
|
+
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
147797
148050
|
},
|
|
147798
|
-
fixIds: [
|
|
147799
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148051
|
+
fixIds: [fixId42],
|
|
148052
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
147800
148053
|
const info = getInfo15(diag2.file, diag2.start);
|
|
147801
148054
|
if (info)
|
|
147802
|
-
|
|
148055
|
+
doChange28(changes, diag2.file, info, context.preferences);
|
|
147803
148056
|
})
|
|
147804
148057
|
});
|
|
147805
148058
|
function getInfo15(sourceFile, pos) {
|
|
@@ -147814,7 +148067,7 @@ function getInfo15(sourceFile, pos) {
|
|
|
147814
148067
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
147815
148068
|
}
|
|
147816
148069
|
}
|
|
147817
|
-
function
|
|
148070
|
+
function doChange28(changes, sourceFile, info, preferences) {
|
|
147818
148071
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
147819
148072
|
info.name,
|
|
147820
148073
|
/*namedImports*/
|
|
@@ -147825,21 +148078,21 @@ function doChange26(changes, sourceFile, info, preferences) {
|
|
|
147825
148078
|
}
|
|
147826
148079
|
|
|
147827
148080
|
// src/services/codefixes/useBigintLiteral.ts
|
|
147828
|
-
var
|
|
147829
|
-
var
|
|
148081
|
+
var fixId43 = "useBigintLiteral";
|
|
148082
|
+
var errorCodes54 = [
|
|
147830
148083
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
147831
148084
|
];
|
|
147832
148085
|
registerCodeFix({
|
|
147833
|
-
errorCodes:
|
|
148086
|
+
errorCodes: errorCodes54,
|
|
147834
148087
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
147835
148088
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
147836
148089
|
if (changes.length > 0) {
|
|
147837
|
-
return [createCodeFixAction(
|
|
148090
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
147838
148091
|
}
|
|
147839
148092
|
},
|
|
147840
|
-
fixIds: [
|
|
148093
|
+
fixIds: [fixId43],
|
|
147841
148094
|
getAllCodeActions: (context) => {
|
|
147842
|
-
return codeFixAll(context,
|
|
148095
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
147843
148096
|
}
|
|
147844
148097
|
});
|
|
147845
148098
|
function makeChange9(changeTracker, sourceFile, span) {
|
|
@@ -147853,18 +148106,18 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
147853
148106
|
|
|
147854
148107
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
147855
148108
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
147856
|
-
var
|
|
147857
|
-
var
|
|
148109
|
+
var fixId44 = fixIdAddMissingTypeof;
|
|
148110
|
+
var errorCodes55 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
|
147858
148111
|
registerCodeFix({
|
|
147859
|
-
errorCodes:
|
|
148112
|
+
errorCodes: errorCodes55,
|
|
147860
148113
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
147861
148114
|
const { sourceFile, span } = context;
|
|
147862
148115
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
147863
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147864
|
-
return [createCodeFixAction(
|
|
148116
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, importType));
|
|
148117
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
147865
148118
|
},
|
|
147866
|
-
fixIds: [
|
|
147867
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148119
|
+
fixIds: [fixId44],
|
|
148120
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => doChange29(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
147868
148121
|
});
|
|
147869
148122
|
function getImportTypeNode(sourceFile, pos) {
|
|
147870
148123
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -147872,7 +148125,7 @@ function getImportTypeNode(sourceFile, pos) {
|
|
|
147872
148125
|
Debug.assert(token.parent.kind === 202 /* ImportType */, "Token parent should be an ImportType");
|
|
147873
148126
|
return token.parent;
|
|
147874
148127
|
}
|
|
147875
|
-
function
|
|
148128
|
+
function doChange29(changes, sourceFile, importType) {
|
|
147876
148129
|
const newTypeNode = factory.updateImportTypeNode(
|
|
147877
148130
|
importType,
|
|
147878
148131
|
importType.argument,
|
|
@@ -147887,23 +148140,23 @@ function doChange27(changes, sourceFile, importType) {
|
|
|
147887
148140
|
|
|
147888
148141
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
147889
148142
|
var fixID2 = "wrapJsxInFragment";
|
|
147890
|
-
var
|
|
148143
|
+
var errorCodes56 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
147891
148144
|
registerCodeFix({
|
|
147892
|
-
errorCodes:
|
|
148145
|
+
errorCodes: errorCodes56,
|
|
147893
148146
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
147894
148147
|
const { sourceFile, span } = context;
|
|
147895
148148
|
const node = findNodeToFix(sourceFile, span.start);
|
|
147896
148149
|
if (!node)
|
|
147897
148150
|
return void 0;
|
|
147898
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148151
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, sourceFile, node));
|
|
147899
148152
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
147900
148153
|
},
|
|
147901
148154
|
fixIds: [fixID2],
|
|
147902
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148155
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
147903
148156
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
147904
148157
|
if (!node)
|
|
147905
148158
|
return void 0;
|
|
147906
|
-
|
|
148159
|
+
doChange30(changes, context.sourceFile, node);
|
|
147907
148160
|
})
|
|
147908
148161
|
});
|
|
147909
148162
|
function findNodeToFix(sourceFile, pos) {
|
|
@@ -147919,7 +148172,7 @@ function findNodeToFix(sourceFile, pos) {
|
|
|
147919
148172
|
return void 0;
|
|
147920
148173
|
return binaryExpr;
|
|
147921
148174
|
}
|
|
147922
|
-
function
|
|
148175
|
+
function doChange30(changeTracker, sf, node) {
|
|
147923
148176
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
147924
148177
|
if (jsx)
|
|
147925
148178
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -147944,24 +148197,24 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
147944
148197
|
}
|
|
147945
148198
|
|
|
147946
148199
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
147947
|
-
var
|
|
147948
|
-
var
|
|
148200
|
+
var fixId45 = "fixConvertToMappedObjectType";
|
|
148201
|
+
var errorCodes57 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
147949
148202
|
registerCodeFix({
|
|
147950
|
-
errorCodes:
|
|
148203
|
+
errorCodes: errorCodes57,
|
|
147951
148204
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
147952
148205
|
const { sourceFile, span } = context;
|
|
147953
148206
|
const info = getInfo16(sourceFile, span.start);
|
|
147954
148207
|
if (!info)
|
|
147955
148208
|
return void 0;
|
|
147956
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148209
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, info));
|
|
147957
148210
|
const name = idText(info.container.name);
|
|
147958
|
-
return [createCodeFixAction(
|
|
148211
|
+
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
147959
148212
|
},
|
|
147960
|
-
fixIds: [
|
|
147961
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148213
|
+
fixIds: [fixId45],
|
|
148214
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
147962
148215
|
const info = getInfo16(diag2.file, diag2.start);
|
|
147963
148216
|
if (info)
|
|
147964
|
-
|
|
148217
|
+
doChange31(changes, diag2.file, info);
|
|
147965
148218
|
})
|
|
147966
148219
|
});
|
|
147967
148220
|
function getInfo16(sourceFile, pos) {
|
|
@@ -147977,7 +148230,7 @@ function getInfo16(sourceFile, pos) {
|
|
|
147977
148230
|
function createTypeAliasFromInterface(declaration, type) {
|
|
147978
148231
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
147979
148232
|
}
|
|
147980
|
-
function
|
|
148233
|
+
function doChange31(changes, sourceFile, { indexSignature, container }) {
|
|
147981
148234
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
147982
148235
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
147983
148236
|
const parameter = first(indexSignature.parameters);
|
|
@@ -148006,12 +148259,12 @@ function doChange29(changes, sourceFile, { indexSignature, container }) {
|
|
|
148006
148259
|
}
|
|
148007
148260
|
|
|
148008
148261
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
148009
|
-
var
|
|
148010
|
-
var
|
|
148262
|
+
var fixId46 = "removeAccidentalCallParentheses";
|
|
148263
|
+
var errorCodes58 = [
|
|
148011
148264
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
148012
148265
|
];
|
|
148013
148266
|
registerCodeFix({
|
|
148014
|
-
errorCodes:
|
|
148267
|
+
errorCodes: errorCodes58,
|
|
148015
148268
|
getCodeActions(context) {
|
|
148016
148269
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
148017
148270
|
if (!callExpression) {
|
|
@@ -148020,27 +148273,27 @@ registerCodeFix({
|
|
|
148020
148273
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
148021
148274
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
148022
148275
|
});
|
|
148023
|
-
return [createCodeFixActionWithoutFixAll(
|
|
148276
|
+
return [createCodeFixActionWithoutFixAll(fixId46, changes, Diagnostics.Remove_parentheses)];
|
|
148024
148277
|
},
|
|
148025
|
-
fixIds: [
|
|
148278
|
+
fixIds: [fixId46]
|
|
148026
148279
|
});
|
|
148027
148280
|
|
|
148028
148281
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
148029
|
-
var
|
|
148030
|
-
var
|
|
148282
|
+
var fixId47 = "removeUnnecessaryAwait";
|
|
148283
|
+
var errorCodes59 = [
|
|
148031
148284
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
148032
148285
|
];
|
|
148033
148286
|
registerCodeFix({
|
|
148034
|
-
errorCodes:
|
|
148287
|
+
errorCodes: errorCodes59,
|
|
148035
148288
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
148036
148289
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
148037
148290
|
if (changes.length > 0) {
|
|
148038
|
-
return [createCodeFixAction(
|
|
148291
|
+
return [createCodeFixAction(fixId47, changes, Diagnostics.Remove_unnecessary_await, fixId47, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
148039
148292
|
}
|
|
148040
148293
|
},
|
|
148041
|
-
fixIds: [
|
|
148294
|
+
fixIds: [fixId47],
|
|
148042
148295
|
getAllCodeActions: (context) => {
|
|
148043
|
-
return codeFixAll(context,
|
|
148296
|
+
return codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
148044
148297
|
}
|
|
148045
148298
|
});
|
|
148046
148299
|
function makeChange10(changeTracker, sourceFile, span) {
|
|
@@ -148068,20 +148321,20 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
148068
148321
|
}
|
|
148069
148322
|
|
|
148070
148323
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
148071
|
-
var
|
|
148072
|
-
var
|
|
148324
|
+
var errorCodes60 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
148325
|
+
var fixId48 = "splitTypeOnlyImport";
|
|
148073
148326
|
registerCodeFix({
|
|
148074
|
-
errorCodes:
|
|
148075
|
-
fixIds: [
|
|
148327
|
+
errorCodes: errorCodes60,
|
|
148328
|
+
fixIds: [fixId48],
|
|
148076
148329
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
148077
148330
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
148078
148331
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
148079
148332
|
});
|
|
148080
148333
|
if (changes.length) {
|
|
148081
|
-
return [createCodeFixAction(
|
|
148334
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
148082
148335
|
}
|
|
148083
148336
|
},
|
|
148084
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148337
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, error) => {
|
|
148085
148338
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error), context);
|
|
148086
148339
|
})
|
|
148087
148340
|
});
|
|
@@ -148122,34 +148375,34 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
148122
148375
|
}
|
|
148123
148376
|
|
|
148124
148377
|
// src/services/codefixes/convertConstToLet.ts
|
|
148125
|
-
var
|
|
148126
|
-
var
|
|
148378
|
+
var fixId49 = "fixConvertConstToLet";
|
|
148379
|
+
var errorCodes61 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
148127
148380
|
registerCodeFix({
|
|
148128
|
-
errorCodes:
|
|
148381
|
+
errorCodes: errorCodes61,
|
|
148129
148382
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
148130
148383
|
const { sourceFile, span, program } = context;
|
|
148131
148384
|
const info = getInfo17(sourceFile, span.start, program);
|
|
148132
148385
|
if (info === void 0)
|
|
148133
148386
|
return;
|
|
148134
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148135
|
-
return [createCodeFixActionMaybeFixAll(
|
|
148387
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange32(t, sourceFile, info.token));
|
|
148388
|
+
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
148136
148389
|
},
|
|
148137
148390
|
getAllCodeActions: (context) => {
|
|
148138
148391
|
const { program } = context;
|
|
148139
148392
|
const seen = /* @__PURE__ */ new Map();
|
|
148140
148393
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
148141
|
-
eachDiagnostic(context,
|
|
148394
|
+
eachDiagnostic(context, errorCodes61, (diag2) => {
|
|
148142
148395
|
const info = getInfo17(diag2.file, diag2.start, program);
|
|
148143
148396
|
if (info) {
|
|
148144
148397
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
148145
|
-
return
|
|
148398
|
+
return doChange32(changes, diag2.file, info.token);
|
|
148146
148399
|
}
|
|
148147
148400
|
}
|
|
148148
148401
|
return void 0;
|
|
148149
148402
|
});
|
|
148150
148403
|
}));
|
|
148151
148404
|
},
|
|
148152
|
-
fixIds: [
|
|
148405
|
+
fixIds: [fixId49]
|
|
148153
148406
|
});
|
|
148154
148407
|
function getInfo17(sourceFile, pos, program) {
|
|
148155
148408
|
var _a2;
|
|
@@ -148165,64 +148418,64 @@ function getInfo17(sourceFile, pos, program) {
|
|
|
148165
148418
|
return;
|
|
148166
148419
|
return { symbol, token: constToken };
|
|
148167
148420
|
}
|
|
148168
|
-
function
|
|
148421
|
+
function doChange32(changes, sourceFile, token) {
|
|
148169
148422
|
changes.replaceNode(sourceFile, token, factory.createToken(119 /* LetKeyword */));
|
|
148170
148423
|
}
|
|
148171
148424
|
|
|
148172
148425
|
// src/services/codefixes/fixExpectedComma.ts
|
|
148173
|
-
var
|
|
148426
|
+
var fixId50 = "fixExpectedComma";
|
|
148174
148427
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
148175
|
-
var
|
|
148428
|
+
var errorCodes62 = [expectedErrorCode];
|
|
148176
148429
|
registerCodeFix({
|
|
148177
|
-
errorCodes:
|
|
148430
|
+
errorCodes: errorCodes62,
|
|
148178
148431
|
getCodeActions(context) {
|
|
148179
148432
|
const { sourceFile } = context;
|
|
148180
148433
|
const info = getInfo18(sourceFile, context.span.start, context.errorCode);
|
|
148181
148434
|
if (!info)
|
|
148182
148435
|
return void 0;
|
|
148183
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148436
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange33(t, sourceFile, info));
|
|
148184
148437
|
return [createCodeFixAction(
|
|
148185
|
-
|
|
148438
|
+
fixId50,
|
|
148186
148439
|
changes,
|
|
148187
148440
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
148188
|
-
|
|
148441
|
+
fixId50,
|
|
148189
148442
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
148190
148443
|
)];
|
|
148191
148444
|
},
|
|
148192
|
-
fixIds: [
|
|
148193
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148445
|
+
fixIds: [fixId50],
|
|
148446
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, diag2) => {
|
|
148194
148447
|
const info = getInfo18(diag2.file, diag2.start, diag2.code);
|
|
148195
148448
|
if (info)
|
|
148196
|
-
|
|
148449
|
+
doChange33(changes, context.sourceFile, info);
|
|
148197
148450
|
})
|
|
148198
148451
|
});
|
|
148199
148452
|
function getInfo18(sourceFile, pos, _) {
|
|
148200
148453
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
148201
148454
|
return node.kind === 26 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
148202
148455
|
}
|
|
148203
|
-
function
|
|
148456
|
+
function doChange33(changes, sourceFile, { node }) {
|
|
148204
148457
|
const newNode = factory.createToken(27 /* CommaToken */);
|
|
148205
148458
|
changes.replaceNode(sourceFile, node, newNode);
|
|
148206
148459
|
}
|
|
148207
148460
|
|
|
148208
148461
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
148209
148462
|
var fixName7 = "addVoidToPromise";
|
|
148210
|
-
var
|
|
148211
|
-
var
|
|
148463
|
+
var fixId51 = "addVoidToPromise";
|
|
148464
|
+
var errorCodes63 = [
|
|
148212
148465
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
148213
148466
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
148214
148467
|
];
|
|
148215
148468
|
registerCodeFix({
|
|
148216
|
-
errorCodes:
|
|
148217
|
-
fixIds: [
|
|
148469
|
+
errorCodes: errorCodes63,
|
|
148470
|
+
fixIds: [fixId51],
|
|
148218
148471
|
getCodeActions(context) {
|
|
148219
148472
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
148220
148473
|
if (changes.length > 0) {
|
|
148221
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
148474
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId51, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
148222
148475
|
}
|
|
148223
148476
|
},
|
|
148224
148477
|
getAllCodeActions(context) {
|
|
148225
|
-
return codeFixAll(context,
|
|
148478
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
148226
148479
|
}
|
|
148227
148480
|
});
|
|
148228
148481
|
function makeChange11(changes, sourceFile, span, program, seen) {
|
|
@@ -157257,7 +157510,7 @@ registerRefactor(refactorName, {
|
|
|
157257
157510
|
Debug.assert(actionName2 === defaultToNamedAction.name || actionName2 === namedToDefaultAction.name, "Unexpected action name");
|
|
157258
157511
|
const info = getInfo19(context);
|
|
157259
157512
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
157260
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157513
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(context.file, context.program, info, t, context.cancellationToken));
|
|
157261
157514
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
157262
157515
|
}
|
|
157263
157516
|
});
|
|
@@ -157310,7 +157563,7 @@ function getInfo19(context, considerPartialSpans = true) {
|
|
|
157310
157563
|
return void 0;
|
|
157311
157564
|
}
|
|
157312
157565
|
}
|
|
157313
|
-
function
|
|
157566
|
+
function doChange34(exportingSourceFile, program, info, changes, cancellationToken) {
|
|
157314
157567
|
changeExport(exportingSourceFile, info, changes, program.getTypeChecker());
|
|
157315
157568
|
changeImports(program, info, changes, cancellationToken);
|
|
157316
157569
|
}
|
|
@@ -157505,7 +157758,7 @@ registerRefactor(refactorName2, {
|
|
|
157505
157758
|
Debug.assert(some(getOwnValues(actions), (action) => action.name === actionName2), "Unexpected action name");
|
|
157506
157759
|
const info = getImportConversionInfo(context);
|
|
157507
157760
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
157508
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157761
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(context.file, context.program, t, info));
|
|
157509
157762
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
157510
157763
|
}
|
|
157511
157764
|
});
|
|
@@ -157536,7 +157789,7 @@ function getImportConversionInfo(context, considerPartialSpans = true) {
|
|
|
157536
157789
|
function getShouldUseDefault(program, importClause) {
|
|
157537
157790
|
return getAllowSyntheticDefaultImports(program.getCompilerOptions()) && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157538
157791
|
}
|
|
157539
|
-
function
|
|
157792
|
+
function doChange35(sourceFile, program, changes, info) {
|
|
157540
157793
|
const checker = program.getTypeChecker();
|
|
157541
157794
|
if (info.convertTo === 0 /* Named */) {
|
|
157542
157795
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
@@ -158009,7 +158262,7 @@ registerRefactor(refactorName4, {
|
|
|
158009
158262
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
158010
158263
|
Debug.assert(actionName2 === refactorName4, "Wrong refactor invoked");
|
|
158011
158264
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
158012
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158265
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(context.file, context.program, statements, t, context.host, context.preferences));
|
|
158013
158266
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
158014
158267
|
}
|
|
158015
158268
|
});
|
|
@@ -158034,7 +158287,7 @@ function getRangeToMove(context) {
|
|
|
158034
158287
|
afterLast: afterEndNodeIndex === -1 ? void 0 : statements[afterEndNodeIndex]
|
|
158035
158288
|
};
|
|
158036
158289
|
}
|
|
158037
|
-
function
|
|
158290
|
+
function doChange36(oldFile, program, toMove, changes, host, preferences) {
|
|
158038
158291
|
const checker = program.getTypeChecker();
|
|
158039
158292
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
158040
158293
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
@@ -159406,12 +159659,12 @@ function getRefactorEditsToConvertParametersToDestructuredObject(context, action
|
|
|
159406
159659
|
return void 0;
|
|
159407
159660
|
const groupedReferences = getGroupedReferences(functionDeclaration, program, cancellationToken);
|
|
159408
159661
|
if (groupedReferences.valid) {
|
|
159409
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
159662
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(file, program, host, t, functionDeclaration, groupedReferences));
|
|
159410
159663
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
159411
159664
|
}
|
|
159412
159665
|
return { edits: [] };
|
|
159413
159666
|
}
|
|
159414
|
-
function
|
|
159667
|
+
function doChange37(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
|
|
159415
159668
|
const signature = groupedReferences.signature;
|
|
159416
159669
|
const newFunctionDeclarationParams = map(createNewParameters(functionDeclaration, program, host), (param) => getSynthesizedDeepClone(param));
|
|
159417
159670
|
if (signature) {
|
|
@@ -160175,7 +160428,7 @@ function getRefactorEditsToConvertToOptionalChain(context, actionName2) {
|
|
|
160175
160428
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
160176
160429
|
const edits = ts_textChanges_exports.ChangeTracker.with(
|
|
160177
160430
|
context,
|
|
160178
|
-
(t) =>
|
|
160431
|
+
(t) => doChange38(context.file, context.program.getTypeChecker(), t, info, actionName2)
|
|
160179
160432
|
);
|
|
160180
160433
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
160181
160434
|
}
|
|
@@ -160331,7 +160584,7 @@ function convertOccurrences(checker, toConvert, occurrences) {
|
|
|
160331
160584
|
}
|
|
160332
160585
|
return toConvert;
|
|
160333
160586
|
}
|
|
160334
|
-
function
|
|
160587
|
+
function doChange38(sourceFile, checker, changes, info, _actionName) {
|
|
160335
160588
|
const { finalExpression, occurrences, expression } = info;
|
|
160336
160589
|
const firstOccurrence = occurrences[occurrences.length - 1];
|
|
160337
160590
|
const convertedChain = convertOccurrences(checker, finalExpression, occurrences);
|
|
@@ -162026,7 +162279,7 @@ registerRefactor(refactorName12, {
|
|
|
162026
162279
|
function getRefactorEditsToInferReturnType(context) {
|
|
162027
162280
|
const info = getInfo21(context);
|
|
162028
162281
|
if (info && !isRefactorErrorInfo(info)) {
|
|
162029
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
162282
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(context.file, t, info.declaration, info.returnTypeNode));
|
|
162030
162283
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
162031
162284
|
}
|
|
162032
162285
|
return void 0;
|
|
@@ -162051,7 +162304,7 @@ function getRefactorActionsToInferReturnType(context) {
|
|
|
162051
162304
|
}
|
|
162052
162305
|
return emptyArray;
|
|
162053
162306
|
}
|
|
162054
|
-
function
|
|
162307
|
+
function doChange39(sourceFile, changes, declaration, typeNode) {
|
|
162055
162308
|
const closeParen = findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile);
|
|
162056
162309
|
const needParens = isArrowFunction(declaration) && closeParen === void 0;
|
|
162057
162310
|
const endNode2 = needParens ? first(declaration.parameters) : closeParen;
|
|
@@ -169514,7 +169767,6 @@ __export(ts_exports3, {
|
|
|
169514
169767
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
169515
169768
|
noop: () => noop,
|
|
169516
169769
|
noopFileWatcher: () => noopFileWatcher,
|
|
169517
|
-
noopPush: () => noopPush,
|
|
169518
169770
|
normalizePath: () => normalizePath,
|
|
169519
169771
|
normalizeSlashes: () => normalizeSlashes,
|
|
169520
169772
|
not: () => not,
|
|
@@ -170391,7 +170643,6 @@ var CommandTypes = /* @__PURE__ */ ((CommandTypes2) => {
|
|
|
170391
170643
|
CommandTypes2["NavtoFull"] = "navto-full";
|
|
170392
170644
|
CommandTypes2["NavTree"] = "navtree";
|
|
170393
170645
|
CommandTypes2["NavTreeFull"] = "navtree-full";
|
|
170394
|
-
CommandTypes2["Occurrences"] = "occurrences";
|
|
170395
170646
|
CommandTypes2["DocumentHighlights"] = "documentHighlights";
|
|
170396
170647
|
CommandTypes2["DocumentHighlightsFull"] = "documentHighlights-full";
|
|
170397
170648
|
CommandTypes2["Open"] = "open";
|
|
@@ -170596,17 +170847,14 @@ var TextStorage = class {
|
|
|
170596
170847
|
* True when reloading contents of file from the disk is pending
|
|
170597
170848
|
*/
|
|
170598
170849
|
this.pendingReloadFromDisk = false;
|
|
170599
|
-
this.version = initialVersion ||
|
|
170850
|
+
this.version = initialVersion || 0;
|
|
170600
170851
|
}
|
|
170601
170852
|
getVersion() {
|
|
170602
|
-
return this.svc ? `SVC-${this.version
|
|
170853
|
+
return this.svc ? `SVC-${this.version}-${this.svc.getSnapshotVersion()}` : `Text-${this.version}`;
|
|
170603
170854
|
}
|
|
170604
170855
|
hasScriptVersionCache_TestOnly() {
|
|
170605
170856
|
return this.svc !== void 0;
|
|
170606
170857
|
}
|
|
170607
|
-
useScriptVersionCache_TestOnly() {
|
|
170608
|
-
this.switchToScriptVersionCache();
|
|
170609
|
-
}
|
|
170610
170858
|
resetSourceMapInfo() {
|
|
170611
170859
|
this.info.sourceFileLike = void 0;
|
|
170612
170860
|
this.info.closeSourceMapFileWatcher();
|
|
@@ -170619,15 +170867,17 @@ var TextStorage = class {
|
|
|
170619
170867
|
useText(newText) {
|
|
170620
170868
|
this.svc = void 0;
|
|
170621
170869
|
this.text = newText;
|
|
170870
|
+
this.textSnapshot = void 0;
|
|
170622
170871
|
this.lineMap = void 0;
|
|
170623
170872
|
this.fileSize = void 0;
|
|
170624
170873
|
this.resetSourceMapInfo();
|
|
170625
|
-
this.version
|
|
170874
|
+
this.version++;
|
|
170626
170875
|
}
|
|
170627
170876
|
edit(start2, end, newText) {
|
|
170628
170877
|
this.switchToScriptVersionCache().edit(start2, end - start2, newText);
|
|
170629
170878
|
this.ownFileText = false;
|
|
170630
170879
|
this.text = void 0;
|
|
170880
|
+
this.textSnapshot = void 0;
|
|
170631
170881
|
this.lineMap = void 0;
|
|
170632
170882
|
this.fileSize = void 0;
|
|
170633
170883
|
this.resetSourceMapInfo();
|
|
@@ -170639,6 +170889,9 @@ var TextStorage = class {
|
|
|
170639
170889
|
reload(newText) {
|
|
170640
170890
|
Debug.assert(newText !== void 0);
|
|
170641
170891
|
this.pendingReloadFromDisk = false;
|
|
170892
|
+
if (!this.text && this.svc) {
|
|
170893
|
+
this.text = getSnapshotText(this.svc.getSnapshot());
|
|
170894
|
+
}
|
|
170642
170895
|
if (this.text !== newText) {
|
|
170643
170896
|
this.useText(newText);
|
|
170644
170897
|
this.ownFileText = false;
|
|
@@ -170651,21 +170904,18 @@ var TextStorage = class {
|
|
|
170651
170904
|
* returns true if text changed
|
|
170652
170905
|
*/
|
|
170653
170906
|
reloadWithFileText(tempFileName) {
|
|
170654
|
-
const { text: newText, fileSize } = this.getFileTextAndSize(tempFileName);
|
|
170907
|
+
const { text: newText, fileSize } = tempFileName || !this.info.isDynamicOrHasMixedContent() ? this.getFileTextAndSize(tempFileName) : { text: "", fileSize: void 0 };
|
|
170655
170908
|
const reloaded = this.reload(newText);
|
|
170656
170909
|
this.fileSize = fileSize;
|
|
170657
170910
|
this.ownFileText = !tempFileName || tempFileName === this.info.fileName;
|
|
170658
170911
|
return reloaded;
|
|
170659
170912
|
}
|
|
170660
170913
|
/**
|
|
170661
|
-
*
|
|
170662
|
-
* returns true
|
|
170914
|
+
* Schedule reload from the disk if its not already scheduled and its not own text
|
|
170915
|
+
* returns true when scheduling reload
|
|
170663
170916
|
*/
|
|
170664
|
-
|
|
170665
|
-
|
|
170666
|
-
return this.reloadWithFileText();
|
|
170667
|
-
}
|
|
170668
|
-
return false;
|
|
170917
|
+
scheduleReloadIfNeeded() {
|
|
170918
|
+
return !this.pendingReloadFromDisk && !this.ownFileText ? this.pendingReloadFromDisk = true : false;
|
|
170669
170919
|
}
|
|
170670
170920
|
delayReloadFromFileIntoText() {
|
|
170671
170921
|
this.pendingReloadFromDisk = true;
|
|
@@ -170681,39 +170931,48 @@ var TextStorage = class {
|
|
|
170681
170931
|
return !!this.fileSize ? this.fileSize : !!this.text ? this.text.length : !!this.svc ? this.svc.getSnapshot().getLength() : this.getSnapshot().getLength();
|
|
170682
170932
|
}
|
|
170683
170933
|
getSnapshot() {
|
|
170684
|
-
|
|
170934
|
+
var _a2, _b;
|
|
170935
|
+
return ((_a2 = this.tryUseScriptVersionCache()) == null ? void 0 : _a2.getSnapshot()) || ((_b = this.textSnapshot) != null ? _b : this.textSnapshot = ScriptSnapshot.fromString(Debug.checkDefined(this.text)));
|
|
170685
170936
|
}
|
|
170686
|
-
getAbsolutePositionAndLineText(
|
|
170687
|
-
|
|
170937
|
+
getAbsolutePositionAndLineText(oneBasedLine) {
|
|
170938
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170939
|
+
if (svc)
|
|
170940
|
+
return svc.getAbsolutePositionAndLineText(oneBasedLine);
|
|
170941
|
+
const lineMap = this.getLineMap();
|
|
170942
|
+
return oneBasedLine <= lineMap.length ? {
|
|
170943
|
+
absolutePosition: lineMap[oneBasedLine - 1],
|
|
170944
|
+
lineText: this.text.substring(lineMap[oneBasedLine - 1], lineMap[oneBasedLine])
|
|
170945
|
+
} : {
|
|
170946
|
+
absolutePosition: this.text.length,
|
|
170947
|
+
lineText: void 0
|
|
170948
|
+
};
|
|
170688
170949
|
}
|
|
170689
170950
|
/**
|
|
170690
170951
|
* @param line 0 based index
|
|
170691
170952
|
*/
|
|
170692
170953
|
lineToTextSpan(line) {
|
|
170693
|
-
|
|
170694
|
-
|
|
170695
|
-
|
|
170696
|
-
|
|
170697
|
-
|
|
170698
|
-
|
|
170699
|
-
return
|
|
170954
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170955
|
+
if (svc)
|
|
170956
|
+
return svc.lineToTextSpan(line);
|
|
170957
|
+
const lineMap = this.getLineMap();
|
|
170958
|
+
const start2 = lineMap[line];
|
|
170959
|
+
const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
|
|
170960
|
+
return createTextSpanFromBounds(start2, end);
|
|
170700
170961
|
}
|
|
170701
170962
|
/**
|
|
170702
170963
|
* @param line 1 based index
|
|
170703
170964
|
* @param offset 1 based index
|
|
170704
170965
|
*/
|
|
170705
170966
|
lineOffsetToPosition(line, offset, allowEdits) {
|
|
170706
|
-
|
|
170707
|
-
|
|
170708
|
-
}
|
|
170709
|
-
return this.svc.lineOffsetToPosition(line, offset);
|
|
170967
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170968
|
+
return svc ? svc.lineOffsetToPosition(line, offset) : computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
|
|
170710
170969
|
}
|
|
170711
170970
|
positionToLineOffset(position) {
|
|
170712
|
-
|
|
170713
|
-
|
|
170714
|
-
return
|
|
170715
|
-
}
|
|
170716
|
-
return
|
|
170971
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170972
|
+
if (svc)
|
|
170973
|
+
return svc.positionToLineOffset(position);
|
|
170974
|
+
const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
|
|
170975
|
+
return { line: line + 1, offset: character + 1 };
|
|
170717
170976
|
}
|
|
170718
170977
|
getFileTextAndSize(tempFileName) {
|
|
170719
170978
|
let text;
|
|
@@ -170731,19 +170990,25 @@ var TextStorage = class {
|
|
|
170731
170990
|
}
|
|
170732
170991
|
return { text: getText() };
|
|
170733
170992
|
}
|
|
170993
|
+
/** @internal */
|
|
170734
170994
|
switchToScriptVersionCache() {
|
|
170735
170995
|
if (!this.svc || this.pendingReloadFromDisk) {
|
|
170736
170996
|
this.svc = ScriptVersionCache.fromString(this.getOrLoadText());
|
|
170737
|
-
this.
|
|
170997
|
+
this.textSnapshot = void 0;
|
|
170998
|
+
this.version++;
|
|
170738
170999
|
}
|
|
170739
171000
|
return this.svc;
|
|
170740
171001
|
}
|
|
170741
|
-
|
|
170742
|
-
if (this.
|
|
170743
|
-
|
|
171002
|
+
tryUseScriptVersionCache() {
|
|
171003
|
+
if (!this.svc || this.pendingReloadFromDisk) {
|
|
171004
|
+
this.getOrLoadText();
|
|
170744
171005
|
}
|
|
170745
|
-
if (this.
|
|
170746
|
-
this.
|
|
171006
|
+
if (this.isOpen) {
|
|
171007
|
+
if (!this.svc && !this.textSnapshot) {
|
|
171008
|
+
this.svc = ScriptVersionCache.fromString(Debug.checkDefined(this.text));
|
|
171009
|
+
this.textSnapshot = void 0;
|
|
171010
|
+
}
|
|
171011
|
+
return this.svc;
|
|
170747
171012
|
}
|
|
170748
171013
|
return this.svc;
|
|
170749
171014
|
}
|
|
@@ -170756,13 +171021,14 @@ var TextStorage = class {
|
|
|
170756
171021
|
}
|
|
170757
171022
|
getLineMap() {
|
|
170758
171023
|
Debug.assert(!this.svc, "ScriptVersionCache should not be set");
|
|
170759
|
-
return this.lineMap || (this.lineMap = computeLineStarts(this.
|
|
171024
|
+
return this.lineMap || (this.lineMap = computeLineStarts(Debug.checkDefined(this.text)));
|
|
170760
171025
|
}
|
|
170761
171026
|
getLineInfo() {
|
|
170762
|
-
|
|
171027
|
+
const svc = this.tryUseScriptVersionCache();
|
|
171028
|
+
if (svc) {
|
|
170763
171029
|
return {
|
|
170764
|
-
getLineCount: () =>
|
|
170765
|
-
getLineText: (line) =>
|
|
171030
|
+
getLineCount: () => svc.getLineCount(),
|
|
171031
|
+
getLineText: (line) => svc.getAbsolutePositionAndLineText(line + 1).lineText
|
|
170766
171032
|
};
|
|
170767
171033
|
}
|
|
170768
171034
|
const lineMap = this.getLineMap();
|
|
@@ -170786,20 +171052,11 @@ var ScriptInfo = class {
|
|
|
170786
171052
|
this.isDynamic = isDynamicFileName(fileName);
|
|
170787
171053
|
this.textStorage = new TextStorage(host, this, initialVersion);
|
|
170788
171054
|
if (hasMixedContent || this.isDynamic) {
|
|
170789
|
-
this.textStorage.reload("");
|
|
170790
171055
|
this.realpath = this.path;
|
|
170791
171056
|
}
|
|
170792
171057
|
this.scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
|
|
170793
171058
|
}
|
|
170794
171059
|
/** @internal */
|
|
170795
|
-
getVersion() {
|
|
170796
|
-
return this.textStorage.version;
|
|
170797
|
-
}
|
|
170798
|
-
/** @internal */
|
|
170799
|
-
getTelemetryFileSize() {
|
|
170800
|
-
return this.textStorage.getTelemetryFileSize();
|
|
170801
|
-
}
|
|
170802
|
-
/** @internal */
|
|
170803
171060
|
isDynamicOrHasMixedContent() {
|
|
170804
171061
|
return this.hasMixedContent || this.isDynamic;
|
|
170805
171062
|
}
|
|
@@ -170814,11 +171071,7 @@ var ScriptInfo = class {
|
|
|
170814
171071
|
}
|
|
170815
171072
|
close(fileExists = true) {
|
|
170816
171073
|
this.textStorage.isOpen = false;
|
|
170817
|
-
if (this.
|
|
170818
|
-
if (this.textStorage.reload("")) {
|
|
170819
|
-
this.markContainingProjectsAsDirty();
|
|
170820
|
-
}
|
|
170821
|
-
} else if (this.textStorage.reloadFromDisk()) {
|
|
171074
|
+
if (fileExists && this.textStorage.scheduleReloadIfNeeded()) {
|
|
170822
171075
|
this.markContainingProjectsAsDirty();
|
|
170823
171076
|
}
|
|
170824
171077
|
}
|
|
@@ -170998,22 +171251,12 @@ var ScriptInfo = class {
|
|
|
170998
171251
|
this.markContainingProjectsAsDirty();
|
|
170999
171252
|
}
|
|
171000
171253
|
reloadFromFile(tempFileName) {
|
|
171001
|
-
if (this.
|
|
171002
|
-
this.textStorage.reload("");
|
|
171254
|
+
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
171003
171255
|
this.markContainingProjectsAsDirty();
|
|
171004
171256
|
return true;
|
|
171005
|
-
} else {
|
|
171006
|
-
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
171007
|
-
this.markContainingProjectsAsDirty();
|
|
171008
|
-
return true;
|
|
171009
|
-
}
|
|
171010
171257
|
}
|
|
171011
171258
|
return false;
|
|
171012
171259
|
}
|
|
171013
|
-
/** @internal */
|
|
171014
|
-
getAbsolutePositionAndLineText(line) {
|
|
171015
|
-
return this.textStorage.getAbsolutePositionAndLineText(line);
|
|
171016
|
-
}
|
|
171017
171260
|
editContent(start2, end, newText) {
|
|
171018
171261
|
this.textStorage.edit(start2, end, newText);
|
|
171019
171262
|
this.markContainingProjectsAsDirty();
|
|
@@ -171053,10 +171296,6 @@ var ScriptInfo = class {
|
|
|
171053
171296
|
return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */;
|
|
171054
171297
|
}
|
|
171055
171298
|
/** @internal */
|
|
171056
|
-
getLineInfo() {
|
|
171057
|
-
return this.textStorage.getLineInfo();
|
|
171058
|
-
}
|
|
171059
|
-
/** @internal */
|
|
171060
171299
|
closeSourceMapFileWatcher() {
|
|
171061
171300
|
if (this.sourceMapFilePath && !isString(this.sourceMapFilePath)) {
|
|
171062
171301
|
closeFileWatcherOf(this.sourceMapFilePath);
|
|
@@ -171201,7 +171440,7 @@ function countEachFileTypes(infos, includeSizes = false) {
|
|
|
171201
171440
|
deferredSize: 0
|
|
171202
171441
|
};
|
|
171203
171442
|
for (const info of infos) {
|
|
171204
|
-
const fileSize = includeSizes ? info.getTelemetryFileSize() : 0;
|
|
171443
|
+
const fileSize = includeSizes ? info.textStorage.getTelemetryFileSize() : 0;
|
|
171205
171444
|
switch (info.scriptKind) {
|
|
171206
171445
|
case 1 /* JS */:
|
|
171207
171446
|
result.js += 1;
|
|
@@ -172185,10 +172424,26 @@ var Project3 = class {
|
|
|
172185
172424
|
const elapsed = timestamp() - start2;
|
|
172186
172425
|
this.sendPerformanceEvent("UpdateGraph", elapsed);
|
|
172187
172426
|
this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram}${this.program ? ` structureIsReused:: ${StructureIsReused[this.program.structureIsReused]}` : ""} Elapsed: ${elapsed}ms`);
|
|
172188
|
-
if (this.
|
|
172427
|
+
if (this.projectService.logger.isTestLogger) {
|
|
172428
|
+
if (this.program !== oldProgram) {
|
|
172429
|
+
this.print(
|
|
172430
|
+
/*writeProjectFileNames*/
|
|
172431
|
+
true,
|
|
172432
|
+
this.hasAddedorRemovedFiles,
|
|
172433
|
+
/*writeFileVersionAndText*/
|
|
172434
|
+
true
|
|
172435
|
+
);
|
|
172436
|
+
} else {
|
|
172437
|
+
this.writeLog(`Same program as before`);
|
|
172438
|
+
}
|
|
172439
|
+
} else if (this.hasAddedorRemovedFiles) {
|
|
172189
172440
|
this.print(
|
|
172190
172441
|
/*writeProjectFileNames*/
|
|
172191
|
-
true
|
|
172442
|
+
true,
|
|
172443
|
+
/*writeFileExplaination*/
|
|
172444
|
+
true,
|
|
172445
|
+
/*writeFileVersionAndText*/
|
|
172446
|
+
false
|
|
172192
172447
|
);
|
|
172193
172448
|
} else if (this.program !== oldProgram) {
|
|
172194
172449
|
this.writeLog(`Different program with same set of files`);
|
|
@@ -172298,6 +172553,16 @@ var Project3 = class {
|
|
|
172298
172553
|
return this.projectService.getScriptInfo(uncheckedFileName);
|
|
172299
172554
|
}
|
|
172300
172555
|
filesToString(writeProjectFileNames) {
|
|
172556
|
+
return this.filesToStringWorker(
|
|
172557
|
+
writeProjectFileNames,
|
|
172558
|
+
/*writeFileExplaination*/
|
|
172559
|
+
true,
|
|
172560
|
+
/*writeFileVersionAndText*/
|
|
172561
|
+
false
|
|
172562
|
+
);
|
|
172563
|
+
}
|
|
172564
|
+
/** @internal */
|
|
172565
|
+
filesToStringWorker(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
172301
172566
|
if (this.isInitialLoadPending())
|
|
172302
172567
|
return " Files (0) InitialLoadPending\n";
|
|
172303
172568
|
if (!this.program)
|
|
@@ -172307,23 +172572,33 @@ var Project3 = class {
|
|
|
172307
172572
|
`;
|
|
172308
172573
|
if (writeProjectFileNames) {
|
|
172309
172574
|
for (const file of sourceFiles) {
|
|
172310
|
-
strBuilder += ` ${file.fileName}
|
|
172575
|
+
strBuilder += ` ${file.fileName}${writeFileVersionAndText ? ` ${file.version} ${JSON.stringify(file.text)}` : ""}
|
|
172311
172576
|
`;
|
|
172312
172577
|
}
|
|
172313
|
-
|
|
172314
|
-
|
|
172578
|
+
if (writeFileExplaination) {
|
|
172579
|
+
strBuilder += "\n\n";
|
|
172580
|
+
explainFiles(this.program, (s) => strBuilder += ` ${s}
|
|
172315
172581
|
`);
|
|
172582
|
+
}
|
|
172316
172583
|
}
|
|
172317
172584
|
return strBuilder;
|
|
172318
172585
|
}
|
|
172319
172586
|
/** @internal */
|
|
172320
|
-
print(writeProjectFileNames) {
|
|
172587
|
+
print(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
172321
172588
|
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
|
|
172322
|
-
this.writeLog(this.
|
|
172589
|
+
this.writeLog(this.filesToStringWorker(
|
|
172590
|
+
writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
172591
|
+
writeFileExplaination && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
172592
|
+
writeFileVersionAndText && this.projectService.logger.hasLevel(3 /* verbose */)
|
|
172593
|
+
));
|
|
172323
172594
|
this.writeLog("-----------------------------------------------");
|
|
172324
172595
|
if (this.autoImportProviderHost) {
|
|
172325
172596
|
this.autoImportProviderHost.print(
|
|
172326
172597
|
/*writeProjectFileNames*/
|
|
172598
|
+
false,
|
|
172599
|
+
/*writeFileExplaination*/
|
|
172600
|
+
false,
|
|
172601
|
+
/*writeFileVersionAndText*/
|
|
172327
172602
|
false
|
|
172328
172603
|
);
|
|
172329
172604
|
}
|
|
@@ -173347,7 +173622,7 @@ var ConfiguredProject2 = class extends Project3 {
|
|
|
173347
173622
|
return !!this.externalProjectRefCount;
|
|
173348
173623
|
}
|
|
173349
173624
|
getEffectiveTypeRoots() {
|
|
173350
|
-
return getEffectiveTypeRoots(this.getCompilationSettings(), this
|
|
173625
|
+
return getEffectiveTypeRoots(this.getCompilationSettings(), this) || [];
|
|
173351
173626
|
}
|
|
173352
173627
|
/** @internal */
|
|
173353
173628
|
updateErrorOnNoInputFiles(fileNames) {
|
|
@@ -174278,7 +174553,11 @@ var _ProjectService = class {
|
|
|
174278
174553
|
this.logger.info("`remove Project::");
|
|
174279
174554
|
project.print(
|
|
174280
174555
|
/*writeProjectFileNames*/
|
|
174281
|
-
true
|
|
174556
|
+
true,
|
|
174557
|
+
/*writeFileExplaination*/
|
|
174558
|
+
true,
|
|
174559
|
+
/*writeFileVersionAndText*/
|
|
174560
|
+
false
|
|
174282
174561
|
);
|
|
174283
174562
|
project.close();
|
|
174284
174563
|
if (Debug.shouldAssert(1 /* Normal */)) {
|
|
@@ -174417,7 +174696,7 @@ var _ProjectService = class {
|
|
|
174417
174696
|
}
|
|
174418
174697
|
deleteScriptInfo(info) {
|
|
174419
174698
|
this.filenameToScriptInfo.delete(info.path);
|
|
174420
|
-
this.filenameToScriptInfoVersion.set(info.path, info.
|
|
174699
|
+
this.filenameToScriptInfoVersion.set(info.path, info.textStorage.version);
|
|
174421
174700
|
const realpath = info.getRealpathIfDifferent();
|
|
174422
174701
|
if (realpath) {
|
|
174423
174702
|
this.realpathToScriptInfos.remove(realpath, info);
|
|
@@ -175501,7 +175780,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
175501
175780
|
const documentPositionMapper = getDocumentPositionMapper(
|
|
175502
175781
|
{ getCanonicalFileName: this.toCanonicalFileName, log: (s) => this.logger.info(s), getSourceFileLike: (f) => this.getSourceFileLike(f, projectName, declarationInfo) },
|
|
175503
175782
|
declarationInfo.fileName,
|
|
175504
|
-
declarationInfo.getLineInfo(),
|
|
175783
|
+
declarationInfo.textStorage.getLineInfo(),
|
|
175505
175784
|
readMapFile
|
|
175506
175785
|
);
|
|
175507
175786
|
readMapFile = void 0;
|
|
@@ -176632,6 +176911,10 @@ function isConfigFile(config) {
|
|
|
176632
176911
|
function printProjectWithoutFileNames(project) {
|
|
176633
176912
|
project.print(
|
|
176634
176913
|
/*writeProjectFileNames*/
|
|
176914
|
+
false,
|
|
176915
|
+
/*writeFileExplaination*/
|
|
176916
|
+
false,
|
|
176917
|
+
/*writeFileVersionAndText*/
|
|
176635
176918
|
false
|
|
176636
176919
|
);
|
|
176637
176920
|
}
|
|
@@ -177270,7 +177553,6 @@ var invalidSyntacticModeCommands = [
|
|
|
177270
177553
|
"signatureHelp-full" /* SignatureHelpFull */,
|
|
177271
177554
|
"navto" /* Navto */,
|
|
177272
177555
|
"navto-full" /* NavtoFull */,
|
|
177273
|
-
"occurrences" /* Occurrences */,
|
|
177274
177556
|
"documentHighlights" /* DocumentHighlights */,
|
|
177275
177557
|
"documentHighlights-full" /* DocumentHighlightsFull */
|
|
177276
177558
|
];
|
|
@@ -177703,9 +177985,6 @@ var Session3 = class {
|
|
|
177703
177985
|
false
|
|
177704
177986
|
));
|
|
177705
177987
|
},
|
|
177706
|
-
["occurrences" /* Occurrences */]: (request) => {
|
|
177707
|
-
return this.requiredResponse(this.getOccurrences(request.arguments));
|
|
177708
|
-
},
|
|
177709
177988
|
["documentHighlights" /* DocumentHighlights */]: (request) => {
|
|
177710
177989
|
return this.requiredResponse(this.getDocumentHighlights(
|
|
177711
177990
|
request.arguments,
|
|
@@ -178668,21 +178947,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
178668
178947
|
const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray2, project);
|
|
178669
178948
|
return simplifiedResult ? implementations.map(({ fileName, textSpan, contextSpan }) => this.toFileSpanWithContext(fileName, textSpan, contextSpan, project)) : implementations.map(Session3.mapToOriginalLocation);
|
|
178670
178949
|
}
|
|
178671
|
-
getOccurrences(args) {
|
|
178672
|
-
const { file, project } = this.getFileAndProject(args);
|
|
178673
|
-
const position = this.getPositionInFile(args, file);
|
|
178674
|
-
const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position);
|
|
178675
|
-
return occurrences ? occurrences.map((occurrence) => {
|
|
178676
|
-
const { fileName, isWriteAccess: isWriteAccess2, textSpan, isInString: isInString2, contextSpan } = occurrence;
|
|
178677
|
-
const scriptInfo = project.getScriptInfo(fileName);
|
|
178678
|
-
return {
|
|
178679
|
-
...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo),
|
|
178680
|
-
file: fileName,
|
|
178681
|
-
isWriteAccess: isWriteAccess2,
|
|
178682
|
-
...isInString2 ? { isInString: isInString2 } : void 0
|
|
178683
|
-
};
|
|
178684
|
-
}) : emptyArray2;
|
|
178685
|
-
}
|
|
178686
178950
|
getSyntacticDiagnosticsSync(args) {
|
|
178687
178951
|
const { configFile } = this.getConfigFileAndProject(args);
|
|
178688
178952
|
if (configFile) {
|
|
@@ -179093,7 +179357,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
179093
179357
|
formatOptions
|
|
179094
179358
|
);
|
|
179095
179359
|
if (args.key === "\n" && (!edits || edits.length === 0 || allEditsBeforePos(edits, position))) {
|
|
179096
|
-
const { lineText, absolutePosition } = scriptInfo.getAbsolutePositionAndLineText(args.line);
|
|
179360
|
+
const { lineText, absolutePosition } = scriptInfo.textStorage.getAbsolutePositionAndLineText(args.line);
|
|
179097
179361
|
if (lineText && lineText.search("\\S") < 0) {
|
|
179098
179362
|
const preferredIndent = languageService.getIndentationAtPosition(file, position, formatOptions);
|
|
179099
179363
|
let hasIndent = 0;
|
|
@@ -179318,6 +179582,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
179318
179582
|
change(args) {
|
|
179319
179583
|
const scriptInfo = this.projectService.getScriptInfo(args.file);
|
|
179320
179584
|
Debug.assert(!!scriptInfo);
|
|
179585
|
+
scriptInfo.textStorage.switchToScriptVersionCache();
|
|
179321
179586
|
const start2 = scriptInfo.lineOffsetToPosition(args.line, args.offset);
|
|
179322
179587
|
const end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
|
|
179323
179588
|
if (start2 >= 0) {
|
|
@@ -179610,10 +179875,10 @@ ${e.message}`;
|
|
|
179610
179875
|
}
|
|
179611
179876
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
179612
179877
|
}
|
|
179613
|
-
getCombinedCodeFix({ scope, fixId:
|
|
179878
|
+
getCombinedCodeFix({ scope, fixId: fixId52 }, simplifiedResult) {
|
|
179614
179879
|
Debug.assert(scope.type === "file");
|
|
179615
179880
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
179616
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
179881
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId52, this.getFormatOptions(file), this.getPreferences(file));
|
|
179617
179882
|
if (simplifiedResult) {
|
|
179618
179883
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
179619
179884
|
} else {
|
|
@@ -179652,8 +179917,8 @@ ${e.message}`;
|
|
|
179652
179917
|
mapCodeAction({ description: description2, changes, commands }) {
|
|
179653
179918
|
return { description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
179654
179919
|
}
|
|
179655
|
-
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId:
|
|
179656
|
-
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
179920
|
+
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId: fixId52, fixAllDescription }) {
|
|
179921
|
+
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId52, fixAllDescription };
|
|
179657
179922
|
}
|
|
179658
179923
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
179659
179924
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -183463,7 +183728,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
183463
183728
|
nodeToDisplayParts,
|
|
183464
183729
|
noop,
|
|
183465
183730
|
noopFileWatcher,
|
|
183466
|
-
noopPush,
|
|
183467
183731
|
normalizePath,
|
|
183468
183732
|
normalizeSlashes,
|
|
183469
183733
|
not,
|