typescript 5.1.0-dev.20230301 → 5.1.0-dev.20230303
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 +135 -102
- package/lib/tsserver.js +878 -641
- package/lib/tsserverlibrary.d.ts +2 -37
- package/lib/tsserverlibrary.js +937 -691
- package/lib/typescript.d.ts +0 -3
- package/lib/typescript.js +815 -581
- package/lib/typingsInstaller.js +52 -49
- 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.20230303`;
|
|
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
|
}
|
|
@@ -5288,41 +5283,8 @@ function tryGetWebPerformanceHooks() {
|
|
|
5288
5283
|
function tryGetNodePerformanceHooks() {
|
|
5289
5284
|
if (isNodeLikeSystem()) {
|
|
5290
5285
|
try {
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
if (hasRequiredAPI(nodePerformance, PerformanceObserver2)) {
|
|
5294
|
-
performance2 = nodePerformance;
|
|
5295
|
-
const version2 = new Version(process.versions.node);
|
|
5296
|
-
const range = new VersionRange("<12.16.3 || 13 <13.13");
|
|
5297
|
-
if (range.test(version2)) {
|
|
5298
|
-
performance2 = {
|
|
5299
|
-
get timeOrigin() {
|
|
5300
|
-
return nodePerformance.timeOrigin;
|
|
5301
|
-
},
|
|
5302
|
-
now() {
|
|
5303
|
-
return nodePerformance.now();
|
|
5304
|
-
},
|
|
5305
|
-
mark(name) {
|
|
5306
|
-
return nodePerformance.mark(name);
|
|
5307
|
-
},
|
|
5308
|
-
measure(name, start2 = "nodeStart", end) {
|
|
5309
|
-
if (end === void 0) {
|
|
5310
|
-
end = "__performance.measure-fix__";
|
|
5311
|
-
nodePerformance.mark(end);
|
|
5312
|
-
}
|
|
5313
|
-
nodePerformance.measure(name, start2, end);
|
|
5314
|
-
if (end === "__performance.measure-fix__") {
|
|
5315
|
-
nodePerformance.clearMarks("__performance.measure-fix__");
|
|
5316
|
-
}
|
|
5317
|
-
},
|
|
5318
|
-
clearMarks(name) {
|
|
5319
|
-
return nodePerformance.clearMarks(name);
|
|
5320
|
-
},
|
|
5321
|
-
clearMeasures(name) {
|
|
5322
|
-
return nodePerformance.clearMeasures(name);
|
|
5323
|
-
}
|
|
5324
|
-
};
|
|
5325
|
-
}
|
|
5286
|
+
const { performance: performance2, PerformanceObserver: PerformanceObserver2 } = require("perf_hooks");
|
|
5287
|
+
if (hasRequiredAPI(performance2, PerformanceObserver2)) {
|
|
5326
5288
|
return {
|
|
5327
5289
|
// By default, only write native events when generating a cpu profile or using the v8 profiler.
|
|
5328
5290
|
shouldWriteNativeEvents: false,
|
|
@@ -10635,6 +10597,7 @@ var Diagnostics = {
|
|
|
10635
10597
|
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
10598
|
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
10599
|
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."),
|
|
10600
|
+
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
10601
|
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
10602
|
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
10603
|
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 +10993,8 @@ var Diagnostics = {
|
|
|
11030
10993
|
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
10994
|
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
10995
|
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."),
|
|
10996
|
+
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."),
|
|
10997
|
+
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
10998
|
Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
11034
10999
|
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
11000
|
Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
@@ -11244,6 +11209,8 @@ var Diagnostics = {
|
|
|
11244
11209
|
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
11210
|
Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
|
|
11246
11211
|
Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
11212
|
+
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
|
|
11213
|
+
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
11247
11214
|
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
11215
|
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
11216
|
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 +40919,14 @@ function getEffectiveTypeRoots(options, host) {
|
|
|
40952
40919
|
currentDirectory = host.getCurrentDirectory();
|
|
40953
40920
|
}
|
|
40954
40921
|
if (currentDirectory !== void 0) {
|
|
40955
|
-
return getDefaultTypeRoots(currentDirectory
|
|
40922
|
+
return getDefaultTypeRoots(currentDirectory);
|
|
40956
40923
|
}
|
|
40957
40924
|
}
|
|
40958
|
-
function getDefaultTypeRoots(currentDirectory
|
|
40959
|
-
if (!host.directoryExists) {
|
|
40960
|
-
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
40961
|
-
}
|
|
40925
|
+
function getDefaultTypeRoots(currentDirectory) {
|
|
40962
40926
|
let typeRoots;
|
|
40963
40927
|
forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
|
|
40964
40928
|
const atTypes = combinePaths(directory, nodeModulesAtTypes);
|
|
40965
|
-
|
|
40966
|
-
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
40967
|
-
}
|
|
40968
|
-
return void 0;
|
|
40929
|
+
(typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
|
|
40969
40930
|
});
|
|
40970
40931
|
return typeRoots;
|
|
40971
40932
|
}
|
|
@@ -41102,10 +41063,22 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
41102
41063
|
}
|
|
41103
41064
|
return firstDefined(typeRoots, (typeRoot) => {
|
|
41104
41065
|
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
41105
|
-
const
|
|
41106
|
-
const directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
41066
|
+
const directoryExists = directoryProbablyExists(typeRoot, host);
|
|
41107
41067
|
if (!directoryExists && traceEnabled) {
|
|
41108
|
-
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it,
|
|
41068
|
+
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
41069
|
+
}
|
|
41070
|
+
if (options.typeRoots) {
|
|
41071
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
|
|
41072
|
+
if (resolvedFromFile) {
|
|
41073
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
41074
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
41075
|
+
packageDirectory,
|
|
41076
|
+
/*onlyRecordFailures*/
|
|
41077
|
+
false,
|
|
41078
|
+
moduleResolutionState
|
|
41079
|
+
) : void 0;
|
|
41080
|
+
return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
|
|
41081
|
+
}
|
|
41109
41082
|
}
|
|
41110
41083
|
return resolvedTypeScriptOnly(
|
|
41111
41084
|
loadNodeModuleFromDirectory(
|
|
@@ -41125,33 +41098,37 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
41125
41098
|
function secondaryLookup() {
|
|
41126
41099
|
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
|
|
41127
41100
|
if (initialLocationForSecondaryLookup !== void 0) {
|
|
41128
|
-
if (traceEnabled) {
|
|
41129
|
-
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
41130
|
-
}
|
|
41131
41101
|
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
|
-
|
|
41102
|
+
if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
|
|
41103
|
+
if (traceEnabled) {
|
|
41104
|
+
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
41105
|
+
}
|
|
41106
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
41107
|
+
const searchResult = loadModuleFromNearestNodeModulesDirectory(
|
|
41108
|
+
4 /* Declaration */,
|
|
41109
|
+
typeReferenceDirectiveName,
|
|
41110
|
+
initialLocationForSecondaryLookup,
|
|
41111
|
+
moduleResolutionState,
|
|
41112
|
+
/*cache*/
|
|
41113
|
+
void 0,
|
|
41114
|
+
/*redirectedReference*/
|
|
41115
|
+
void 0
|
|
41116
|
+
);
|
|
41117
|
+
result2 = searchResult && searchResult.value;
|
|
41118
|
+
} else {
|
|
41119
|
+
const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
|
|
41120
|
+
result2 = nodeLoadModuleByRelativeName(
|
|
41121
|
+
4 /* Declaration */,
|
|
41122
|
+
candidate,
|
|
41123
|
+
/*onlyRecordFailures*/
|
|
41124
|
+
false,
|
|
41125
|
+
moduleResolutionState,
|
|
41126
|
+
/*considerPackageJson*/
|
|
41127
|
+
true
|
|
41128
|
+
);
|
|
41129
|
+
}
|
|
41130
|
+
} else if (traceEnabled) {
|
|
41131
|
+
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
|
|
41155
41132
|
}
|
|
41156
41133
|
return resolvedTypeScriptOnly(result2);
|
|
41157
41134
|
} else {
|
|
@@ -41983,6 +41960,9 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
41983
41960
|
}
|
|
41984
41961
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
41985
41962
|
}
|
|
41963
|
+
if (extensions2 & 4 /* Declaration */) {
|
|
41964
|
+
resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
|
|
41965
|
+
}
|
|
41986
41966
|
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
41987
41967
|
} else {
|
|
41988
41968
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
@@ -42163,6 +42143,7 @@ function tryFile(fileName, onlyRecordFailures, state) {
|
|
|
42163
42143
|
return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
|
|
42164
42144
|
}
|
|
42165
42145
|
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
42146
|
+
var _a2;
|
|
42166
42147
|
if (!onlyRecordFailures) {
|
|
42167
42148
|
if (state.host.fileExists(fileName)) {
|
|
42168
42149
|
if (state.traceEnabled) {
|
|
@@ -42175,7 +42156,7 @@ function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
|
42175
42156
|
}
|
|
42176
42157
|
}
|
|
42177
42158
|
}
|
|
42178
|
-
state.failedLookupLocations.push(fileName);
|
|
42159
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
|
|
42179
42160
|
return void 0;
|
|
42180
42161
|
}
|
|
42181
42162
|
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
|
|
@@ -42290,8 +42271,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
|
|
|
42290
42271
|
host,
|
|
42291
42272
|
compilerOptions: options,
|
|
42292
42273
|
traceEnabled: isTraceEnabled(options, host),
|
|
42293
|
-
failedLookupLocations:
|
|
42294
|
-
affectingLocations:
|
|
42274
|
+
failedLookupLocations: void 0,
|
|
42275
|
+
affectingLocations: void 0,
|
|
42295
42276
|
packageJsonInfoCache,
|
|
42296
42277
|
features: 0 /* None */,
|
|
42297
42278
|
conditions: emptyArray,
|
|
@@ -42325,24 +42306,24 @@ function getVersionPathsOfPackageJsonInfo(packageJsonInfo, state) {
|
|
|
42325
42306
|
return packageJsonInfo.contents.versionPaths || void 0;
|
|
42326
42307
|
}
|
|
42327
42308
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
42328
|
-
var _a2, _b, _c;
|
|
42309
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
42329
42310
|
const { host, traceEnabled } = state;
|
|
42330
42311
|
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
|
42331
42312
|
if (onlyRecordFailures) {
|
|
42332
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42313
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
|
|
42333
42314
|
return void 0;
|
|
42334
42315
|
}
|
|
42335
|
-
const existing = (
|
|
42316
|
+
const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
42336
42317
|
if (existing !== void 0) {
|
|
42337
42318
|
if (typeof existing !== "boolean") {
|
|
42338
42319
|
if (traceEnabled)
|
|
42339
42320
|
trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
|
|
42340
|
-
state.affectingLocations.push(packageJsonPath);
|
|
42321
|
+
(_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
|
|
42341
42322
|
return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
|
|
42342
42323
|
} else {
|
|
42343
42324
|
if (existing && traceEnabled)
|
|
42344
42325
|
trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
|
|
42345
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42326
|
+
(_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
|
|
42346
42327
|
return void 0;
|
|
42347
42328
|
}
|
|
42348
42329
|
}
|
|
@@ -42353,15 +42334,15 @@ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
|
42353
42334
|
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
42354
42335
|
}
|
|
42355
42336
|
const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
|
|
42356
|
-
(
|
|
42357
|
-
state.affectingLocations.push(packageJsonPath);
|
|
42337
|
+
(_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
|
|
42338
|
+
(_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
|
|
42358
42339
|
return result;
|
|
42359
42340
|
} else {
|
|
42360
42341
|
if (directoryExists && traceEnabled) {
|
|
42361
42342
|
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
42362
42343
|
}
|
|
42363
|
-
(
|
|
42364
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
42344
|
+
(_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
|
|
42345
|
+
(_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
|
|
42365
42346
|
}
|
|
42366
42347
|
}
|
|
42367
42348
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
@@ -43182,11 +43163,13 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
43182
43163
|
state
|
|
43183
43164
|
));
|
|
43184
43165
|
});
|
|
43185
|
-
if (resolved2)
|
|
43166
|
+
if (resolved2)
|
|
43186
43167
|
return resolved2;
|
|
43187
|
-
}
|
|
43188
43168
|
if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
|
|
43189
|
-
|
|
43169
|
+
let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
|
|
43170
|
+
if (extensions & 4 /* Declaration */)
|
|
43171
|
+
resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
|
|
43172
|
+
return resolved3;
|
|
43190
43173
|
}
|
|
43191
43174
|
} else {
|
|
43192
43175
|
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
|
@@ -43200,6 +43183,31 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
43200
43183
|
}
|
|
43201
43184
|
}
|
|
43202
43185
|
}
|
|
43186
|
+
function resolveFromTypeRoot(moduleName, state) {
|
|
43187
|
+
if (!state.compilerOptions.typeRoots)
|
|
43188
|
+
return;
|
|
43189
|
+
for (const typeRoot of state.compilerOptions.typeRoots) {
|
|
43190
|
+
const candidate = combinePaths(typeRoot, moduleName);
|
|
43191
|
+
const directoryExists = directoryProbablyExists(typeRoot, state.host);
|
|
43192
|
+
if (!directoryExists && state.traceEnabled) {
|
|
43193
|
+
trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
43194
|
+
}
|
|
43195
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
|
|
43196
|
+
if (resolvedFromFile) {
|
|
43197
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
43198
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
43199
|
+
packageDirectory,
|
|
43200
|
+
/*onlyRecordFailures*/
|
|
43201
|
+
false,
|
|
43202
|
+
state
|
|
43203
|
+
) : void 0;
|
|
43204
|
+
return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
|
|
43205
|
+
}
|
|
43206
|
+
const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
|
|
43207
|
+
if (resolved)
|
|
43208
|
+
return toSearchResult(resolved);
|
|
43209
|
+
}
|
|
43210
|
+
}
|
|
43203
43211
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
43204
43212
|
return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
|
|
43205
43213
|
}
|
|
@@ -56198,7 +56206,11 @@ function createTypeChecker(host) {
|
|
|
56198
56206
|
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
|
56199
56207
|
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
|
56200
56208
|
} else {
|
|
56201
|
-
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
56209
|
+
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
56210
|
+
type,
|
|
56211
|
+
/*isProperty*/
|
|
56212
|
+
true
|
|
56213
|
+
) : type;
|
|
56202
56214
|
}
|
|
56203
56215
|
}
|
|
56204
56216
|
function getTypeOfEnumMember(symbol) {
|
|
@@ -64899,6 +64911,7 @@ function createTypeChecker(host) {
|
|
|
64899
64911
|
} else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
64900
64912
|
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
64901
64913
|
if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
|
|
64914
|
+
instantiateType(source2.objectType, reportUnreliableMapper);
|
|
64902
64915
|
result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
|
|
64903
64916
|
}
|
|
64904
64917
|
if (result2) {
|
|
@@ -68044,7 +68057,7 @@ function createTypeChecker(host) {
|
|
|
68044
68057
|
);
|
|
68045
68058
|
}
|
|
68046
68059
|
function isInAmbientOrTypeNode(node) {
|
|
68047
|
-
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
|
68060
|
+
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
|
68048
68061
|
}
|
|
68049
68062
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
68050
68063
|
switch (node.kind) {
|
|
@@ -71192,6 +71205,16 @@ function createTypeChecker(host) {
|
|
|
71192
71205
|
const symbol = getSymbolOfDeclaration(element);
|
|
71193
71206
|
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
71194
71207
|
}
|
|
71208
|
+
if (hasDynamicName(element)) {
|
|
71209
|
+
const name = getNameOfDeclaration(element);
|
|
71210
|
+
if (name && isComputedPropertyName(name)) {
|
|
71211
|
+
const exprType = checkExpression(name.expression);
|
|
71212
|
+
const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
|
|
71213
|
+
if (propType) {
|
|
71214
|
+
return propType;
|
|
71215
|
+
}
|
|
71216
|
+
}
|
|
71217
|
+
}
|
|
71195
71218
|
if (element.name) {
|
|
71196
71219
|
const nameType = getLiteralTypeFromPropertyName(element.name);
|
|
71197
71220
|
return mapType(
|
|
@@ -73799,16 +73822,20 @@ function createTypeChecker(host) {
|
|
|
73799
73822
|
) : createTupleType([type], [8 /* Variadic */]);
|
|
73800
73823
|
}
|
|
73801
73824
|
function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
|
|
73825
|
+
const inConstContext = isConstTypeVariable(restType);
|
|
73802
73826
|
if (index >= argCount - 1) {
|
|
73803
73827
|
const arg = args[argCount - 1];
|
|
73804
73828
|
if (isSpreadArgument(arg)) {
|
|
73805
|
-
|
|
73829
|
+
const spreadType = arg.kind === 234 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode);
|
|
73830
|
+
if (isArrayLikeType(spreadType)) {
|
|
73831
|
+
return getMutableArrayOrTupleType(spreadType);
|
|
73832
|
+
}
|
|
73833
|
+
return createArrayType(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 227 /* SpreadElement */ ? arg.expression : arg), inConstContext);
|
|
73806
73834
|
}
|
|
73807
73835
|
}
|
|
73808
73836
|
const types = [];
|
|
73809
73837
|
const flags = [];
|
|
73810
73838
|
const names = [];
|
|
73811
|
-
const inConstContext = isConstTypeVariable(restType);
|
|
73812
73839
|
for (let i = index; i < argCount; i++) {
|
|
73813
73840
|
const arg = args[i];
|
|
73814
73841
|
if (isSpreadArgument(arg)) {
|
|
@@ -75965,7 +75992,7 @@ function createTypeChecker(host) {
|
|
|
75965
75992
|
}
|
|
75966
75993
|
function getNonArrayRestType(signature) {
|
|
75967
75994
|
const restType = getEffectiveRestType(signature);
|
|
75968
|
-
return restType && !isArrayType(restType) && !isTypeAny(restType)
|
|
75995
|
+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
|
|
75969
75996
|
}
|
|
75970
75997
|
function getTypeOfFirstParameterOfSignature(signature) {
|
|
75971
75998
|
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
|
|
@@ -80779,6 +80806,9 @@ function createTypeChecker(host) {
|
|
|
80779
80806
|
return;
|
|
80780
80807
|
}
|
|
80781
80808
|
if (isBindingPattern(node.name)) {
|
|
80809
|
+
if (isInAmbientOrTypeNode(node)) {
|
|
80810
|
+
return;
|
|
80811
|
+
}
|
|
80782
80812
|
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
|
|
80783
80813
|
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
|
80784
80814
|
if (needCheckInitializer || needCheckWidenedType) {
|
|
@@ -123398,7 +123428,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123398
123428
|
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
123399
123429
|
}
|
|
123400
123430
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
123401
|
-
return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
123431
|
+
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
123402
123432
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
123403
123433
|
if (cachedDirectoryStructureHost) {
|
|
123404
123434
|
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
|
@@ -123409,7 +123439,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123409
123439
|
if (dirPath) {
|
|
123410
123440
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
123411
123441
|
}
|
|
123412
|
-
}, 1 /* Recursive */);
|
|
123442
|
+
}, 1 /* Recursive */) : noopFileWatcher;
|
|
123413
123443
|
}
|
|
123414
123444
|
function updateTypeRootsWatch() {
|
|
123415
123445
|
const options = resolutionHost.getCompilationSettings();
|
|
@@ -123417,7 +123447,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123417
123447
|
closeTypeRootsWatch();
|
|
123418
123448
|
return;
|
|
123419
123449
|
}
|
|
123420
|
-
const typeRoots = getEffectiveTypeRoots(options, {
|
|
123450
|
+
const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
|
|
123421
123451
|
if (typeRoots) {
|
|
123422
123452
|
mutateMap(
|
|
123423
123453
|
typeRootsWatches,
|
|
@@ -123431,7 +123461,9 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
123431
123461
|
closeTypeRootsWatch();
|
|
123432
123462
|
}
|
|
123433
123463
|
}
|
|
123434
|
-
function
|
|
123464
|
+
function canWatchTypeRootPath(nodeTypesDirectory) {
|
|
123465
|
+
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
123466
|
+
return true;
|
|
123435
123467
|
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
|
123436
123468
|
const dirPath = resolutionHost.toPath(dir);
|
|
123437
123469
|
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
@@ -133236,6 +133268,10 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
133236
133268
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
133237
133269
|
}
|
|
133238
133270
|
}
|
|
133271
|
+
const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
|
|
133272
|
+
if (jsdocTypedefNode) {
|
|
133273
|
+
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
133274
|
+
}
|
|
133239
133275
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
133240
133276
|
diags.push(createDiagnosticForNode(node.name || node, Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types));
|
|
133241
133277
|
}
|
|
@@ -135260,7 +135296,6 @@ var invalidOperationsInSyntacticMode = [
|
|
|
135260
135296
|
"getTypeDefinitionAtPosition",
|
|
135261
135297
|
"getReferencesAtPosition",
|
|
135262
135298
|
"findReferences",
|
|
135263
|
-
"getOccurrencesAtPosition",
|
|
135264
135299
|
"getDocumentHighlights",
|
|
135265
135300
|
"getNavigateToItems",
|
|
135266
135301
|
"getRenameInfo",
|
|
@@ -135683,18 +135718,6 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
135683
135718
|
synchronizeHostData();
|
|
135684
135719
|
return ts_FindAllReferences_exports.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
135685
135720
|
}
|
|
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
135721
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
135699
135722
|
const normalizedFileName = normalizePath(fileName);
|
|
135700
135723
|
Debug.assert(filesToSearch.some((f) => normalizePath(f) === normalizedFileName));
|
|
@@ -135887,22 +135910,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
135887
135910
|
}
|
|
135888
135911
|
return [];
|
|
135889
135912
|
}
|
|
135890
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
135913
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes64, formatOptions, preferences = emptyOptions) {
|
|
135891
135914
|
synchronizeHostData();
|
|
135892
135915
|
const sourceFile = getValidSourceFile(fileName);
|
|
135893
135916
|
const span = createTextSpanFromBounds(start2, end);
|
|
135894
135917
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
135895
|
-
return flatMap(deduplicate(
|
|
135918
|
+
return flatMap(deduplicate(errorCodes64, equateValues, compareValues), (errorCode) => {
|
|
135896
135919
|
cancellationToken.throwIfCancellationRequested();
|
|
135897
135920
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
135898
135921
|
});
|
|
135899
135922
|
}
|
|
135900
|
-
function getCombinedCodeFix(scope,
|
|
135923
|
+
function getCombinedCodeFix(scope, fixId52, formatOptions, preferences = emptyOptions) {
|
|
135901
135924
|
synchronizeHostData();
|
|
135902
135925
|
Debug.assert(scope.type === "file");
|
|
135903
135926
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
135904
135927
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
135905
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
135928
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId52, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
135906
135929
|
}
|
|
135907
135930
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
135908
135931
|
var _a3;
|
|
@@ -136324,7 +136347,6 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
136324
136347
|
getReferencesAtPosition,
|
|
136325
136348
|
findReferences,
|
|
136326
136349
|
getFileReferences,
|
|
136327
|
-
getOccurrencesAtPosition,
|
|
136328
136350
|
getDocumentHighlights,
|
|
136329
136351
|
getNameOrDottedNameSpan,
|
|
136330
136352
|
getBreakpointStatementAtPosition,
|
|
@@ -137043,12 +137065,6 @@ var LanguageServiceShimObject = class extends ShimBase {
|
|
|
137043
137065
|
() => this.languageService.getFileReferences(fileName)
|
|
137044
137066
|
);
|
|
137045
137067
|
}
|
|
137046
|
-
getOccurrencesAtPosition(fileName, position) {
|
|
137047
|
-
return this.forwardJSONCall(
|
|
137048
|
-
`getOccurrencesAtPosition('${fileName}', ${position})`,
|
|
137049
|
-
() => this.languageService.getOccurrencesAtPosition(fileName, position)
|
|
137050
|
-
);
|
|
137051
|
-
}
|
|
137052
137068
|
getDocumentHighlights(fileName, position, filesToSearch) {
|
|
137053
137069
|
return this.forwardJSONCall(
|
|
137054
137070
|
`getDocumentHighlights('${fileName}', ${position})`,
|
|
@@ -138657,6 +138673,7 @@ __export(ts_codefix_exports, {
|
|
|
138657
138673
|
getFixes: () => getFixes,
|
|
138658
138674
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
138659
138675
|
getImportKind: () => getImportKind,
|
|
138676
|
+
getJSDocTypedefNode: () => getJSDocTypedefNode,
|
|
138660
138677
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
138661
138678
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
138662
138679
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -138686,41 +138703,43 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description2) {
|
|
|
138686
138703
|
void 0
|
|
138687
138704
|
);
|
|
138688
138705
|
}
|
|
138689
|
-
function createCodeFixAction(fixName8, changes, description2,
|
|
138690
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
138706
|
+
function createCodeFixAction(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
138707
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, diagnosticToString(fixAllDescription), command);
|
|
138691
138708
|
}
|
|
138692
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description2,
|
|
138693
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
138709
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
138710
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
138694
138711
|
}
|
|
138695
|
-
function createCodeFixActionWorker(fixName8, description2, changes,
|
|
138696
|
-
return { fixName: fixName8, description: description2, changes, fixId:
|
|
138712
|
+
function createCodeFixActionWorker(fixName8, description2, changes, fixId52, fixAllDescription, command) {
|
|
138713
|
+
return { fixName: fixName8, description: description2, changes, fixId: fixId52, fixAllDescription, commands: command ? [command] : void 0 };
|
|
138697
138714
|
}
|
|
138698
138715
|
function registerCodeFix(reg) {
|
|
138699
138716
|
for (const error of reg.errorCodes) {
|
|
138717
|
+
errorCodeToFixesArray = void 0;
|
|
138700
138718
|
errorCodeToFixes.add(String(error), reg);
|
|
138701
138719
|
}
|
|
138702
138720
|
if (reg.fixIds) {
|
|
138703
|
-
for (const
|
|
138704
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
138705
|
-
fixIdToRegistration.set(
|
|
138721
|
+
for (const fixId52 of reg.fixIds) {
|
|
138722
|
+
Debug.assert(!fixIdToRegistration.has(fixId52));
|
|
138723
|
+
fixIdToRegistration.set(fixId52, reg);
|
|
138706
138724
|
}
|
|
138707
138725
|
}
|
|
138708
138726
|
}
|
|
138727
|
+
var errorCodeToFixesArray;
|
|
138709
138728
|
function getSupportedErrorCodes() {
|
|
138710
|
-
return arrayFrom(errorCodeToFixes.keys());
|
|
138729
|
+
return errorCodeToFixesArray != null ? errorCodeToFixesArray : errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys());
|
|
138711
138730
|
}
|
|
138712
138731
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
138713
|
-
const { errorCodes:
|
|
138732
|
+
const { errorCodes: errorCodes64 } = registration;
|
|
138714
138733
|
let maybeFixableDiagnostics = 0;
|
|
138715
138734
|
for (const diag2 of diagnostics) {
|
|
138716
|
-
if (contains(
|
|
138735
|
+
if (contains(errorCodes64, diag2.code))
|
|
138717
138736
|
maybeFixableDiagnostics++;
|
|
138718
138737
|
if (maybeFixableDiagnostics > 1)
|
|
138719
138738
|
break;
|
|
138720
138739
|
}
|
|
138721
138740
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
138722
|
-
return ({ fixId:
|
|
138723
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
138741
|
+
return ({ fixId: fixId52, fixAllDescription, ...action }) => {
|
|
138742
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId52, fixAllDescription };
|
|
138724
138743
|
};
|
|
138725
138744
|
}
|
|
138726
138745
|
function getFixes(context) {
|
|
@@ -138737,14 +138756,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
138737
138756
|
function createFileTextChanges(fileName, textChanges2) {
|
|
138738
138757
|
return { fileName, textChanges: textChanges2 };
|
|
138739
138758
|
}
|
|
138740
|
-
function codeFixAll(context,
|
|
138759
|
+
function codeFixAll(context, errorCodes64, use) {
|
|
138741
138760
|
const commands = [];
|
|
138742
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
138761
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes64, (diag2) => use(t, diag2, commands)));
|
|
138743
138762
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
138744
138763
|
}
|
|
138745
|
-
function eachDiagnostic(context,
|
|
138764
|
+
function eachDiagnostic(context, errorCodes64, cb) {
|
|
138746
138765
|
for (const diag2 of getDiagnostics(context)) {
|
|
138747
|
-
if (contains(
|
|
138766
|
+
if (contains(errorCodes64, diag2.code)) {
|
|
138748
138767
|
cb(diag2);
|
|
138749
138768
|
}
|
|
138750
138769
|
}
|
|
@@ -141199,61 +141218,268 @@ function getTypeExportSpecifiers(originExportSpecifier, context) {
|
|
|
141199
141218
|
}
|
|
141200
141219
|
|
|
141201
141220
|
// src/services/codefixes/convertToTypeOnlyImport.ts
|
|
141202
|
-
var errorCodes14 = [
|
|
141221
|
+
var errorCodes14 = [
|
|
141222
|
+
Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error.code,
|
|
141223
|
+
Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code
|
|
141224
|
+
];
|
|
141203
141225
|
var fixId13 = "convertToTypeOnlyImport";
|
|
141204
141226
|
registerCodeFix({
|
|
141205
141227
|
errorCodes: errorCodes14,
|
|
141206
141228
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
141207
|
-
const
|
|
141208
|
-
|
|
141209
|
-
|
|
141210
|
-
});
|
|
141211
|
-
if (changes.length) {
|
|
141229
|
+
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
141230
|
+
if (declaration) {
|
|
141231
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(t, context.sourceFile, declaration));
|
|
141212
141232
|
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
141233
|
}
|
|
141234
|
+
return void 0;
|
|
141214
141235
|
},
|
|
141215
141236
|
fixIds: [fixId13],
|
|
141216
141237
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
141217
141238
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
141218
|
-
const
|
|
141219
|
-
|
|
141239
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
141240
|
+
if (declaration) {
|
|
141241
|
+
doChange4(changes, diag2.file, declaration);
|
|
141242
|
+
}
|
|
141220
141243
|
});
|
|
141221
141244
|
}
|
|
141222
141245
|
});
|
|
141223
|
-
function
|
|
141224
|
-
|
|
141246
|
+
function getDeclaration2(sourceFile, pos) {
|
|
141247
|
+
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
141248
|
+
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
141249
|
+
}
|
|
141250
|
+
function doChange4(changes, sourceFile, declaration) {
|
|
141251
|
+
if (isImportSpecifier(declaration)) {
|
|
141252
|
+
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
141253
|
+
declaration,
|
|
141254
|
+
/*isTypeOnly*/
|
|
141255
|
+
true,
|
|
141256
|
+
declaration.propertyName,
|
|
141257
|
+
declaration.name
|
|
141258
|
+
));
|
|
141259
|
+
} else {
|
|
141260
|
+
const importClause = declaration.importClause;
|
|
141261
|
+
if (importClause.name && importClause.namedBindings) {
|
|
141262
|
+
changes.replaceNodeWithNodes(sourceFile, declaration, [
|
|
141263
|
+
factory.createImportDeclaration(
|
|
141264
|
+
getSynthesizedDeepClones(
|
|
141265
|
+
declaration.modifiers,
|
|
141266
|
+
/*includeTrivia*/
|
|
141267
|
+
true
|
|
141268
|
+
),
|
|
141269
|
+
factory.createImportClause(
|
|
141270
|
+
/*isTypeOnly*/
|
|
141271
|
+
true,
|
|
141272
|
+
getSynthesizedDeepClone(
|
|
141273
|
+
importClause.name,
|
|
141274
|
+
/*includeTrivia*/
|
|
141275
|
+
true
|
|
141276
|
+
),
|
|
141277
|
+
/*namedBindings*/
|
|
141278
|
+
void 0
|
|
141279
|
+
),
|
|
141280
|
+
getSynthesizedDeepClone(
|
|
141281
|
+
declaration.moduleSpecifier,
|
|
141282
|
+
/*includeTrivia*/
|
|
141283
|
+
true
|
|
141284
|
+
),
|
|
141285
|
+
getSynthesizedDeepClone(
|
|
141286
|
+
declaration.assertClause,
|
|
141287
|
+
/*includeTrivia*/
|
|
141288
|
+
true
|
|
141289
|
+
)
|
|
141290
|
+
),
|
|
141291
|
+
factory.createImportDeclaration(
|
|
141292
|
+
getSynthesizedDeepClones(
|
|
141293
|
+
declaration.modifiers,
|
|
141294
|
+
/*includeTrivia*/
|
|
141295
|
+
true
|
|
141296
|
+
),
|
|
141297
|
+
factory.createImportClause(
|
|
141298
|
+
/*isTypeOnly*/
|
|
141299
|
+
true,
|
|
141300
|
+
/*name*/
|
|
141301
|
+
void 0,
|
|
141302
|
+
getSynthesizedDeepClone(
|
|
141303
|
+
importClause.namedBindings,
|
|
141304
|
+
/*includeTrivia*/
|
|
141305
|
+
true
|
|
141306
|
+
)
|
|
141307
|
+
),
|
|
141308
|
+
getSynthesizedDeepClone(
|
|
141309
|
+
declaration.moduleSpecifier,
|
|
141310
|
+
/*includeTrivia*/
|
|
141311
|
+
true
|
|
141312
|
+
),
|
|
141313
|
+
getSynthesizedDeepClone(
|
|
141314
|
+
declaration.assertClause,
|
|
141315
|
+
/*includeTrivia*/
|
|
141316
|
+
true
|
|
141317
|
+
)
|
|
141318
|
+
)
|
|
141319
|
+
]);
|
|
141320
|
+
} else {
|
|
141321
|
+
const importDeclaration = factory.updateImportDeclaration(
|
|
141322
|
+
declaration,
|
|
141323
|
+
declaration.modifiers,
|
|
141324
|
+
factory.updateImportClause(
|
|
141325
|
+
importClause,
|
|
141326
|
+
/*isTypeOnly*/
|
|
141327
|
+
true,
|
|
141328
|
+
importClause.name,
|
|
141329
|
+
importClause.namedBindings
|
|
141330
|
+
),
|
|
141331
|
+
declaration.moduleSpecifier,
|
|
141332
|
+
declaration.assertClause
|
|
141333
|
+
);
|
|
141334
|
+
changes.replaceNode(sourceFile, declaration, importDeclaration);
|
|
141335
|
+
}
|
|
141336
|
+
}
|
|
141337
|
+
}
|
|
141338
|
+
|
|
141339
|
+
// src/services/codefixes/convertTypedefToType.ts
|
|
141340
|
+
var fixId14 = "convertTypedefToType";
|
|
141341
|
+
var errorCodes15 = [Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type.code];
|
|
141342
|
+
registerCodeFix({
|
|
141343
|
+
fixIds: [fixId14],
|
|
141344
|
+
errorCodes: errorCodes15,
|
|
141345
|
+
getCodeActions(context) {
|
|
141346
|
+
const node = getTokenAtPosition(
|
|
141347
|
+
context.sourceFile,
|
|
141348
|
+
context.span.start
|
|
141349
|
+
);
|
|
141350
|
+
if (!node)
|
|
141351
|
+
return;
|
|
141352
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange5(t, node, context.sourceFile));
|
|
141353
|
+
if (changes.length > 0) {
|
|
141354
|
+
return [
|
|
141355
|
+
createCodeFixAction(
|
|
141356
|
+
fixId14,
|
|
141357
|
+
changes,
|
|
141358
|
+
Diagnostics.Convert_typedef_to_TypeScript_type,
|
|
141359
|
+
fixId14,
|
|
141360
|
+
Diagnostics.Convert_all_typedef_to_TypeScript_types
|
|
141361
|
+
)
|
|
141362
|
+
];
|
|
141363
|
+
}
|
|
141364
|
+
},
|
|
141365
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
|
|
141366
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
141367
|
+
if (node)
|
|
141368
|
+
doChange5(changes, node, diag2.file);
|
|
141369
|
+
})
|
|
141370
|
+
});
|
|
141371
|
+
function doChange5(changes, node, sourceFile) {
|
|
141372
|
+
if (isJSDocTypedefTag(node)) {
|
|
141373
|
+
fixSingleTypeDef(changes, node, sourceFile);
|
|
141374
|
+
}
|
|
141225
141375
|
}
|
|
141226
|
-
function
|
|
141227
|
-
if (!
|
|
141376
|
+
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
141377
|
+
if (!typeDefNode)
|
|
141228
141378
|
return;
|
|
141379
|
+
const declaration = createDeclaration(typeDefNode);
|
|
141380
|
+
if (!declaration)
|
|
141381
|
+
return;
|
|
141382
|
+
const comment = typeDefNode.parent;
|
|
141383
|
+
changes.replaceNode(
|
|
141384
|
+
sourceFile,
|
|
141385
|
+
comment,
|
|
141386
|
+
declaration
|
|
141387
|
+
);
|
|
141388
|
+
}
|
|
141389
|
+
function createDeclaration(tag) {
|
|
141390
|
+
var _a2;
|
|
141391
|
+
const { typeExpression } = tag;
|
|
141392
|
+
if (!typeExpression)
|
|
141393
|
+
return;
|
|
141394
|
+
const typeName = (_a2 = tag.name) == null ? void 0 : _a2.getText();
|
|
141395
|
+
if (!typeName)
|
|
141396
|
+
return;
|
|
141397
|
+
if (typeExpression.kind === 325 /* JSDocTypeLiteral */) {
|
|
141398
|
+
return createInterfaceForTypeLiteral(typeName, typeExpression);
|
|
141229
141399
|
}
|
|
141230
|
-
|
|
141231
|
-
|
|
141232
|
-
|
|
141233
|
-
|
|
141234
|
-
|
|
141235
|
-
|
|
141236
|
-
|
|
141237
|
-
|
|
141238
|
-
|
|
141239
|
-
|
|
141240
|
-
|
|
141241
|
-
|
|
141242
|
-
|
|
141243
|
-
|
|
141244
|
-
|
|
141245
|
-
|
|
141246
|
-
|
|
141247
|
-
|
|
141248
|
-
|
|
141400
|
+
if (typeExpression.kind === 312 /* JSDocTypeExpression */) {
|
|
141401
|
+
return createTypeAliasForTypeExpression(typeName, typeExpression);
|
|
141402
|
+
}
|
|
141403
|
+
}
|
|
141404
|
+
function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
141405
|
+
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
141406
|
+
if (!some(propertySignatures))
|
|
141407
|
+
return;
|
|
141408
|
+
const interfaceDeclaration = factory.createInterfaceDeclaration(
|
|
141409
|
+
/*modifiers*/
|
|
141410
|
+
void 0,
|
|
141411
|
+
typeName,
|
|
141412
|
+
/*typeParameters*/
|
|
141413
|
+
void 0,
|
|
141414
|
+
/*heritageClauses*/
|
|
141415
|
+
void 0,
|
|
141416
|
+
propertySignatures
|
|
141417
|
+
);
|
|
141418
|
+
return interfaceDeclaration;
|
|
141419
|
+
}
|
|
141420
|
+
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
141421
|
+
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
141422
|
+
if (!typeReference)
|
|
141423
|
+
return;
|
|
141424
|
+
const declaration = factory.createTypeAliasDeclaration(
|
|
141425
|
+
/*modifiers*/
|
|
141426
|
+
void 0,
|
|
141427
|
+
factory.createIdentifier(typeName),
|
|
141428
|
+
/*typeParameters*/
|
|
141429
|
+
void 0,
|
|
141430
|
+
typeReference
|
|
141431
|
+
);
|
|
141432
|
+
return declaration;
|
|
141433
|
+
}
|
|
141434
|
+
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
141435
|
+
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
141436
|
+
if (!some(propertyTags))
|
|
141437
|
+
return;
|
|
141438
|
+
const getSignature = (tag) => {
|
|
141439
|
+
var _a2;
|
|
141440
|
+
const name = getPropertyName(tag);
|
|
141441
|
+
const type = (_a2 = tag.typeExpression) == null ? void 0 : _a2.type;
|
|
141442
|
+
const isOptional = tag.isBracketed;
|
|
141443
|
+
let typeReference;
|
|
141444
|
+
if (type && isJSDocTypeLiteral(type)) {
|
|
141445
|
+
const signatures = createSignatureFromTypeLiteral(type);
|
|
141446
|
+
typeReference = factory.createTypeLiteralNode(signatures);
|
|
141447
|
+
} else if (type) {
|
|
141448
|
+
typeReference = getSynthesizedDeepClone(type);
|
|
141449
|
+
}
|
|
141450
|
+
if (typeReference && name) {
|
|
141451
|
+
const questionToken = isOptional ? factory.createToken(57 /* QuestionToken */) : void 0;
|
|
141452
|
+
const prop = factory.createPropertySignature(
|
|
141453
|
+
/*modifiers*/
|
|
141454
|
+
void 0,
|
|
141455
|
+
name,
|
|
141456
|
+
questionToken,
|
|
141457
|
+
typeReference
|
|
141458
|
+
);
|
|
141459
|
+
return prop;
|
|
141460
|
+
}
|
|
141461
|
+
};
|
|
141462
|
+
const props = mapDefined(propertyTags, getSignature);
|
|
141463
|
+
return props;
|
|
141464
|
+
}
|
|
141465
|
+
function getPropertyName(tag) {
|
|
141466
|
+
return tag.name.kind === 79 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
141467
|
+
}
|
|
141468
|
+
function getJSDocTypedefNode(node) {
|
|
141469
|
+
if (hasJSDocNodes(node)) {
|
|
141470
|
+
return forEach(node.jsDoc, (node2) => {
|
|
141471
|
+
var _a2;
|
|
141472
|
+
return (_a2 = node2.tags) == null ? void 0 : _a2.find(isJSDocTypedefTag);
|
|
141473
|
+
});
|
|
141249
141474
|
}
|
|
141475
|
+
return void 0;
|
|
141250
141476
|
}
|
|
141251
141477
|
|
|
141252
141478
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
141253
|
-
var
|
|
141254
|
-
var
|
|
141479
|
+
var fixId15 = "convertLiteralTypeToMappedType";
|
|
141480
|
+
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
141481
|
registerCodeFix({
|
|
141256
|
-
errorCodes:
|
|
141482
|
+
errorCodes: errorCodes16,
|
|
141257
141483
|
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
|
|
141258
141484
|
const { sourceFile, span } = context;
|
|
141259
141485
|
const info = getInfo2(sourceFile, span.start);
|
|
@@ -141261,14 +141487,14 @@ registerCodeFix({
|
|
|
141261
141487
|
return void 0;
|
|
141262
141488
|
}
|
|
141263
141489
|
const { name, constraint } = info;
|
|
141264
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141265
|
-
return [createCodeFixAction(
|
|
141490
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange6(t, sourceFile, info));
|
|
141491
|
+
return [createCodeFixAction(fixId15, changes, [Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId15, Diagnostics.Convert_all_type_literals_to_mapped_type)];
|
|
141266
141492
|
},
|
|
141267
|
-
fixIds: [
|
|
141268
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141493
|
+
fixIds: [fixId15],
|
|
141494
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes16, (changes, diag2) => {
|
|
141269
141495
|
const info = getInfo2(diag2.file, diag2.start);
|
|
141270
141496
|
if (info) {
|
|
141271
|
-
|
|
141497
|
+
doChange6(changes, diag2.file, info);
|
|
141272
141498
|
}
|
|
141273
141499
|
})
|
|
141274
141500
|
});
|
|
@@ -141286,7 +141512,7 @@ function getInfo2(sourceFile, pos) {
|
|
|
141286
141512
|
}
|
|
141287
141513
|
return void 0;
|
|
141288
141514
|
}
|
|
141289
|
-
function
|
|
141515
|
+
function doChange6(changes, sourceFile, { container, typeNode, constraint, name }) {
|
|
141290
141516
|
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
|
|
141291
141517
|
/*readonlyToken*/
|
|
141292
141518
|
void 0,
|
|
@@ -141307,25 +141533,25 @@ function doChange4(changes, sourceFile, { container, typeNode, constraint, name
|
|
|
141307
141533
|
}
|
|
141308
141534
|
|
|
141309
141535
|
// src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts
|
|
141310
|
-
var
|
|
141536
|
+
var errorCodes17 = [
|
|
141311
141537
|
Diagnostics.Class_0_incorrectly_implements_interface_1.code,
|
|
141312
141538
|
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code
|
|
141313
141539
|
];
|
|
141314
|
-
var
|
|
141540
|
+
var fixId16 = "fixClassIncorrectlyImplementsInterface";
|
|
141315
141541
|
registerCodeFix({
|
|
141316
|
-
errorCodes:
|
|
141542
|
+
errorCodes: errorCodes17,
|
|
141317
141543
|
getCodeActions(context) {
|
|
141318
141544
|
const { sourceFile, span } = context;
|
|
141319
141545
|
const classDeclaration = getClass(sourceFile, span.start);
|
|
141320
141546
|
return mapDefined(getEffectiveImplementsTypeNodes(classDeclaration), (implementedTypeNode) => {
|
|
141321
141547
|
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(
|
|
141548
|
+
return changes.length === 0 ? void 0 : createCodeFixAction(fixId16, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId16, Diagnostics.Implement_all_unimplemented_interfaces);
|
|
141323
141549
|
});
|
|
141324
141550
|
},
|
|
141325
|
-
fixIds: [
|
|
141551
|
+
fixIds: [fixId16],
|
|
141326
141552
|
getAllCodeActions(context) {
|
|
141327
141553
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
141328
|
-
return codeFixAll(context,
|
|
141554
|
+
return codeFixAll(context, errorCodes17, (changes, diag2) => {
|
|
141329
141555
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
141330
141556
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
141331
141557
|
for (const implementedTypeNode of getEffectiveImplementsTypeNodes(classDeclaration)) {
|
|
@@ -141390,7 +141616,7 @@ function getHeritageClauseSymbolTable(classDeclaration, checker) {
|
|
|
141390
141616
|
// src/services/codefixes/importFixes.ts
|
|
141391
141617
|
var importFixName = "import";
|
|
141392
141618
|
var importFixId = "fixMissingImport";
|
|
141393
|
-
var
|
|
141619
|
+
var errorCodes18 = [
|
|
141394
141620
|
Diagnostics.Cannot_find_name_0.code,
|
|
141395
141621
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
141396
141622
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
@@ -141402,7 +141628,7 @@ var errorCodes17 = [
|
|
|
141402
141628
|
Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
|
|
141403
141629
|
];
|
|
141404
141630
|
registerCodeFix({
|
|
141405
|
-
errorCodes:
|
|
141631
|
+
errorCodes: errorCodes18,
|
|
141406
141632
|
getCodeActions(context) {
|
|
141407
141633
|
const { errorCode, preferences, sourceFile, span, program } = context;
|
|
141408
141634
|
const info = getFixInfos(
|
|
@@ -141437,7 +141663,7 @@ registerCodeFix({
|
|
|
141437
141663
|
host,
|
|
141438
141664
|
cancellationToken
|
|
141439
141665
|
);
|
|
141440
|
-
eachDiagnostic(context,
|
|
141666
|
+
eachDiagnostic(context, errorCodes18, (diag2) => importAdder.addImportFromDiagnostic(diag2, context));
|
|
141441
141667
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, importAdder.writeFixes));
|
|
141442
141668
|
}
|
|
141443
141669
|
});
|
|
@@ -142603,8 +142829,8 @@ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitali
|
|
|
142603
142829
|
}
|
|
142604
142830
|
|
|
142605
142831
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
142606
|
-
var
|
|
142607
|
-
var
|
|
142832
|
+
var fixId17 = "addMissingConstraint";
|
|
142833
|
+
var errorCodes19 = [
|
|
142608
142834
|
// We want errors this could be attached to:
|
|
142609
142835
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
142610
142836
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -142617,21 +142843,21 @@ var errorCodes18 = [
|
|
|
142617
142843
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
142618
142844
|
];
|
|
142619
142845
|
registerCodeFix({
|
|
142620
|
-
errorCodes:
|
|
142846
|
+
errorCodes: errorCodes19,
|
|
142621
142847
|
getCodeActions(context) {
|
|
142622
142848
|
const { sourceFile, span, program, preferences, host } = context;
|
|
142623
142849
|
const info = getInfo3(program, sourceFile, span);
|
|
142624
142850
|
if (info === void 0)
|
|
142625
142851
|
return;
|
|
142626
142852
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
142627
|
-
return [createCodeFixAction(
|
|
142853
|
+
return [createCodeFixAction(fixId17, changes, Diagnostics.Add_extends_constraint, fixId17, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
142628
142854
|
},
|
|
142629
|
-
fixIds: [
|
|
142855
|
+
fixIds: [fixId17],
|
|
142630
142856
|
getAllCodeActions: (context) => {
|
|
142631
142857
|
const { program, preferences, host } = context;
|
|
142632
142858
|
const seen = /* @__PURE__ */ new Map();
|
|
142633
142859
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142634
|
-
eachDiagnostic(context,
|
|
142860
|
+
eachDiagnostic(context, errorCodes19, (diag2) => {
|
|
142635
142861
|
const info = getInfo3(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
142636
142862
|
if (info) {
|
|
142637
142863
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -142715,7 +142941,7 @@ function tryGetConstraintType(checker, node) {
|
|
|
142715
142941
|
var fixName = "fixOverrideModifier";
|
|
142716
142942
|
var fixAddOverrideId = "fixAddOverrideModifier";
|
|
142717
142943
|
var fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
142718
|
-
var
|
|
142944
|
+
var errorCodes20 = [
|
|
142719
142945
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
142720
142946
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
142721
142947
|
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 +143005,20 @@ var errorCodeFixIdMap = {
|
|
|
142779
143005
|
}
|
|
142780
143006
|
};
|
|
142781
143007
|
registerCodeFix({
|
|
142782
|
-
errorCodes:
|
|
143008
|
+
errorCodes: errorCodes20,
|
|
142783
143009
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
142784
143010
|
const { errorCode, span } = context;
|
|
142785
143011
|
const info = errorCodeFixIdMap[errorCode];
|
|
142786
143012
|
if (!info)
|
|
142787
143013
|
return emptyArray;
|
|
142788
|
-
const { descriptions, fixId:
|
|
143014
|
+
const { descriptions, fixId: fixId52, fixAllDescriptions } = info;
|
|
142789
143015
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
142790
143016
|
return [
|
|
142791
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
143017
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId52, fixAllDescriptions)
|
|
142792
143018
|
];
|
|
142793
143019
|
},
|
|
142794
143020
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
142795
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143021
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes20, (changes, diag2) => {
|
|
142796
143022
|
const { code, start: start2 } = diag2;
|
|
142797
143023
|
const info = errorCodeFixIdMap[code];
|
|
142798
143024
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -142869,22 +143095,22 @@ function findContainerClassElementLike(sourceFile, pos) {
|
|
|
142869
143095
|
}
|
|
142870
143096
|
|
|
142871
143097
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
142872
|
-
var
|
|
142873
|
-
var
|
|
143098
|
+
var fixId18 = "fixNoPropertyAccessFromIndexSignature";
|
|
143099
|
+
var errorCodes21 = [
|
|
142874
143100
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
142875
143101
|
];
|
|
142876
143102
|
registerCodeFix({
|
|
142877
|
-
errorCodes:
|
|
142878
|
-
fixIds: [
|
|
143103
|
+
errorCodes: errorCodes21,
|
|
143104
|
+
fixIds: [fixId18],
|
|
142879
143105
|
getCodeActions(context) {
|
|
142880
143106
|
const { sourceFile, span, preferences } = context;
|
|
142881
143107
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
142882
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
142883
|
-
return [createCodeFixAction(
|
|
143108
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange7(t, context.sourceFile, property, preferences));
|
|
143109
|
+
return [createCodeFixAction(fixId18, changes, [Diagnostics.Use_element_access_for_0, property.name.text], fixId18, Diagnostics.Use_element_access_for_all_undeclared_properties)];
|
|
142884
143110
|
},
|
|
142885
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143111
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => doChange7(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
142886
143112
|
});
|
|
142887
|
-
function
|
|
143113
|
+
function doChange7(changes, sourceFile, node, preferences) {
|
|
142888
143114
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
142889
143115
|
const argumentsExpression = factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */);
|
|
142890
143116
|
changes.replaceNode(
|
|
@@ -142898,24 +143124,24 @@ function getPropertyAccessExpression(sourceFile, pos) {
|
|
|
142898
143124
|
}
|
|
142899
143125
|
|
|
142900
143126
|
// src/services/codefixes/fixImplicitThis.ts
|
|
142901
|
-
var
|
|
142902
|
-
var
|
|
143127
|
+
var fixId19 = "fixImplicitThis";
|
|
143128
|
+
var errorCodes22 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
142903
143129
|
registerCodeFix({
|
|
142904
|
-
errorCodes:
|
|
143130
|
+
errorCodes: errorCodes22,
|
|
142905
143131
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
142906
143132
|
const { sourceFile, program, span } = context;
|
|
142907
143133
|
let diagnostic;
|
|
142908
143134
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
142909
|
-
diagnostic =
|
|
143135
|
+
diagnostic = doChange8(t, sourceFile, span.start, program.getTypeChecker());
|
|
142910
143136
|
});
|
|
142911
|
-
return diagnostic ? [createCodeFixAction(
|
|
143137
|
+
return diagnostic ? [createCodeFixAction(fixId19, changes, diagnostic, fixId19, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
142912
143138
|
},
|
|
142913
|
-
fixIds: [
|
|
142914
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142915
|
-
|
|
143139
|
+
fixIds: [fixId19],
|
|
143140
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => {
|
|
143141
|
+
doChange8(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
142916
143142
|
})
|
|
142917
143143
|
});
|
|
142918
|
-
function
|
|
143144
|
+
function doChange8(changes, sourceFile, pos, checker) {
|
|
142919
143145
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
142920
143146
|
if (!isThis(token))
|
|
142921
143147
|
return void 0;
|
|
@@ -142958,26 +143184,26 @@ function doChange6(changes, sourceFile, pos, checker) {
|
|
|
142958
143184
|
}
|
|
142959
143185
|
|
|
142960
143186
|
// src/services/codefixes/fixImportNonExportedMember.ts
|
|
142961
|
-
var
|
|
142962
|
-
var
|
|
143187
|
+
var fixId20 = "fixImportNonExportedMember";
|
|
143188
|
+
var errorCodes23 = [
|
|
142963
143189
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
142964
143190
|
];
|
|
142965
143191
|
registerCodeFix({
|
|
142966
|
-
errorCodes:
|
|
142967
|
-
fixIds: [
|
|
143192
|
+
errorCodes: errorCodes23,
|
|
143193
|
+
fixIds: [fixId20],
|
|
142968
143194
|
getCodeActions(context) {
|
|
142969
143195
|
const { sourceFile, span, program } = context;
|
|
142970
143196
|
const info = getInfo4(sourceFile, span.start, program);
|
|
142971
143197
|
if (info === void 0)
|
|
142972
143198
|
return void 0;
|
|
142973
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
142974
|
-
return [createCodeFixAction(
|
|
143199
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange9(t, program, info));
|
|
143200
|
+
return [createCodeFixAction(fixId20, changes, [Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId20, Diagnostics.Export_all_referenced_locals)];
|
|
142975
143201
|
},
|
|
142976
143202
|
getAllCodeActions(context) {
|
|
142977
143203
|
const { program } = context;
|
|
142978
143204
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142979
143205
|
const exports = /* @__PURE__ */ new Map();
|
|
142980
|
-
eachDiagnostic(context,
|
|
143206
|
+
eachDiagnostic(context, errorCodes23, (diag2) => {
|
|
142981
143207
|
const info = getInfo4(diag2.file, diag2.start, program);
|
|
142982
143208
|
if (info === void 0)
|
|
142983
143209
|
return void 0;
|
|
@@ -143050,7 +143276,7 @@ function getInfo4(sourceFile, pos, program) {
|
|
|
143050
143276
|
}
|
|
143051
143277
|
return void 0;
|
|
143052
143278
|
}
|
|
143053
|
-
function
|
|
143279
|
+
function doChange9(changes, program, { exportName, node, moduleSourceFile }) {
|
|
143054
143280
|
const exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
143055
143281
|
if (exportDeclaration) {
|
|
143056
143282
|
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
@@ -143134,26 +143360,26 @@ function getNodeOfSymbol(symbol) {
|
|
|
143134
143360
|
}
|
|
143135
143361
|
|
|
143136
143362
|
// src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
|
|
143137
|
-
var
|
|
143138
|
-
var
|
|
143363
|
+
var fixId21 = "fixIncorrectNamedTupleSyntax";
|
|
143364
|
+
var errorCodes24 = [
|
|
143139
143365
|
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
143366
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
143141
143367
|
];
|
|
143142
143368
|
registerCodeFix({
|
|
143143
|
-
errorCodes:
|
|
143369
|
+
errorCodes: errorCodes24,
|
|
143144
143370
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
143145
143371
|
const { sourceFile, span } = context;
|
|
143146
143372
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
143147
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143148
|
-
return [createCodeFixAction(
|
|
143373
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange10(t, sourceFile, namedTupleMember));
|
|
143374
|
+
return [createCodeFixAction(fixId21, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId21, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
143149
143375
|
},
|
|
143150
|
-
fixIds: [
|
|
143376
|
+
fixIds: [fixId21]
|
|
143151
143377
|
});
|
|
143152
143378
|
function getNamedTupleMember(sourceFile, pos) {
|
|
143153
143379
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
143154
143380
|
return findAncestor(token, (t) => t.kind === 199 /* NamedTupleMember */);
|
|
143155
143381
|
}
|
|
143156
|
-
function
|
|
143382
|
+
function doChange10(changes, sourceFile, namedTupleMember) {
|
|
143157
143383
|
if (!namedTupleMember) {
|
|
143158
143384
|
return;
|
|
143159
143385
|
}
|
|
@@ -143182,8 +143408,8 @@ function doChange8(changes, sourceFile, namedTupleMember) {
|
|
|
143182
143408
|
}
|
|
143183
143409
|
|
|
143184
143410
|
// src/services/codefixes/fixSpelling.ts
|
|
143185
|
-
var
|
|
143186
|
-
var
|
|
143411
|
+
var fixId22 = "fixSpelling";
|
|
143412
|
+
var errorCodes25 = [
|
|
143187
143413
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143188
143414
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143189
143415
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -143200,7 +143426,7 @@ var errorCodes24 = [
|
|
|
143200
143426
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
143201
143427
|
];
|
|
143202
143428
|
registerCodeFix({
|
|
143203
|
-
errorCodes:
|
|
143429
|
+
errorCodes: errorCodes25,
|
|
143204
143430
|
getCodeActions(context) {
|
|
143205
143431
|
const { sourceFile, errorCode } = context;
|
|
143206
143432
|
const info = getInfo5(sourceFile, context.span.start, context, errorCode);
|
|
@@ -143208,15 +143434,15 @@ registerCodeFix({
|
|
|
143208
143434
|
return void 0;
|
|
143209
143435
|
const { node, suggestedSymbol } = info;
|
|
143210
143436
|
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)],
|
|
143437
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, sourceFile, node, suggestedSymbol, target));
|
|
143438
|
+
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId22, Diagnostics.Fix_all_detected_spelling_errors)];
|
|
143213
143439
|
},
|
|
143214
|
-
fixIds: [
|
|
143215
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143440
|
+
fixIds: [fixId22],
|
|
143441
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes25, (changes, diag2) => {
|
|
143216
143442
|
const info = getInfo5(diag2.file, diag2.start, context, diag2.code);
|
|
143217
143443
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
143218
143444
|
if (info)
|
|
143219
|
-
|
|
143445
|
+
doChange11(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
143220
143446
|
})
|
|
143221
143447
|
});
|
|
143222
143448
|
function getInfo5(sourceFile, pos, context, errorCode) {
|
|
@@ -143268,7 +143494,7 @@ function getInfo5(sourceFile, pos, context, errorCode) {
|
|
|
143268
143494
|
}
|
|
143269
143495
|
return suggestedSymbol === void 0 ? void 0 : { node, suggestedSymbol };
|
|
143270
143496
|
}
|
|
143271
|
-
function
|
|
143497
|
+
function doChange11(changes, sourceFile, node, suggestedSymbol, target) {
|
|
143272
143498
|
const suggestion = symbolName(suggestedSymbol);
|
|
143273
143499
|
if (!isIdentifierText(suggestion, target) && isPropertyAccessExpression(node.parent)) {
|
|
143274
143500
|
const valDecl = suggestedSymbol.valueDeclaration;
|
|
@@ -143304,17 +143530,17 @@ function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importD
|
|
|
143304
143530
|
}
|
|
143305
143531
|
|
|
143306
143532
|
// src/services/codefixes/returnValueCorrect.ts
|
|
143307
|
-
var
|
|
143533
|
+
var fixId23 = "returnValueCorrect";
|
|
143308
143534
|
var fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
143309
143535
|
var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
143310
143536
|
var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
143311
|
-
var
|
|
143537
|
+
var errorCodes26 = [
|
|
143312
143538
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
143313
143539
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
143314
143540
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
143315
143541
|
];
|
|
143316
143542
|
registerCodeFix({
|
|
143317
|
-
errorCodes:
|
|
143543
|
+
errorCodes: errorCodes26,
|
|
143318
143544
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
143319
143545
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
143320
143546
|
const { program, sourceFile, span: { start: start2 }, errorCode } = context;
|
|
@@ -143330,7 +143556,7 @@ registerCodeFix({
|
|
|
143330
143556
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
143331
143557
|
}
|
|
143332
143558
|
},
|
|
143333
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143559
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
143334
143560
|
const info = getInfo6(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
143335
143561
|
if (!info)
|
|
143336
143562
|
return void 0;
|
|
@@ -143538,7 +143764,7 @@ function wrapBlockWithParen(changes, sourceFile, declaration, expression) {
|
|
|
143538
143764
|
}
|
|
143539
143765
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
143540
143766
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
143541
|
-
return createCodeFixAction(
|
|
143767
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
143542
143768
|
}
|
|
143543
143769
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
143544
143770
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -143550,11 +143776,11 @@ function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration,
|
|
|
143550
143776
|
/* withParen */
|
|
143551
143777
|
false
|
|
143552
143778
|
));
|
|
143553
|
-
return createCodeFixAction(
|
|
143779
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
|
143554
143780
|
}
|
|
143555
143781
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
143556
143782
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
143557
|
-
return createCodeFixAction(
|
|
143783
|
+
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
143784
|
}
|
|
143559
143785
|
|
|
143560
143786
|
// src/services/codefixes/fixAddMissingMember.ts
|
|
@@ -143562,7 +143788,7 @@ var fixMissingMember = "fixMissingMember";
|
|
|
143562
143788
|
var fixMissingProperties = "fixMissingProperties";
|
|
143563
143789
|
var fixMissingAttributes = "fixMissingAttributes";
|
|
143564
143790
|
var fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
143565
|
-
var
|
|
143791
|
+
var errorCodes27 = [
|
|
143566
143792
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
143567
143793
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
143568
143794
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -143572,7 +143798,7 @@ var errorCodes26 = [
|
|
|
143572
143798
|
Diagnostics.Cannot_find_name_0.code
|
|
143573
143799
|
];
|
|
143574
143800
|
registerCodeFix({
|
|
143575
|
-
errorCodes:
|
|
143801
|
+
errorCodes: errorCodes27,
|
|
143576
143802
|
getCodeActions(context) {
|
|
143577
143803
|
const typeChecker = context.program.getTypeChecker();
|
|
143578
143804
|
const info = getInfo7(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -143599,21 +143825,21 @@ registerCodeFix({
|
|
|
143599
143825
|
},
|
|
143600
143826
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
143601
143827
|
getAllCodeActions: (context) => {
|
|
143602
|
-
const { program, fixId:
|
|
143828
|
+
const { program, fixId: fixId52 } = context;
|
|
143603
143829
|
const checker = program.getTypeChecker();
|
|
143604
143830
|
const seen = /* @__PURE__ */ new Map();
|
|
143605
143831
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
143606
143832
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
143607
|
-
eachDiagnostic(context,
|
|
143833
|
+
eachDiagnostic(context, errorCodes27, (diag2) => {
|
|
143608
143834
|
const info = getInfo7(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
143609
143835
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
|
|
143610
143836
|
return;
|
|
143611
143837
|
}
|
|
143612
|
-
if (
|
|
143838
|
+
if (fixId52 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
143613
143839
|
addFunctionDeclaration(changes, context, info);
|
|
143614
|
-
} else if (
|
|
143840
|
+
} else if (fixId52 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
143615
143841
|
addObjectLiteralProperties(changes, context, info);
|
|
143616
|
-
} else if (
|
|
143842
|
+
} else if (fixId52 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
143617
143843
|
addJsxAttributes(changes, context, info);
|
|
143618
143844
|
} else {
|
|
143619
143845
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -144185,17 +144411,17 @@ function findScope(node) {
|
|
|
144185
144411
|
}
|
|
144186
144412
|
|
|
144187
144413
|
// src/services/codefixes/fixAddMissingNewOperator.ts
|
|
144188
|
-
var
|
|
144189
|
-
var
|
|
144414
|
+
var fixId24 = "addMissingNewOperator";
|
|
144415
|
+
var errorCodes28 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
144190
144416
|
registerCodeFix({
|
|
144191
|
-
errorCodes:
|
|
144417
|
+
errorCodes: errorCodes28,
|
|
144192
144418
|
getCodeActions(context) {
|
|
144193
144419
|
const { sourceFile, span } = context;
|
|
144194
144420
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
144195
|
-
return [createCodeFixAction(
|
|
144421
|
+
return [createCodeFixAction(fixId24, changes, Diagnostics.Add_missing_new_operator_to_call, fixId24, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
144196
144422
|
},
|
|
144197
|
-
fixIds: [
|
|
144198
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144423
|
+
fixIds: [fixId24],
|
|
144424
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes28, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
144199
144425
|
});
|
|
144200
144426
|
function addMissingNewOperator(changes, sourceFile, span) {
|
|
144201
144427
|
const call = cast(findAncestorMatchingSpan2(sourceFile, span), isCallExpression);
|
|
@@ -144215,12 +144441,12 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
144215
144441
|
var fixName2 = "fixCannotFindModule";
|
|
144216
144442
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
144217
144443
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
144218
|
-
var
|
|
144444
|
+
var errorCodes29 = [
|
|
144219
144445
|
errorCodeCannotFindModule,
|
|
144220
144446
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
144221
144447
|
];
|
|
144222
144448
|
registerCodeFix({
|
|
144223
|
-
errorCodes:
|
|
144449
|
+
errorCodes: errorCodes29,
|
|
144224
144450
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
144225
144451
|
const { host, sourceFile, span: { start: start2 } } = context;
|
|
144226
144452
|
const packageName = tryGetImportedPackageName(sourceFile, start2);
|
|
@@ -144239,7 +144465,7 @@ registerCodeFix({
|
|
|
144239
144465
|
},
|
|
144240
144466
|
fixIds: [fixIdInstallTypesPackage],
|
|
144241
144467
|
getAllCodeActions: (context) => {
|
|
144242
|
-
return codeFixAll(context,
|
|
144468
|
+
return codeFixAll(context, errorCodes29, (_changes, diag2, commands) => {
|
|
144243
144469
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
144244
144470
|
if (packageName === void 0)
|
|
144245
144471
|
return void 0;
|
|
@@ -144274,22 +144500,22 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
144274
144500
|
}
|
|
144275
144501
|
|
|
144276
144502
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
144277
|
-
var
|
|
144503
|
+
var errorCodes30 = [
|
|
144278
144504
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
144279
144505
|
Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code
|
|
144280
144506
|
];
|
|
144281
|
-
var
|
|
144507
|
+
var fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
144282
144508
|
registerCodeFix({
|
|
144283
|
-
errorCodes:
|
|
144509
|
+
errorCodes: errorCodes30,
|
|
144284
144510
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
144285
144511
|
const { sourceFile, span } = context;
|
|
144286
144512
|
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(
|
|
144513
|
+
return changes.length === 0 ? void 0 : [createCodeFixAction(fixId25, changes, Diagnostics.Implement_inherited_abstract_class, fixId25, Diagnostics.Implement_all_inherited_abstract_classes)];
|
|
144288
144514
|
},
|
|
144289
|
-
fixIds: [
|
|
144515
|
+
fixIds: [fixId25],
|
|
144290
144516
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
144291
144517
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
144292
|
-
return codeFixAll(context,
|
|
144518
|
+
return codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
144293
144519
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
144294
144520
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
144295
144521
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -144316,35 +144542,35 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
144316
144542
|
}
|
|
144317
144543
|
|
|
144318
144544
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
144319
|
-
var
|
|
144320
|
-
var
|
|
144545
|
+
var fixId26 = "classSuperMustPrecedeThisAccess";
|
|
144546
|
+
var errorCodes31 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
144321
144547
|
registerCodeFix({
|
|
144322
|
-
errorCodes:
|
|
144548
|
+
errorCodes: errorCodes31,
|
|
144323
144549
|
getCodeActions(context) {
|
|
144324
144550
|
const { sourceFile, span } = context;
|
|
144325
144551
|
const nodes = getNodes(sourceFile, span.start);
|
|
144326
144552
|
if (!nodes)
|
|
144327
144553
|
return void 0;
|
|
144328
144554
|
const { constructor, superCall } = nodes;
|
|
144329
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144330
|
-
return [createCodeFixAction(
|
|
144555
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, sourceFile, constructor, superCall));
|
|
144556
|
+
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
144557
|
},
|
|
144332
|
-
fixIds: [
|
|
144558
|
+
fixIds: [fixId26],
|
|
144333
144559
|
getAllCodeActions(context) {
|
|
144334
144560
|
const { sourceFile } = context;
|
|
144335
144561
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
144336
|
-
return codeFixAll(context,
|
|
144562
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
144337
144563
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
144338
144564
|
if (!nodes)
|
|
144339
144565
|
return;
|
|
144340
144566
|
const { constructor, superCall } = nodes;
|
|
144341
144567
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
144342
|
-
|
|
144568
|
+
doChange12(changes, sourceFile, constructor, superCall);
|
|
144343
144569
|
}
|
|
144344
144570
|
});
|
|
144345
144571
|
}
|
|
144346
144572
|
});
|
|
144347
|
-
function
|
|
144573
|
+
function doChange12(changes, sourceFile, constructor, superCall) {
|
|
144348
144574
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
144349
144575
|
changes.delete(sourceFile, superCall);
|
|
144350
144576
|
}
|
|
@@ -144361,25 +144587,25 @@ function findSuperCall(n) {
|
|
|
144361
144587
|
}
|
|
144362
144588
|
|
|
144363
144589
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
144364
|
-
var
|
|
144365
|
-
var
|
|
144590
|
+
var fixId27 = "constructorForDerivedNeedSuperCall";
|
|
144591
|
+
var errorCodes32 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
144366
144592
|
registerCodeFix({
|
|
144367
|
-
errorCodes:
|
|
144593
|
+
errorCodes: errorCodes32,
|
|
144368
144594
|
getCodeActions(context) {
|
|
144369
144595
|
const { sourceFile, span } = context;
|
|
144370
144596
|
const ctr = getNode(sourceFile, span.start);
|
|
144371
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144372
|
-
return [createCodeFixAction(
|
|
144597
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange13(t, sourceFile, ctr));
|
|
144598
|
+
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
144373
144599
|
},
|
|
144374
|
-
fixIds: [
|
|
144375
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144600
|
+
fixIds: [fixId27],
|
|
144601
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes32, (changes, diag2) => doChange13(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
144376
144602
|
});
|
|
144377
144603
|
function getNode(sourceFile, pos) {
|
|
144378
144604
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
144379
144605
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
144380
144606
|
return token.parent;
|
|
144381
144607
|
}
|
|
144382
|
-
function
|
|
144608
|
+
function doChange13(changes, sourceFile, ctr) {
|
|
144383
144609
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
144384
144610
|
factory.createSuper(),
|
|
144385
144611
|
/*typeArguments*/
|
|
@@ -144392,9 +144618,9 @@ function doChange11(changes, sourceFile, ctr) {
|
|
|
144392
144618
|
|
|
144393
144619
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
144394
144620
|
var fixID = "fixEnableJsxFlag";
|
|
144395
|
-
var
|
|
144621
|
+
var errorCodes33 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
144396
144622
|
registerCodeFix({
|
|
144397
|
-
errorCodes:
|
|
144623
|
+
errorCodes: errorCodes33,
|
|
144398
144624
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
144399
144625
|
const { configFile } = context.program.getCompilerOptions();
|
|
144400
144626
|
if (configFile === void 0) {
|
|
@@ -144402,47 +144628,47 @@ registerCodeFix({
|
|
|
144402
144628
|
}
|
|
144403
144629
|
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
144404
144630
|
context,
|
|
144405
|
-
(changeTracker) =>
|
|
144631
|
+
(changeTracker) => doChange14(changeTracker, configFile)
|
|
144406
144632
|
);
|
|
144407
144633
|
return [
|
|
144408
144634
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
144409
144635
|
];
|
|
144410
144636
|
},
|
|
144411
144637
|
fixIds: [fixID],
|
|
144412
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144638
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes) => {
|
|
144413
144639
|
const { configFile } = context.program.getCompilerOptions();
|
|
144414
144640
|
if (configFile === void 0) {
|
|
144415
144641
|
return void 0;
|
|
144416
144642
|
}
|
|
144417
|
-
|
|
144643
|
+
doChange14(changes, configFile);
|
|
144418
144644
|
})
|
|
144419
144645
|
});
|
|
144420
|
-
function
|
|
144646
|
+
function doChange14(changeTracker, configFile) {
|
|
144421
144647
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
144422
144648
|
}
|
|
144423
144649
|
|
|
144424
144650
|
// src/services/codefixes/fixNaNEquality.ts
|
|
144425
|
-
var
|
|
144426
|
-
var
|
|
144651
|
+
var fixId28 = "fixNaNEquality";
|
|
144652
|
+
var errorCodes34 = [
|
|
144427
144653
|
Diagnostics.This_condition_will_always_return_0.code
|
|
144428
144654
|
];
|
|
144429
144655
|
registerCodeFix({
|
|
144430
|
-
errorCodes:
|
|
144656
|
+
errorCodes: errorCodes34,
|
|
144431
144657
|
getCodeActions(context) {
|
|
144432
144658
|
const { sourceFile, span, program } = context;
|
|
144433
144659
|
const info = getInfo8(program, sourceFile, span);
|
|
144434
144660
|
if (info === void 0)
|
|
144435
144661
|
return;
|
|
144436
144662
|
const { suggestion, expression, arg } = info;
|
|
144437
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144438
|
-
return [createCodeFixAction(
|
|
144663
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange15(t, sourceFile, arg, expression));
|
|
144664
|
+
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
144439
144665
|
},
|
|
144440
|
-
fixIds: [
|
|
144666
|
+
fixIds: [fixId28],
|
|
144441
144667
|
getAllCodeActions: (context) => {
|
|
144442
|
-
return codeFixAll(context,
|
|
144668
|
+
return codeFixAll(context, errorCodes34, (changes, diag2) => {
|
|
144443
144669
|
const info = getInfo8(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
144444
144670
|
if (info) {
|
|
144445
|
-
|
|
144671
|
+
doChange15(changes, diag2.file, info.arg, info.expression);
|
|
144446
144672
|
}
|
|
144447
144673
|
});
|
|
144448
144674
|
}
|
|
@@ -144462,7 +144688,7 @@ function getInfo8(program, sourceFile, span) {
|
|
|
144462
144688
|
}
|
|
144463
144689
|
return void 0;
|
|
144464
144690
|
}
|
|
144465
|
-
function
|
|
144691
|
+
function doChange15(changes, sourceFile, arg, expression) {
|
|
144466
144692
|
const callExpression = factory.createCallExpression(
|
|
144467
144693
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
144468
144694
|
/*typeArguments*/
|
|
@@ -144522,22 +144748,22 @@ registerCodeFix({
|
|
|
144522
144748
|
});
|
|
144523
144749
|
|
|
144524
144750
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
144525
|
-
var
|
|
144526
|
-
var
|
|
144751
|
+
var fixId29 = "fixPropertyAssignment";
|
|
144752
|
+
var errorCodes35 = [
|
|
144527
144753
|
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
144754
|
];
|
|
144529
144755
|
registerCodeFix({
|
|
144530
|
-
errorCodes:
|
|
144531
|
-
fixIds: [
|
|
144756
|
+
errorCodes: errorCodes35,
|
|
144757
|
+
fixIds: [fixId29],
|
|
144532
144758
|
getCodeActions(context) {
|
|
144533
144759
|
const { sourceFile, span } = context;
|
|
144534
144760
|
const property = getProperty2(sourceFile, span.start);
|
|
144535
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144536
|
-
return [createCodeFixAction(
|
|
144761
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, context.sourceFile, property));
|
|
144762
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
144537
144763
|
},
|
|
144538
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144764
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes, diag2) => doChange16(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
144539
144765
|
});
|
|
144540
|
-
function
|
|
144766
|
+
function doChange16(changes, sourceFile, node) {
|
|
144541
144767
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
144542
144768
|
}
|
|
144543
144769
|
function getProperty2(sourceFile, pos) {
|
|
@@ -144545,10 +144771,10 @@ function getProperty2(sourceFile, pos) {
|
|
|
144545
144771
|
}
|
|
144546
144772
|
|
|
144547
144773
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
144548
|
-
var
|
|
144549
|
-
var
|
|
144774
|
+
var fixId30 = "extendsInterfaceBecomesImplements";
|
|
144775
|
+
var errorCodes36 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
144550
144776
|
registerCodeFix({
|
|
144551
|
-
errorCodes:
|
|
144777
|
+
errorCodes: errorCodes36,
|
|
144552
144778
|
getCodeActions(context) {
|
|
144553
144779
|
const { sourceFile } = context;
|
|
144554
144780
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -144556,10 +144782,10 @@ registerCodeFix({
|
|
|
144556
144782
|
return void 0;
|
|
144557
144783
|
const { extendsToken, heritageClauses } = nodes;
|
|
144558
144784
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
144559
|
-
return [createCodeFixAction(
|
|
144785
|
+
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
144560
144786
|
},
|
|
144561
|
-
fixIds: [
|
|
144562
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144787
|
+
fixIds: [fixId30],
|
|
144788
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
144563
144789
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
144564
144790
|
if (nodes)
|
|
144565
144791
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -144587,29 +144813,29 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
144587
144813
|
}
|
|
144588
144814
|
|
|
144589
144815
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
144590
|
-
var
|
|
144816
|
+
var fixId31 = "forgottenThisPropertyAccess";
|
|
144591
144817
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
144592
|
-
var
|
|
144818
|
+
var errorCodes37 = [
|
|
144593
144819
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
144594
144820
|
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
144821
|
didYouMeanStaticMemberCode
|
|
144596
144822
|
];
|
|
144597
144823
|
registerCodeFix({
|
|
144598
|
-
errorCodes:
|
|
144824
|
+
errorCodes: errorCodes37,
|
|
144599
144825
|
getCodeActions(context) {
|
|
144600
144826
|
const { sourceFile } = context;
|
|
144601
144827
|
const info = getInfo9(sourceFile, context.span.start, context.errorCode);
|
|
144602
144828
|
if (!info) {
|
|
144603
144829
|
return void 0;
|
|
144604
144830
|
}
|
|
144605
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144606
|
-
return [createCodeFixAction(
|
|
144831
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, info));
|
|
144832
|
+
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
144833
|
},
|
|
144608
|
-
fixIds: [
|
|
144609
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144834
|
+
fixIds: [fixId31],
|
|
144835
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
144610
144836
|
const info = getInfo9(diag2.file, diag2.start, diag2.code);
|
|
144611
144837
|
if (info)
|
|
144612
|
-
|
|
144838
|
+
doChange17(changes, context.sourceFile, info);
|
|
144613
144839
|
})
|
|
144614
144840
|
});
|
|
144615
144841
|
function getInfo9(sourceFile, pos, diagCode) {
|
|
@@ -144618,7 +144844,7 @@ function getInfo9(sourceFile, pos, diagCode) {
|
|
|
144618
144844
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
144619
144845
|
}
|
|
144620
144846
|
}
|
|
144621
|
-
function
|
|
144847
|
+
function doChange17(changes, sourceFile, { node, className }) {
|
|
144622
144848
|
suppressLeadingAndTrailingTrivia(node);
|
|
144623
144849
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
144624
144850
|
}
|
|
@@ -144626,16 +144852,16 @@ function doChange15(changes, sourceFile, { node, className }) {
|
|
|
144626
144852
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
144627
144853
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
144628
144854
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
144629
|
-
var
|
|
144855
|
+
var errorCodes38 = [
|
|
144630
144856
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
144631
144857
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
144632
144858
|
];
|
|
144633
144859
|
registerCodeFix({
|
|
144634
|
-
errorCodes:
|
|
144860
|
+
errorCodes: errorCodes38,
|
|
144635
144861
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
144636
144862
|
getCodeActions(context) {
|
|
144637
144863
|
const { sourceFile, preferences, span } = context;
|
|
144638
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144864
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
144639
144865
|
t,
|
|
144640
144866
|
preferences,
|
|
144641
144867
|
sourceFile,
|
|
@@ -144643,7 +144869,7 @@ registerCodeFix({
|
|
|
144643
144869
|
/* useHtmlEntity */
|
|
144644
144870
|
false
|
|
144645
144871
|
));
|
|
144646
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144872
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
144647
144873
|
t,
|
|
144648
144874
|
preferences,
|
|
144649
144875
|
sourceFile,
|
|
@@ -144657,7 +144883,7 @@ registerCodeFix({
|
|
|
144657
144883
|
];
|
|
144658
144884
|
},
|
|
144659
144885
|
getAllCodeActions(context) {
|
|
144660
|
-
return codeFixAll(context,
|
|
144886
|
+
return codeFixAll(context, errorCodes38, (changes, diagnostic) => doChange18(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
144661
144887
|
}
|
|
144662
144888
|
});
|
|
144663
144889
|
var htmlEntity = {
|
|
@@ -144667,7 +144893,7 @@ var htmlEntity = {
|
|
|
144667
144893
|
function isValidCharacter(character) {
|
|
144668
144894
|
return hasProperty(htmlEntity, character);
|
|
144669
144895
|
}
|
|
144670
|
-
function
|
|
144896
|
+
function doChange18(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
144671
144897
|
const character = sourceFile.getText()[start2];
|
|
144672
144898
|
if (!isValidCharacter(character)) {
|
|
144673
144899
|
return;
|
|
@@ -144679,12 +144905,12 @@ function doChange16(changes, preferences, sourceFile, start2, useHtmlEntity) {
|
|
|
144679
144905
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
144680
144906
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
144681
144907
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
144682
|
-
var
|
|
144908
|
+
var errorCodes39 = [
|
|
144683
144909
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
144684
144910
|
];
|
|
144685
144911
|
registerCodeFix({
|
|
144686
144912
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
144687
|
-
errorCodes:
|
|
144913
|
+
errorCodes: errorCodes39,
|
|
144688
144914
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
144689
144915
|
const { sourceFile, span } = context;
|
|
144690
144916
|
const actions2 = [];
|
|
@@ -144699,7 +144925,7 @@ registerCodeFix({
|
|
|
144699
144925
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
144700
144926
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
144701
144927
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
144702
|
-
eachDiagnostic(context,
|
|
144928
|
+
eachDiagnostic(context, errorCodes39, ({ file, start: start2 }) => {
|
|
144703
144929
|
const info = getInfo10(file, start2);
|
|
144704
144930
|
if (info) {
|
|
144705
144931
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -144764,10 +144990,10 @@ function getInfo10(sourceFile, pos) {
|
|
|
144764
144990
|
}
|
|
144765
144991
|
|
|
144766
144992
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
144767
|
-
var
|
|
144768
|
-
var
|
|
144993
|
+
var fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
144994
|
+
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
144995
|
registerCodeFix({
|
|
144770
|
-
errorCodes:
|
|
144996
|
+
errorCodes: errorCodes40,
|
|
144771
144997
|
getCodeActions: (context) => {
|
|
144772
144998
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
144773
144999
|
if (!importDeclaration)
|
|
@@ -144776,14 +145002,14 @@ registerCodeFix({
|
|
|
144776
145002
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
144777
145003
|
let actions2;
|
|
144778
145004
|
if (namespaceChanges.length) {
|
|
144779
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
145005
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
144780
145006
|
}
|
|
144781
145007
|
if (typeOnlyChanges.length) {
|
|
144782
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
145008
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
144783
145009
|
}
|
|
144784
145010
|
return actions2;
|
|
144785
145011
|
},
|
|
144786
|
-
fixIds: [
|
|
145012
|
+
fixIds: [fixId32]
|
|
144787
145013
|
});
|
|
144788
145014
|
function getImportDeclaration(sourceFile, program, start2) {
|
|
144789
145015
|
const identifier = tryCast(getTokenAtPosition(sourceFile, start2), isIdentifier);
|
|
@@ -144822,7 +145048,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
144822
145048
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
144823
145049
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
144824
145050
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
144825
|
-
var
|
|
145051
|
+
var errorCodes41 = [
|
|
144826
145052
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
144827
145053
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
144828
145054
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -144832,7 +145058,7 @@ var errorCodes40 = [
|
|
|
144832
145058
|
Diagnostics.All_type_parameters_are_unused.code
|
|
144833
145059
|
];
|
|
144834
145060
|
registerCodeFix({
|
|
144835
|
-
errorCodes:
|
|
145061
|
+
errorCodes: errorCodes41,
|
|
144836
145062
|
getCodeActions(context) {
|
|
144837
145063
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
144838
145064
|
const checker = program.getTypeChecker();
|
|
@@ -144918,7 +145144,7 @@ registerCodeFix({
|
|
|
144918
145144
|
const { sourceFile, program, cancellationToken } = context;
|
|
144919
145145
|
const checker = program.getTypeChecker();
|
|
144920
145146
|
const sourceFiles = program.getSourceFiles();
|
|
144921
|
-
return codeFixAll(context,
|
|
145147
|
+
return codeFixAll(context, errorCodes41, (changes, diag2) => {
|
|
144922
145148
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
144923
145149
|
switch (context.fixId) {
|
|
144924
145150
|
case fixIdPrefix:
|
|
@@ -145135,21 +145361,21 @@ function mayDeleteExpression(node) {
|
|
|
145135
145361
|
}
|
|
145136
145362
|
|
|
145137
145363
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
145138
|
-
var
|
|
145139
|
-
var
|
|
145364
|
+
var fixId33 = "fixUnreachableCode";
|
|
145365
|
+
var errorCodes42 = [Diagnostics.Unreachable_code_detected.code];
|
|
145140
145366
|
registerCodeFix({
|
|
145141
|
-
errorCodes:
|
|
145367
|
+
errorCodes: errorCodes42,
|
|
145142
145368
|
getCodeActions(context) {
|
|
145143
145369
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
145144
145370
|
if (syntacticDiagnostics.length)
|
|
145145
145371
|
return;
|
|
145146
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145147
|
-
return [createCodeFixAction(
|
|
145372
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
145373
|
+
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
145148
145374
|
},
|
|
145149
|
-
fixIds: [
|
|
145150
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145375
|
+
fixIds: [fixId33],
|
|
145376
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes42, (changes, diag2) => doChange19(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
145151
145377
|
});
|
|
145152
|
-
function
|
|
145378
|
+
function doChange19(changes, sourceFile, start2, length2, errorCode) {
|
|
145153
145379
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145154
145380
|
const statement = findAncestor(token, isStatement);
|
|
145155
145381
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -145199,18 +145425,18 @@ function lastWhere(a, pred) {
|
|
|
145199
145425
|
}
|
|
145200
145426
|
|
|
145201
145427
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
145202
|
-
var
|
|
145203
|
-
var
|
|
145428
|
+
var fixId34 = "fixUnusedLabel";
|
|
145429
|
+
var errorCodes43 = [Diagnostics.Unused_label.code];
|
|
145204
145430
|
registerCodeFix({
|
|
145205
|
-
errorCodes:
|
|
145431
|
+
errorCodes: errorCodes43,
|
|
145206
145432
|
getCodeActions(context) {
|
|
145207
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145208
|
-
return [createCodeFixAction(
|
|
145433
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, context.sourceFile, context.span.start));
|
|
145434
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
145209
145435
|
},
|
|
145210
|
-
fixIds: [
|
|
145211
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145436
|
+
fixIds: [fixId34],
|
|
145437
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange20(changes, diag2.file, diag2.start))
|
|
145212
145438
|
});
|
|
145213
|
-
function
|
|
145439
|
+
function doChange20(changes, sourceFile, start2) {
|
|
145214
145440
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145215
145441
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
145216
145442
|
const pos = token.getStart(sourceFile);
|
|
@@ -145227,13 +145453,13 @@ function doChange18(changes, sourceFile, start2) {
|
|
|
145227
145453
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
145228
145454
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
145229
145455
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
145230
|
-
var
|
|
145456
|
+
var errorCodes44 = [
|
|
145231
145457
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
145232
145458
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
145233
145459
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
145234
145460
|
];
|
|
145235
145461
|
registerCodeFix({
|
|
145236
|
-
errorCodes:
|
|
145462
|
+
errorCodes: errorCodes44,
|
|
145237
145463
|
getCodeActions(context) {
|
|
145238
145464
|
const { sourceFile } = context;
|
|
145239
145465
|
const checker = context.program.getTypeChecker();
|
|
@@ -145247,26 +145473,26 @@ registerCodeFix({
|
|
|
145247
145473
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
145248
145474
|
}
|
|
145249
145475
|
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)],
|
|
145476
|
+
function fix(type2, fixId52, fixAllDescription) {
|
|
145477
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, typeNode, type2, checker));
|
|
145478
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
145253
145479
|
}
|
|
145254
145480
|
},
|
|
145255
145481
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
145256
145482
|
getAllCodeActions(context) {
|
|
145257
|
-
const { fixId:
|
|
145483
|
+
const { fixId: fixId52, program, sourceFile } = context;
|
|
145258
145484
|
const checker = program.getTypeChecker();
|
|
145259
|
-
return codeFixAll(context,
|
|
145485
|
+
return codeFixAll(context, errorCodes44, (changes, err) => {
|
|
145260
145486
|
const info = getInfo11(err.file, err.start, checker);
|
|
145261
145487
|
if (!info)
|
|
145262
145488
|
return;
|
|
145263
145489
|
const { typeNode, type } = info;
|
|
145264
|
-
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ &&
|
|
145265
|
-
|
|
145490
|
+
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
145491
|
+
doChange21(changes, sourceFile, typeNode, fixedType, checker);
|
|
145266
145492
|
});
|
|
145267
145493
|
}
|
|
145268
145494
|
});
|
|
145269
|
-
function
|
|
145495
|
+
function doChange21(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
145270
145496
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
145271
145497
|
newType,
|
|
145272
145498
|
/*enclosingDeclaration*/
|
|
@@ -145317,28 +145543,28 @@ function getType(checker, node) {
|
|
|
145317
145543
|
}
|
|
145318
145544
|
|
|
145319
145545
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
145320
|
-
var
|
|
145321
|
-
var
|
|
145546
|
+
var fixId35 = "fixMissingCallParentheses";
|
|
145547
|
+
var errorCodes45 = [
|
|
145322
145548
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
145323
145549
|
];
|
|
145324
145550
|
registerCodeFix({
|
|
145325
|
-
errorCodes:
|
|
145326
|
-
fixIds: [
|
|
145551
|
+
errorCodes: errorCodes45,
|
|
145552
|
+
fixIds: [fixId35],
|
|
145327
145553
|
getCodeActions(context) {
|
|
145328
145554
|
const { sourceFile, span } = context;
|
|
145329
145555
|
const callName = getCallName(sourceFile, span.start);
|
|
145330
145556
|
if (!callName)
|
|
145331
145557
|
return;
|
|
145332
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145333
|
-
return [createCodeFixAction(
|
|
145558
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange22(t, context.sourceFile, callName));
|
|
145559
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
145334
145560
|
},
|
|
145335
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145561
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => {
|
|
145336
145562
|
const callName = getCallName(diag2.file, diag2.start);
|
|
145337
145563
|
if (callName)
|
|
145338
|
-
|
|
145564
|
+
doChange22(changes, diag2.file, callName);
|
|
145339
145565
|
})
|
|
145340
145566
|
});
|
|
145341
|
-
function
|
|
145567
|
+
function doChange22(changes, sourceFile, name) {
|
|
145342
145568
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
145343
145569
|
}
|
|
145344
145570
|
function getCallName(sourceFile, start2) {
|
|
@@ -145357,30 +145583,30 @@ function getCallName(sourceFile, start2) {
|
|
|
145357
145583
|
}
|
|
145358
145584
|
|
|
145359
145585
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
145360
|
-
var
|
|
145361
|
-
var
|
|
145586
|
+
var fixId36 = "fixAwaitInSyncFunction";
|
|
145587
|
+
var errorCodes46 = [
|
|
145362
145588
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
145363
145589
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
145364
145590
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
145365
145591
|
];
|
|
145366
145592
|
registerCodeFix({
|
|
145367
|
-
errorCodes:
|
|
145593
|
+
errorCodes: errorCodes46,
|
|
145368
145594
|
getCodeActions(context) {
|
|
145369
145595
|
const { sourceFile, span } = context;
|
|
145370
145596
|
const nodes = getNodes3(sourceFile, span.start);
|
|
145371
145597
|
if (!nodes)
|
|
145372
145598
|
return void 0;
|
|
145373
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145374
|
-
return [createCodeFixAction(
|
|
145599
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, nodes));
|
|
145600
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
145375
145601
|
},
|
|
145376
|
-
fixIds: [
|
|
145602
|
+
fixIds: [fixId36],
|
|
145377
145603
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
145378
145604
|
const seen = /* @__PURE__ */ new Map();
|
|
145379
|
-
return codeFixAll(context,
|
|
145605
|
+
return codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
145380
145606
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
145381
145607
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
145382
145608
|
return;
|
|
145383
|
-
|
|
145609
|
+
doChange23(changes, context.sourceFile, nodes);
|
|
145384
145610
|
});
|
|
145385
145611
|
}
|
|
145386
145612
|
});
|
|
@@ -145419,7 +145645,7 @@ function getNodes3(sourceFile, start2) {
|
|
|
145419
145645
|
returnType: getReturnType(containingFunction)
|
|
145420
145646
|
};
|
|
145421
145647
|
}
|
|
145422
|
-
function
|
|
145648
|
+
function doChange23(changes, sourceFile, { insertBefore, returnType }) {
|
|
145423
145649
|
if (returnType) {
|
|
145424
145650
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
145425
145651
|
if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -145430,22 +145656,22 @@ function doChange21(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
145430
145656
|
}
|
|
145431
145657
|
|
|
145432
145658
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
145433
|
-
var
|
|
145659
|
+
var errorCodes47 = [
|
|
145434
145660
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
145435
145661
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
145436
145662
|
];
|
|
145437
|
-
var
|
|
145663
|
+
var fixId37 = "fixPropertyOverrideAccessor";
|
|
145438
145664
|
registerCodeFix({
|
|
145439
|
-
errorCodes:
|
|
145665
|
+
errorCodes: errorCodes47,
|
|
145440
145666
|
getCodeActions(context) {
|
|
145441
|
-
const edits =
|
|
145667
|
+
const edits = doChange24(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
145442
145668
|
if (edits) {
|
|
145443
|
-
return [createCodeFixAction(
|
|
145669
|
+
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
145444
145670
|
}
|
|
145445
145671
|
},
|
|
145446
|
-
fixIds: [
|
|
145447
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145448
|
-
const edits =
|
|
145672
|
+
fixIds: [fixId37],
|
|
145673
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
145674
|
+
const edits = doChange24(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
145449
145675
|
if (edits) {
|
|
145450
145676
|
for (const edit of edits) {
|
|
145451
145677
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -145453,7 +145679,7 @@ registerCodeFix({
|
|
|
145453
145679
|
}
|
|
145454
145680
|
})
|
|
145455
145681
|
});
|
|
145456
|
-
function
|
|
145682
|
+
function doChange24(file, start2, length2, code, context) {
|
|
145457
145683
|
let startPosition;
|
|
145458
145684
|
let endPosition;
|
|
145459
145685
|
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 +145708,8 @@ function doChange22(file, start2, length2, code, context) {
|
|
|
145482
145708
|
}
|
|
145483
145709
|
|
|
145484
145710
|
// src/services/codefixes/inferFromUsage.ts
|
|
145485
|
-
var
|
|
145486
|
-
var
|
|
145711
|
+
var fixId38 = "inferFromUsage";
|
|
145712
|
+
var errorCodes48 = [
|
|
145487
145713
|
// Variable declarations
|
|
145488
145714
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
145489
145715
|
// Variable uses
|
|
@@ -145517,13 +145743,13 @@ var errorCodes47 = [
|
|
|
145517
145743
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
145518
145744
|
];
|
|
145519
145745
|
registerCodeFix({
|
|
145520
|
-
errorCodes:
|
|
145746
|
+
errorCodes: errorCodes48,
|
|
145521
145747
|
getCodeActions(context) {
|
|
145522
145748
|
const { sourceFile, program, span: { start: start2 }, errorCode, cancellationToken, host, preferences } = context;
|
|
145523
145749
|
const token = getTokenAtPosition(sourceFile, start2);
|
|
145524
145750
|
let declaration;
|
|
145525
145751
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
145526
|
-
declaration =
|
|
145752
|
+
declaration = doChange25(
|
|
145527
145753
|
changes2,
|
|
145528
145754
|
sourceFile,
|
|
145529
145755
|
token,
|
|
@@ -145537,14 +145763,14 @@ registerCodeFix({
|
|
|
145537
145763
|
);
|
|
145538
145764
|
});
|
|
145539
145765
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
145540
|
-
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
145766
|
+
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
|
|
145541
145767
|
},
|
|
145542
|
-
fixIds: [
|
|
145768
|
+
fixIds: [fixId38],
|
|
145543
145769
|
getAllCodeActions(context) {
|
|
145544
145770
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
145545
145771
|
const markSeen = nodeSeenTracker();
|
|
145546
|
-
return codeFixAll(context,
|
|
145547
|
-
|
|
145772
|
+
return codeFixAll(context, errorCodes48, (changes, err) => {
|
|
145773
|
+
doChange25(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
145548
145774
|
});
|
|
145549
145775
|
}
|
|
145550
145776
|
});
|
|
@@ -145583,7 +145809,7 @@ function mapSuggestionDiagnostic(errorCode) {
|
|
|
145583
145809
|
}
|
|
145584
145810
|
return errorCode;
|
|
145585
145811
|
}
|
|
145586
|
-
function
|
|
145812
|
+
function doChange25(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
145587
145813
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) {
|
|
145588
145814
|
return void 0;
|
|
145589
145815
|
}
|
|
@@ -146479,13 +146705,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
146479
146705
|
}
|
|
146480
146706
|
|
|
146481
146707
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
146482
|
-
var
|
|
146483
|
-
var
|
|
146708
|
+
var fixId39 = "fixReturnTypeInAsyncFunction";
|
|
146709
|
+
var errorCodes49 = [
|
|
146484
146710
|
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
146711
|
];
|
|
146486
146712
|
registerCodeFix({
|
|
146487
|
-
errorCodes:
|
|
146488
|
-
fixIds: [
|
|
146713
|
+
errorCodes: errorCodes49,
|
|
146714
|
+
fixIds: [fixId39],
|
|
146489
146715
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
146490
146716
|
const { sourceFile, program, span } = context;
|
|
146491
146717
|
const checker = program.getTypeChecker();
|
|
@@ -146494,23 +146720,23 @@ registerCodeFix({
|
|
|
146494
146720
|
return void 0;
|
|
146495
146721
|
}
|
|
146496
146722
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
146497
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146723
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
146498
146724
|
return [createCodeFixAction(
|
|
146499
|
-
|
|
146725
|
+
fixId39,
|
|
146500
146726
|
changes,
|
|
146501
146727
|
[
|
|
146502
146728
|
Diagnostics.Replace_0_with_Promise_1,
|
|
146503
146729
|
checker.typeToString(returnType),
|
|
146504
146730
|
checker.typeToString(promisedType)
|
|
146505
146731
|
],
|
|
146506
|
-
|
|
146732
|
+
fixId39,
|
|
146507
146733
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
146508
146734
|
)];
|
|
146509
146735
|
},
|
|
146510
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
146736
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
146511
146737
|
const info = getInfo12(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
146512
146738
|
if (info) {
|
|
146513
|
-
|
|
146739
|
+
doChange26(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
146514
146740
|
}
|
|
146515
146741
|
})
|
|
146516
146742
|
});
|
|
@@ -146537,19 +146763,19 @@ function getInfo12(sourceFile, checker, pos) {
|
|
|
146537
146763
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
146538
146764
|
}
|
|
146539
146765
|
}
|
|
146540
|
-
function
|
|
146766
|
+
function doChange26(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
146541
146767
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
146542
146768
|
}
|
|
146543
146769
|
|
|
146544
146770
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
146545
146771
|
var fixName4 = "disableJsDiagnostics";
|
|
146546
|
-
var
|
|
146547
|
-
var
|
|
146772
|
+
var fixId40 = "disableJsDiagnostics";
|
|
146773
|
+
var errorCodes50 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
146548
146774
|
const diag2 = Diagnostics[key];
|
|
146549
146775
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
146550
146776
|
});
|
|
146551
146777
|
registerCodeFix({
|
|
146552
|
-
errorCodes:
|
|
146778
|
+
errorCodes: errorCodes50,
|
|
146553
146779
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
146554
146780
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
146555
146781
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -146567,14 +146793,14 @@ registerCodeFix({
|
|
|
146567
146793
|
)
|
|
146568
146794
|
];
|
|
146569
146795
|
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,
|
|
146796
|
+
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
146797
|
}
|
|
146572
146798
|
return fixes;
|
|
146573
146799
|
},
|
|
146574
|
-
fixIds: [
|
|
146800
|
+
fixIds: [fixId40],
|
|
146575
146801
|
getAllCodeActions: (context) => {
|
|
146576
146802
|
const seenLines = /* @__PURE__ */ new Set();
|
|
146577
|
-
return codeFixAll(context,
|
|
146803
|
+
return codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
146578
146804
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
146579
146805
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
146580
146806
|
}
|
|
@@ -147554,9 +147780,9 @@ var fixName6 = "strictClassInitialization";
|
|
|
147554
147780
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
147555
147781
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
147556
147782
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
147557
|
-
var
|
|
147783
|
+
var errorCodes51 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
147558
147784
|
registerCodeFix({
|
|
147559
|
-
errorCodes:
|
|
147785
|
+
errorCodes: errorCodes51,
|
|
147560
147786
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
147561
147787
|
const info = getInfo13(context.sourceFile, context.span.start);
|
|
147562
147788
|
if (!info)
|
|
@@ -147569,7 +147795,7 @@ registerCodeFix({
|
|
|
147569
147795
|
},
|
|
147570
147796
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
147571
147797
|
getAllCodeActions: (context) => {
|
|
147572
|
-
return codeFixAll(context,
|
|
147798
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
147573
147799
|
const info = getInfo13(diag2.file, diag2.start);
|
|
147574
147800
|
if (!info)
|
|
147575
147801
|
return;
|
|
@@ -147699,27 +147925,27 @@ function getDefaultValueFromType(checker, type) {
|
|
|
147699
147925
|
}
|
|
147700
147926
|
|
|
147701
147927
|
// src/services/codefixes/requireInTs.ts
|
|
147702
|
-
var
|
|
147703
|
-
var
|
|
147928
|
+
var fixId41 = "requireInTs";
|
|
147929
|
+
var errorCodes52 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
147704
147930
|
registerCodeFix({
|
|
147705
|
-
errorCodes:
|
|
147931
|
+
errorCodes: errorCodes52,
|
|
147706
147932
|
getCodeActions(context) {
|
|
147707
147933
|
const info = getInfo14(context.sourceFile, context.program, context.span.start);
|
|
147708
147934
|
if (!info) {
|
|
147709
147935
|
return void 0;
|
|
147710
147936
|
}
|
|
147711
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147712
|
-
return [createCodeFixAction(
|
|
147937
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, info));
|
|
147938
|
+
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
147713
147939
|
},
|
|
147714
|
-
fixIds: [
|
|
147715
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147940
|
+
fixIds: [fixId41],
|
|
147941
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
147716
147942
|
const info = getInfo14(diag2.file, context.program, diag2.start);
|
|
147717
147943
|
if (info) {
|
|
147718
|
-
|
|
147944
|
+
doChange27(changes, context.sourceFile, info);
|
|
147719
147945
|
}
|
|
147720
147946
|
})
|
|
147721
147947
|
});
|
|
147722
|
-
function
|
|
147948
|
+
function doChange27(changes, sourceFile, info) {
|
|
147723
147949
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
147724
147950
|
changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults ? factory.createImportEqualsDeclaration(
|
|
147725
147951
|
/*modifiers*/
|
|
@@ -147783,23 +148009,23 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
147783
148009
|
}
|
|
147784
148010
|
|
|
147785
148011
|
// src/services/codefixes/useDefaultImport.ts
|
|
147786
|
-
var
|
|
147787
|
-
var
|
|
148012
|
+
var fixId42 = "useDefaultImport";
|
|
148013
|
+
var errorCodes53 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
147788
148014
|
registerCodeFix({
|
|
147789
|
-
errorCodes:
|
|
148015
|
+
errorCodes: errorCodes53,
|
|
147790
148016
|
getCodeActions(context) {
|
|
147791
148017
|
const { sourceFile, span: { start: start2 } } = context;
|
|
147792
148018
|
const info = getInfo15(sourceFile, start2);
|
|
147793
148019
|
if (!info)
|
|
147794
148020
|
return void 0;
|
|
147795
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147796
|
-
return [createCodeFixAction(
|
|
148021
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, sourceFile, info, context.preferences));
|
|
148022
|
+
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
147797
148023
|
},
|
|
147798
|
-
fixIds: [
|
|
147799
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148024
|
+
fixIds: [fixId42],
|
|
148025
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
147800
148026
|
const info = getInfo15(diag2.file, diag2.start);
|
|
147801
148027
|
if (info)
|
|
147802
|
-
|
|
148028
|
+
doChange28(changes, diag2.file, info, context.preferences);
|
|
147803
148029
|
})
|
|
147804
148030
|
});
|
|
147805
148031
|
function getInfo15(sourceFile, pos) {
|
|
@@ -147814,7 +148040,7 @@ function getInfo15(sourceFile, pos) {
|
|
|
147814
148040
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
147815
148041
|
}
|
|
147816
148042
|
}
|
|
147817
|
-
function
|
|
148043
|
+
function doChange28(changes, sourceFile, info, preferences) {
|
|
147818
148044
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
147819
148045
|
info.name,
|
|
147820
148046
|
/*namedImports*/
|
|
@@ -147825,21 +148051,21 @@ function doChange26(changes, sourceFile, info, preferences) {
|
|
|
147825
148051
|
}
|
|
147826
148052
|
|
|
147827
148053
|
// src/services/codefixes/useBigintLiteral.ts
|
|
147828
|
-
var
|
|
147829
|
-
var
|
|
148054
|
+
var fixId43 = "useBigintLiteral";
|
|
148055
|
+
var errorCodes54 = [
|
|
147830
148056
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
147831
148057
|
];
|
|
147832
148058
|
registerCodeFix({
|
|
147833
|
-
errorCodes:
|
|
148059
|
+
errorCodes: errorCodes54,
|
|
147834
148060
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
147835
148061
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
147836
148062
|
if (changes.length > 0) {
|
|
147837
|
-
return [createCodeFixAction(
|
|
148063
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
147838
148064
|
}
|
|
147839
148065
|
},
|
|
147840
|
-
fixIds: [
|
|
148066
|
+
fixIds: [fixId43],
|
|
147841
148067
|
getAllCodeActions: (context) => {
|
|
147842
|
-
return codeFixAll(context,
|
|
148068
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
147843
148069
|
}
|
|
147844
148070
|
});
|
|
147845
148071
|
function makeChange9(changeTracker, sourceFile, span) {
|
|
@@ -147853,18 +148079,18 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
147853
148079
|
|
|
147854
148080
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
147855
148081
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
147856
|
-
var
|
|
147857
|
-
var
|
|
148082
|
+
var fixId44 = fixIdAddMissingTypeof;
|
|
148083
|
+
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
148084
|
registerCodeFix({
|
|
147859
|
-
errorCodes:
|
|
148085
|
+
errorCodes: errorCodes55,
|
|
147860
148086
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
147861
148087
|
const { sourceFile, span } = context;
|
|
147862
148088
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
147863
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147864
|
-
return [createCodeFixAction(
|
|
148089
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, importType));
|
|
148090
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
147865
148091
|
},
|
|
147866
|
-
fixIds: [
|
|
147867
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148092
|
+
fixIds: [fixId44],
|
|
148093
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => doChange29(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
147868
148094
|
});
|
|
147869
148095
|
function getImportTypeNode(sourceFile, pos) {
|
|
147870
148096
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -147872,7 +148098,7 @@ function getImportTypeNode(sourceFile, pos) {
|
|
|
147872
148098
|
Debug.assert(token.parent.kind === 202 /* ImportType */, "Token parent should be an ImportType");
|
|
147873
148099
|
return token.parent;
|
|
147874
148100
|
}
|
|
147875
|
-
function
|
|
148101
|
+
function doChange29(changes, sourceFile, importType) {
|
|
147876
148102
|
const newTypeNode = factory.updateImportTypeNode(
|
|
147877
148103
|
importType,
|
|
147878
148104
|
importType.argument,
|
|
@@ -147887,23 +148113,23 @@ function doChange27(changes, sourceFile, importType) {
|
|
|
147887
148113
|
|
|
147888
148114
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
147889
148115
|
var fixID2 = "wrapJsxInFragment";
|
|
147890
|
-
var
|
|
148116
|
+
var errorCodes56 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
147891
148117
|
registerCodeFix({
|
|
147892
|
-
errorCodes:
|
|
148118
|
+
errorCodes: errorCodes56,
|
|
147893
148119
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
147894
148120
|
const { sourceFile, span } = context;
|
|
147895
148121
|
const node = findNodeToFix(sourceFile, span.start);
|
|
147896
148122
|
if (!node)
|
|
147897
148123
|
return void 0;
|
|
147898
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148124
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, sourceFile, node));
|
|
147899
148125
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
147900
148126
|
},
|
|
147901
148127
|
fixIds: [fixID2],
|
|
147902
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148128
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
147903
148129
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
147904
148130
|
if (!node)
|
|
147905
148131
|
return void 0;
|
|
147906
|
-
|
|
148132
|
+
doChange30(changes, context.sourceFile, node);
|
|
147907
148133
|
})
|
|
147908
148134
|
});
|
|
147909
148135
|
function findNodeToFix(sourceFile, pos) {
|
|
@@ -147919,7 +148145,7 @@ function findNodeToFix(sourceFile, pos) {
|
|
|
147919
148145
|
return void 0;
|
|
147920
148146
|
return binaryExpr;
|
|
147921
148147
|
}
|
|
147922
|
-
function
|
|
148148
|
+
function doChange30(changeTracker, sf, node) {
|
|
147923
148149
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
147924
148150
|
if (jsx)
|
|
147925
148151
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -147944,24 +148170,24 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
147944
148170
|
}
|
|
147945
148171
|
|
|
147946
148172
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
147947
|
-
var
|
|
147948
|
-
var
|
|
148173
|
+
var fixId45 = "fixConvertToMappedObjectType";
|
|
148174
|
+
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
148175
|
registerCodeFix({
|
|
147950
|
-
errorCodes:
|
|
148176
|
+
errorCodes: errorCodes57,
|
|
147951
148177
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
147952
148178
|
const { sourceFile, span } = context;
|
|
147953
148179
|
const info = getInfo16(sourceFile, span.start);
|
|
147954
148180
|
if (!info)
|
|
147955
148181
|
return void 0;
|
|
147956
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148182
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, info));
|
|
147957
148183
|
const name = idText(info.container.name);
|
|
147958
|
-
return [createCodeFixAction(
|
|
148184
|
+
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
147959
148185
|
},
|
|
147960
|
-
fixIds: [
|
|
147961
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148186
|
+
fixIds: [fixId45],
|
|
148187
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
147962
148188
|
const info = getInfo16(diag2.file, diag2.start);
|
|
147963
148189
|
if (info)
|
|
147964
|
-
|
|
148190
|
+
doChange31(changes, diag2.file, info);
|
|
147965
148191
|
})
|
|
147966
148192
|
});
|
|
147967
148193
|
function getInfo16(sourceFile, pos) {
|
|
@@ -147977,7 +148203,7 @@ function getInfo16(sourceFile, pos) {
|
|
|
147977
148203
|
function createTypeAliasFromInterface(declaration, type) {
|
|
147978
148204
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
147979
148205
|
}
|
|
147980
|
-
function
|
|
148206
|
+
function doChange31(changes, sourceFile, { indexSignature, container }) {
|
|
147981
148207
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
147982
148208
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
147983
148209
|
const parameter = first(indexSignature.parameters);
|
|
@@ -148006,12 +148232,12 @@ function doChange29(changes, sourceFile, { indexSignature, container }) {
|
|
|
148006
148232
|
}
|
|
148007
148233
|
|
|
148008
148234
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
148009
|
-
var
|
|
148010
|
-
var
|
|
148235
|
+
var fixId46 = "removeAccidentalCallParentheses";
|
|
148236
|
+
var errorCodes58 = [
|
|
148011
148237
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
148012
148238
|
];
|
|
148013
148239
|
registerCodeFix({
|
|
148014
|
-
errorCodes:
|
|
148240
|
+
errorCodes: errorCodes58,
|
|
148015
148241
|
getCodeActions(context) {
|
|
148016
148242
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
148017
148243
|
if (!callExpression) {
|
|
@@ -148020,27 +148246,27 @@ registerCodeFix({
|
|
|
148020
148246
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
148021
148247
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
148022
148248
|
});
|
|
148023
|
-
return [createCodeFixActionWithoutFixAll(
|
|
148249
|
+
return [createCodeFixActionWithoutFixAll(fixId46, changes, Diagnostics.Remove_parentheses)];
|
|
148024
148250
|
},
|
|
148025
|
-
fixIds: [
|
|
148251
|
+
fixIds: [fixId46]
|
|
148026
148252
|
});
|
|
148027
148253
|
|
|
148028
148254
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
148029
|
-
var
|
|
148030
|
-
var
|
|
148255
|
+
var fixId47 = "removeUnnecessaryAwait";
|
|
148256
|
+
var errorCodes59 = [
|
|
148031
148257
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
148032
148258
|
];
|
|
148033
148259
|
registerCodeFix({
|
|
148034
|
-
errorCodes:
|
|
148260
|
+
errorCodes: errorCodes59,
|
|
148035
148261
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
148036
148262
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
148037
148263
|
if (changes.length > 0) {
|
|
148038
|
-
return [createCodeFixAction(
|
|
148264
|
+
return [createCodeFixAction(fixId47, changes, Diagnostics.Remove_unnecessary_await, fixId47, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
148039
148265
|
}
|
|
148040
148266
|
},
|
|
148041
|
-
fixIds: [
|
|
148267
|
+
fixIds: [fixId47],
|
|
148042
148268
|
getAllCodeActions: (context) => {
|
|
148043
|
-
return codeFixAll(context,
|
|
148269
|
+
return codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
148044
148270
|
}
|
|
148045
148271
|
});
|
|
148046
148272
|
function makeChange10(changeTracker, sourceFile, span) {
|
|
@@ -148068,20 +148294,20 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
148068
148294
|
}
|
|
148069
148295
|
|
|
148070
148296
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
148071
|
-
var
|
|
148072
|
-
var
|
|
148297
|
+
var errorCodes60 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
148298
|
+
var fixId48 = "splitTypeOnlyImport";
|
|
148073
148299
|
registerCodeFix({
|
|
148074
|
-
errorCodes:
|
|
148075
|
-
fixIds: [
|
|
148300
|
+
errorCodes: errorCodes60,
|
|
148301
|
+
fixIds: [fixId48],
|
|
148076
148302
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
148077
148303
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
148078
148304
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
148079
148305
|
});
|
|
148080
148306
|
if (changes.length) {
|
|
148081
|
-
return [createCodeFixAction(
|
|
148307
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
148082
148308
|
}
|
|
148083
148309
|
},
|
|
148084
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148310
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, error) => {
|
|
148085
148311
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error), context);
|
|
148086
148312
|
})
|
|
148087
148313
|
});
|
|
@@ -148122,34 +148348,34 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
148122
148348
|
}
|
|
148123
148349
|
|
|
148124
148350
|
// src/services/codefixes/convertConstToLet.ts
|
|
148125
|
-
var
|
|
148126
|
-
var
|
|
148351
|
+
var fixId49 = "fixConvertConstToLet";
|
|
148352
|
+
var errorCodes61 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
148127
148353
|
registerCodeFix({
|
|
148128
|
-
errorCodes:
|
|
148354
|
+
errorCodes: errorCodes61,
|
|
148129
148355
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
148130
148356
|
const { sourceFile, span, program } = context;
|
|
148131
148357
|
const info = getInfo17(sourceFile, span.start, program);
|
|
148132
148358
|
if (info === void 0)
|
|
148133
148359
|
return;
|
|
148134
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148135
|
-
return [createCodeFixActionMaybeFixAll(
|
|
148360
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange32(t, sourceFile, info.token));
|
|
148361
|
+
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
148136
148362
|
},
|
|
148137
148363
|
getAllCodeActions: (context) => {
|
|
148138
148364
|
const { program } = context;
|
|
148139
148365
|
const seen = /* @__PURE__ */ new Map();
|
|
148140
148366
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
148141
|
-
eachDiagnostic(context,
|
|
148367
|
+
eachDiagnostic(context, errorCodes61, (diag2) => {
|
|
148142
148368
|
const info = getInfo17(diag2.file, diag2.start, program);
|
|
148143
148369
|
if (info) {
|
|
148144
148370
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
148145
|
-
return
|
|
148371
|
+
return doChange32(changes, diag2.file, info.token);
|
|
148146
148372
|
}
|
|
148147
148373
|
}
|
|
148148
148374
|
return void 0;
|
|
148149
148375
|
});
|
|
148150
148376
|
}));
|
|
148151
148377
|
},
|
|
148152
|
-
fixIds: [
|
|
148378
|
+
fixIds: [fixId49]
|
|
148153
148379
|
});
|
|
148154
148380
|
function getInfo17(sourceFile, pos, program) {
|
|
148155
148381
|
var _a2;
|
|
@@ -148165,64 +148391,64 @@ function getInfo17(sourceFile, pos, program) {
|
|
|
148165
148391
|
return;
|
|
148166
148392
|
return { symbol, token: constToken };
|
|
148167
148393
|
}
|
|
148168
|
-
function
|
|
148394
|
+
function doChange32(changes, sourceFile, token) {
|
|
148169
148395
|
changes.replaceNode(sourceFile, token, factory.createToken(119 /* LetKeyword */));
|
|
148170
148396
|
}
|
|
148171
148397
|
|
|
148172
148398
|
// src/services/codefixes/fixExpectedComma.ts
|
|
148173
|
-
var
|
|
148399
|
+
var fixId50 = "fixExpectedComma";
|
|
148174
148400
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
148175
|
-
var
|
|
148401
|
+
var errorCodes62 = [expectedErrorCode];
|
|
148176
148402
|
registerCodeFix({
|
|
148177
|
-
errorCodes:
|
|
148403
|
+
errorCodes: errorCodes62,
|
|
148178
148404
|
getCodeActions(context) {
|
|
148179
148405
|
const { sourceFile } = context;
|
|
148180
148406
|
const info = getInfo18(sourceFile, context.span.start, context.errorCode);
|
|
148181
148407
|
if (!info)
|
|
148182
148408
|
return void 0;
|
|
148183
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
148409
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange33(t, sourceFile, info));
|
|
148184
148410
|
return [createCodeFixAction(
|
|
148185
|
-
|
|
148411
|
+
fixId50,
|
|
148186
148412
|
changes,
|
|
148187
148413
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
148188
|
-
|
|
148414
|
+
fixId50,
|
|
148189
148415
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
148190
148416
|
)];
|
|
148191
148417
|
},
|
|
148192
|
-
fixIds: [
|
|
148193
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
148418
|
+
fixIds: [fixId50],
|
|
148419
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, diag2) => {
|
|
148194
148420
|
const info = getInfo18(diag2.file, diag2.start, diag2.code);
|
|
148195
148421
|
if (info)
|
|
148196
|
-
|
|
148422
|
+
doChange33(changes, context.sourceFile, info);
|
|
148197
148423
|
})
|
|
148198
148424
|
});
|
|
148199
148425
|
function getInfo18(sourceFile, pos, _) {
|
|
148200
148426
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
148201
148427
|
return node.kind === 26 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
148202
148428
|
}
|
|
148203
|
-
function
|
|
148429
|
+
function doChange33(changes, sourceFile, { node }) {
|
|
148204
148430
|
const newNode = factory.createToken(27 /* CommaToken */);
|
|
148205
148431
|
changes.replaceNode(sourceFile, node, newNode);
|
|
148206
148432
|
}
|
|
148207
148433
|
|
|
148208
148434
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
148209
148435
|
var fixName7 = "addVoidToPromise";
|
|
148210
|
-
var
|
|
148211
|
-
var
|
|
148436
|
+
var fixId51 = "addVoidToPromise";
|
|
148437
|
+
var errorCodes63 = [
|
|
148212
148438
|
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
148439
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
148214
148440
|
];
|
|
148215
148441
|
registerCodeFix({
|
|
148216
|
-
errorCodes:
|
|
148217
|
-
fixIds: [
|
|
148442
|
+
errorCodes: errorCodes63,
|
|
148443
|
+
fixIds: [fixId51],
|
|
148218
148444
|
getCodeActions(context) {
|
|
148219
148445
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
148220
148446
|
if (changes.length > 0) {
|
|
148221
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
148447
|
+
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
148448
|
}
|
|
148223
148449
|
},
|
|
148224
148450
|
getAllCodeActions(context) {
|
|
148225
|
-
return codeFixAll(context,
|
|
148451
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
148226
148452
|
}
|
|
148227
148453
|
});
|
|
148228
148454
|
function makeChange11(changes, sourceFile, span, program, seen) {
|
|
@@ -157257,7 +157483,7 @@ registerRefactor(refactorName, {
|
|
|
157257
157483
|
Debug.assert(actionName2 === defaultToNamedAction.name || actionName2 === namedToDefaultAction.name, "Unexpected action name");
|
|
157258
157484
|
const info = getInfo19(context);
|
|
157259
157485
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
157260
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157486
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(context.file, context.program, info, t, context.cancellationToken));
|
|
157261
157487
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
157262
157488
|
}
|
|
157263
157489
|
});
|
|
@@ -157310,7 +157536,7 @@ function getInfo19(context, considerPartialSpans = true) {
|
|
|
157310
157536
|
return void 0;
|
|
157311
157537
|
}
|
|
157312
157538
|
}
|
|
157313
|
-
function
|
|
157539
|
+
function doChange34(exportingSourceFile, program, info, changes, cancellationToken) {
|
|
157314
157540
|
changeExport(exportingSourceFile, info, changes, program.getTypeChecker());
|
|
157315
157541
|
changeImports(program, info, changes, cancellationToken);
|
|
157316
157542
|
}
|
|
@@ -157505,7 +157731,7 @@ registerRefactor(refactorName2, {
|
|
|
157505
157731
|
Debug.assert(some(getOwnValues(actions), (action) => action.name === actionName2), "Unexpected action name");
|
|
157506
157732
|
const info = getImportConversionInfo(context);
|
|
157507
157733
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
157508
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157734
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(context.file, context.program, t, info));
|
|
157509
157735
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
157510
157736
|
}
|
|
157511
157737
|
});
|
|
@@ -157536,7 +157762,7 @@ function getImportConversionInfo(context, considerPartialSpans = true) {
|
|
|
157536
157762
|
function getShouldUseDefault(program, importClause) {
|
|
157537
157763
|
return getAllowSyntheticDefaultImports(program.getCompilerOptions()) && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157538
157764
|
}
|
|
157539
|
-
function
|
|
157765
|
+
function doChange35(sourceFile, program, changes, info) {
|
|
157540
157766
|
const checker = program.getTypeChecker();
|
|
157541
157767
|
if (info.convertTo === 0 /* Named */) {
|
|
157542
157768
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
@@ -158009,7 +158235,7 @@ registerRefactor(refactorName4, {
|
|
|
158009
158235
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
158010
158236
|
Debug.assert(actionName2 === refactorName4, "Wrong refactor invoked");
|
|
158011
158237
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
158012
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158238
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(context.file, context.program, statements, t, context.host, context.preferences));
|
|
158013
158239
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
158014
158240
|
}
|
|
158015
158241
|
});
|
|
@@ -158034,7 +158260,7 @@ function getRangeToMove(context) {
|
|
|
158034
158260
|
afterLast: afterEndNodeIndex === -1 ? void 0 : statements[afterEndNodeIndex]
|
|
158035
158261
|
};
|
|
158036
158262
|
}
|
|
158037
|
-
function
|
|
158263
|
+
function doChange36(oldFile, program, toMove, changes, host, preferences) {
|
|
158038
158264
|
const checker = program.getTypeChecker();
|
|
158039
158265
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
158040
158266
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
@@ -159406,12 +159632,12 @@ function getRefactorEditsToConvertParametersToDestructuredObject(context, action
|
|
|
159406
159632
|
return void 0;
|
|
159407
159633
|
const groupedReferences = getGroupedReferences(functionDeclaration, program, cancellationToken);
|
|
159408
159634
|
if (groupedReferences.valid) {
|
|
159409
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
159635
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(file, program, host, t, functionDeclaration, groupedReferences));
|
|
159410
159636
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
159411
159637
|
}
|
|
159412
159638
|
return { edits: [] };
|
|
159413
159639
|
}
|
|
159414
|
-
function
|
|
159640
|
+
function doChange37(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
|
|
159415
159641
|
const signature = groupedReferences.signature;
|
|
159416
159642
|
const newFunctionDeclarationParams = map(createNewParameters(functionDeclaration, program, host), (param) => getSynthesizedDeepClone(param));
|
|
159417
159643
|
if (signature) {
|
|
@@ -160175,7 +160401,7 @@ function getRefactorEditsToConvertToOptionalChain(context, actionName2) {
|
|
|
160175
160401
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
160176
160402
|
const edits = ts_textChanges_exports.ChangeTracker.with(
|
|
160177
160403
|
context,
|
|
160178
|
-
(t) =>
|
|
160404
|
+
(t) => doChange38(context.file, context.program.getTypeChecker(), t, info, actionName2)
|
|
160179
160405
|
);
|
|
160180
160406
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
160181
160407
|
}
|
|
@@ -160331,7 +160557,7 @@ function convertOccurrences(checker, toConvert, occurrences) {
|
|
|
160331
160557
|
}
|
|
160332
160558
|
return toConvert;
|
|
160333
160559
|
}
|
|
160334
|
-
function
|
|
160560
|
+
function doChange38(sourceFile, checker, changes, info, _actionName) {
|
|
160335
160561
|
const { finalExpression, occurrences, expression } = info;
|
|
160336
160562
|
const firstOccurrence = occurrences[occurrences.length - 1];
|
|
160337
160563
|
const convertedChain = convertOccurrences(checker, finalExpression, occurrences);
|
|
@@ -162026,7 +162252,7 @@ registerRefactor(refactorName12, {
|
|
|
162026
162252
|
function getRefactorEditsToInferReturnType(context) {
|
|
162027
162253
|
const info = getInfo21(context);
|
|
162028
162254
|
if (info && !isRefactorErrorInfo(info)) {
|
|
162029
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
162255
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(context.file, t, info.declaration, info.returnTypeNode));
|
|
162030
162256
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
162031
162257
|
}
|
|
162032
162258
|
return void 0;
|
|
@@ -162051,7 +162277,7 @@ function getRefactorActionsToInferReturnType(context) {
|
|
|
162051
162277
|
}
|
|
162052
162278
|
return emptyArray;
|
|
162053
162279
|
}
|
|
162054
|
-
function
|
|
162280
|
+
function doChange39(sourceFile, changes, declaration, typeNode) {
|
|
162055
162281
|
const closeParen = findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile);
|
|
162056
162282
|
const needParens = isArrowFunction(declaration) && closeParen === void 0;
|
|
162057
162283
|
const endNode2 = needParens ? first(declaration.parameters) : closeParen;
|
|
@@ -169514,7 +169740,6 @@ __export(ts_exports3, {
|
|
|
169514
169740
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
169515
169741
|
noop: () => noop,
|
|
169516
169742
|
noopFileWatcher: () => noopFileWatcher,
|
|
169517
|
-
noopPush: () => noopPush,
|
|
169518
169743
|
normalizePath: () => normalizePath,
|
|
169519
169744
|
normalizeSlashes: () => normalizeSlashes,
|
|
169520
169745
|
not: () => not,
|
|
@@ -170391,7 +170616,6 @@ var CommandTypes = /* @__PURE__ */ ((CommandTypes2) => {
|
|
|
170391
170616
|
CommandTypes2["NavtoFull"] = "navto-full";
|
|
170392
170617
|
CommandTypes2["NavTree"] = "navtree";
|
|
170393
170618
|
CommandTypes2["NavTreeFull"] = "navtree-full";
|
|
170394
|
-
CommandTypes2["Occurrences"] = "occurrences";
|
|
170395
170619
|
CommandTypes2["DocumentHighlights"] = "documentHighlights";
|
|
170396
170620
|
CommandTypes2["DocumentHighlightsFull"] = "documentHighlights-full";
|
|
170397
170621
|
CommandTypes2["Open"] = "open";
|
|
@@ -170596,17 +170820,14 @@ var TextStorage = class {
|
|
|
170596
170820
|
* True when reloading contents of file from the disk is pending
|
|
170597
170821
|
*/
|
|
170598
170822
|
this.pendingReloadFromDisk = false;
|
|
170599
|
-
this.version = initialVersion ||
|
|
170823
|
+
this.version = initialVersion || 0;
|
|
170600
170824
|
}
|
|
170601
170825
|
getVersion() {
|
|
170602
|
-
return this.svc ? `SVC-${this.version
|
|
170826
|
+
return this.svc ? `SVC-${this.version}-${this.svc.getSnapshotVersion()}` : `Text-${this.version}`;
|
|
170603
170827
|
}
|
|
170604
170828
|
hasScriptVersionCache_TestOnly() {
|
|
170605
170829
|
return this.svc !== void 0;
|
|
170606
170830
|
}
|
|
170607
|
-
useScriptVersionCache_TestOnly() {
|
|
170608
|
-
this.switchToScriptVersionCache();
|
|
170609
|
-
}
|
|
170610
170831
|
resetSourceMapInfo() {
|
|
170611
170832
|
this.info.sourceFileLike = void 0;
|
|
170612
170833
|
this.info.closeSourceMapFileWatcher();
|
|
@@ -170619,15 +170840,17 @@ var TextStorage = class {
|
|
|
170619
170840
|
useText(newText) {
|
|
170620
170841
|
this.svc = void 0;
|
|
170621
170842
|
this.text = newText;
|
|
170843
|
+
this.textSnapshot = void 0;
|
|
170622
170844
|
this.lineMap = void 0;
|
|
170623
170845
|
this.fileSize = void 0;
|
|
170624
170846
|
this.resetSourceMapInfo();
|
|
170625
|
-
this.version
|
|
170847
|
+
this.version++;
|
|
170626
170848
|
}
|
|
170627
170849
|
edit(start2, end, newText) {
|
|
170628
170850
|
this.switchToScriptVersionCache().edit(start2, end - start2, newText);
|
|
170629
170851
|
this.ownFileText = false;
|
|
170630
170852
|
this.text = void 0;
|
|
170853
|
+
this.textSnapshot = void 0;
|
|
170631
170854
|
this.lineMap = void 0;
|
|
170632
170855
|
this.fileSize = void 0;
|
|
170633
170856
|
this.resetSourceMapInfo();
|
|
@@ -170639,6 +170862,9 @@ var TextStorage = class {
|
|
|
170639
170862
|
reload(newText) {
|
|
170640
170863
|
Debug.assert(newText !== void 0);
|
|
170641
170864
|
this.pendingReloadFromDisk = false;
|
|
170865
|
+
if (!this.text && this.svc) {
|
|
170866
|
+
this.text = getSnapshotText(this.svc.getSnapshot());
|
|
170867
|
+
}
|
|
170642
170868
|
if (this.text !== newText) {
|
|
170643
170869
|
this.useText(newText);
|
|
170644
170870
|
this.ownFileText = false;
|
|
@@ -170651,21 +170877,18 @@ var TextStorage = class {
|
|
|
170651
170877
|
* returns true if text changed
|
|
170652
170878
|
*/
|
|
170653
170879
|
reloadWithFileText(tempFileName) {
|
|
170654
|
-
const { text: newText, fileSize } = this.getFileTextAndSize(tempFileName);
|
|
170880
|
+
const { text: newText, fileSize } = tempFileName || !this.info.isDynamicOrHasMixedContent() ? this.getFileTextAndSize(tempFileName) : { text: "", fileSize: void 0 };
|
|
170655
170881
|
const reloaded = this.reload(newText);
|
|
170656
170882
|
this.fileSize = fileSize;
|
|
170657
170883
|
this.ownFileText = !tempFileName || tempFileName === this.info.fileName;
|
|
170658
170884
|
return reloaded;
|
|
170659
170885
|
}
|
|
170660
170886
|
/**
|
|
170661
|
-
*
|
|
170662
|
-
* returns true
|
|
170887
|
+
* Schedule reload from the disk if its not already scheduled and its not own text
|
|
170888
|
+
* returns true when scheduling reload
|
|
170663
170889
|
*/
|
|
170664
|
-
|
|
170665
|
-
|
|
170666
|
-
return this.reloadWithFileText();
|
|
170667
|
-
}
|
|
170668
|
-
return false;
|
|
170890
|
+
scheduleReloadIfNeeded() {
|
|
170891
|
+
return !this.pendingReloadFromDisk && !this.ownFileText ? this.pendingReloadFromDisk = true : false;
|
|
170669
170892
|
}
|
|
170670
170893
|
delayReloadFromFileIntoText() {
|
|
170671
170894
|
this.pendingReloadFromDisk = true;
|
|
@@ -170681,39 +170904,48 @@ var TextStorage = class {
|
|
|
170681
170904
|
return !!this.fileSize ? this.fileSize : !!this.text ? this.text.length : !!this.svc ? this.svc.getSnapshot().getLength() : this.getSnapshot().getLength();
|
|
170682
170905
|
}
|
|
170683
170906
|
getSnapshot() {
|
|
170684
|
-
|
|
170907
|
+
var _a2, _b;
|
|
170908
|
+
return ((_a2 = this.tryUseScriptVersionCache()) == null ? void 0 : _a2.getSnapshot()) || ((_b = this.textSnapshot) != null ? _b : this.textSnapshot = ScriptSnapshot.fromString(Debug.checkDefined(this.text)));
|
|
170685
170909
|
}
|
|
170686
|
-
getAbsolutePositionAndLineText(
|
|
170687
|
-
|
|
170910
|
+
getAbsolutePositionAndLineText(oneBasedLine) {
|
|
170911
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170912
|
+
if (svc)
|
|
170913
|
+
return svc.getAbsolutePositionAndLineText(oneBasedLine);
|
|
170914
|
+
const lineMap = this.getLineMap();
|
|
170915
|
+
return oneBasedLine <= lineMap.length ? {
|
|
170916
|
+
absolutePosition: lineMap[oneBasedLine - 1],
|
|
170917
|
+
lineText: this.text.substring(lineMap[oneBasedLine - 1], lineMap[oneBasedLine])
|
|
170918
|
+
} : {
|
|
170919
|
+
absolutePosition: this.text.length,
|
|
170920
|
+
lineText: void 0
|
|
170921
|
+
};
|
|
170688
170922
|
}
|
|
170689
170923
|
/**
|
|
170690
170924
|
* @param line 0 based index
|
|
170691
170925
|
*/
|
|
170692
170926
|
lineToTextSpan(line) {
|
|
170693
|
-
|
|
170694
|
-
|
|
170695
|
-
|
|
170696
|
-
|
|
170697
|
-
|
|
170698
|
-
|
|
170699
|
-
return
|
|
170927
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170928
|
+
if (svc)
|
|
170929
|
+
return svc.lineToTextSpan(line);
|
|
170930
|
+
const lineMap = this.getLineMap();
|
|
170931
|
+
const start2 = lineMap[line];
|
|
170932
|
+
const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
|
|
170933
|
+
return createTextSpanFromBounds(start2, end);
|
|
170700
170934
|
}
|
|
170701
170935
|
/**
|
|
170702
170936
|
* @param line 1 based index
|
|
170703
170937
|
* @param offset 1 based index
|
|
170704
170938
|
*/
|
|
170705
170939
|
lineOffsetToPosition(line, offset, allowEdits) {
|
|
170706
|
-
|
|
170707
|
-
|
|
170708
|
-
}
|
|
170709
|
-
return this.svc.lineOffsetToPosition(line, offset);
|
|
170940
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170941
|
+
return svc ? svc.lineOffsetToPosition(line, offset) : computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
|
|
170710
170942
|
}
|
|
170711
170943
|
positionToLineOffset(position) {
|
|
170712
|
-
|
|
170713
|
-
|
|
170714
|
-
return
|
|
170715
|
-
}
|
|
170716
|
-
return
|
|
170944
|
+
const svc = this.tryUseScriptVersionCache();
|
|
170945
|
+
if (svc)
|
|
170946
|
+
return svc.positionToLineOffset(position);
|
|
170947
|
+
const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
|
|
170948
|
+
return { line: line + 1, offset: character + 1 };
|
|
170717
170949
|
}
|
|
170718
170950
|
getFileTextAndSize(tempFileName) {
|
|
170719
170951
|
let text;
|
|
@@ -170731,19 +170963,25 @@ var TextStorage = class {
|
|
|
170731
170963
|
}
|
|
170732
170964
|
return { text: getText() };
|
|
170733
170965
|
}
|
|
170966
|
+
/** @internal */
|
|
170734
170967
|
switchToScriptVersionCache() {
|
|
170735
170968
|
if (!this.svc || this.pendingReloadFromDisk) {
|
|
170736
170969
|
this.svc = ScriptVersionCache.fromString(this.getOrLoadText());
|
|
170737
|
-
this.
|
|
170970
|
+
this.textSnapshot = void 0;
|
|
170971
|
+
this.version++;
|
|
170738
170972
|
}
|
|
170739
170973
|
return this.svc;
|
|
170740
170974
|
}
|
|
170741
|
-
|
|
170742
|
-
if (this.
|
|
170743
|
-
|
|
170975
|
+
tryUseScriptVersionCache() {
|
|
170976
|
+
if (!this.svc || this.pendingReloadFromDisk) {
|
|
170977
|
+
this.getOrLoadText();
|
|
170744
170978
|
}
|
|
170745
|
-
if (this.
|
|
170746
|
-
this.
|
|
170979
|
+
if (this.isOpen) {
|
|
170980
|
+
if (!this.svc && !this.textSnapshot) {
|
|
170981
|
+
this.svc = ScriptVersionCache.fromString(Debug.checkDefined(this.text));
|
|
170982
|
+
this.textSnapshot = void 0;
|
|
170983
|
+
}
|
|
170984
|
+
return this.svc;
|
|
170747
170985
|
}
|
|
170748
170986
|
return this.svc;
|
|
170749
170987
|
}
|
|
@@ -170756,13 +170994,14 @@ var TextStorage = class {
|
|
|
170756
170994
|
}
|
|
170757
170995
|
getLineMap() {
|
|
170758
170996
|
Debug.assert(!this.svc, "ScriptVersionCache should not be set");
|
|
170759
|
-
return this.lineMap || (this.lineMap = computeLineStarts(this.
|
|
170997
|
+
return this.lineMap || (this.lineMap = computeLineStarts(Debug.checkDefined(this.text)));
|
|
170760
170998
|
}
|
|
170761
170999
|
getLineInfo() {
|
|
170762
|
-
|
|
171000
|
+
const svc = this.tryUseScriptVersionCache();
|
|
171001
|
+
if (svc) {
|
|
170763
171002
|
return {
|
|
170764
|
-
getLineCount: () =>
|
|
170765
|
-
getLineText: (line) =>
|
|
171003
|
+
getLineCount: () => svc.getLineCount(),
|
|
171004
|
+
getLineText: (line) => svc.getAbsolutePositionAndLineText(line + 1).lineText
|
|
170766
171005
|
};
|
|
170767
171006
|
}
|
|
170768
171007
|
const lineMap = this.getLineMap();
|
|
@@ -170786,20 +171025,11 @@ var ScriptInfo = class {
|
|
|
170786
171025
|
this.isDynamic = isDynamicFileName(fileName);
|
|
170787
171026
|
this.textStorage = new TextStorage(host, this, initialVersion);
|
|
170788
171027
|
if (hasMixedContent || this.isDynamic) {
|
|
170789
|
-
this.textStorage.reload("");
|
|
170790
171028
|
this.realpath = this.path;
|
|
170791
171029
|
}
|
|
170792
171030
|
this.scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
|
|
170793
171031
|
}
|
|
170794
171032
|
/** @internal */
|
|
170795
|
-
getVersion() {
|
|
170796
|
-
return this.textStorage.version;
|
|
170797
|
-
}
|
|
170798
|
-
/** @internal */
|
|
170799
|
-
getTelemetryFileSize() {
|
|
170800
|
-
return this.textStorage.getTelemetryFileSize();
|
|
170801
|
-
}
|
|
170802
|
-
/** @internal */
|
|
170803
171033
|
isDynamicOrHasMixedContent() {
|
|
170804
171034
|
return this.hasMixedContent || this.isDynamic;
|
|
170805
171035
|
}
|
|
@@ -170814,11 +171044,7 @@ var ScriptInfo = class {
|
|
|
170814
171044
|
}
|
|
170815
171045
|
close(fileExists = true) {
|
|
170816
171046
|
this.textStorage.isOpen = false;
|
|
170817
|
-
if (this.
|
|
170818
|
-
if (this.textStorage.reload("")) {
|
|
170819
|
-
this.markContainingProjectsAsDirty();
|
|
170820
|
-
}
|
|
170821
|
-
} else if (this.textStorage.reloadFromDisk()) {
|
|
171047
|
+
if (fileExists && this.textStorage.scheduleReloadIfNeeded()) {
|
|
170822
171048
|
this.markContainingProjectsAsDirty();
|
|
170823
171049
|
}
|
|
170824
171050
|
}
|
|
@@ -170998,22 +171224,12 @@ var ScriptInfo = class {
|
|
|
170998
171224
|
this.markContainingProjectsAsDirty();
|
|
170999
171225
|
}
|
|
171000
171226
|
reloadFromFile(tempFileName) {
|
|
171001
|
-
if (this.
|
|
171002
|
-
this.textStorage.reload("");
|
|
171227
|
+
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
171003
171228
|
this.markContainingProjectsAsDirty();
|
|
171004
171229
|
return true;
|
|
171005
|
-
} else {
|
|
171006
|
-
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
171007
|
-
this.markContainingProjectsAsDirty();
|
|
171008
|
-
return true;
|
|
171009
|
-
}
|
|
171010
171230
|
}
|
|
171011
171231
|
return false;
|
|
171012
171232
|
}
|
|
171013
|
-
/** @internal */
|
|
171014
|
-
getAbsolutePositionAndLineText(line) {
|
|
171015
|
-
return this.textStorage.getAbsolutePositionAndLineText(line);
|
|
171016
|
-
}
|
|
171017
171233
|
editContent(start2, end, newText) {
|
|
171018
171234
|
this.textStorage.edit(start2, end, newText);
|
|
171019
171235
|
this.markContainingProjectsAsDirty();
|
|
@@ -171053,10 +171269,6 @@ var ScriptInfo = class {
|
|
|
171053
171269
|
return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */;
|
|
171054
171270
|
}
|
|
171055
171271
|
/** @internal */
|
|
171056
|
-
getLineInfo() {
|
|
171057
|
-
return this.textStorage.getLineInfo();
|
|
171058
|
-
}
|
|
171059
|
-
/** @internal */
|
|
171060
171272
|
closeSourceMapFileWatcher() {
|
|
171061
171273
|
if (this.sourceMapFilePath && !isString(this.sourceMapFilePath)) {
|
|
171062
171274
|
closeFileWatcherOf(this.sourceMapFilePath);
|
|
@@ -171201,7 +171413,7 @@ function countEachFileTypes(infos, includeSizes = false) {
|
|
|
171201
171413
|
deferredSize: 0
|
|
171202
171414
|
};
|
|
171203
171415
|
for (const info of infos) {
|
|
171204
|
-
const fileSize = includeSizes ? info.getTelemetryFileSize() : 0;
|
|
171416
|
+
const fileSize = includeSizes ? info.textStorage.getTelemetryFileSize() : 0;
|
|
171205
171417
|
switch (info.scriptKind) {
|
|
171206
171418
|
case 1 /* JS */:
|
|
171207
171419
|
result.js += 1;
|
|
@@ -172185,10 +172397,26 @@ var Project3 = class {
|
|
|
172185
172397
|
const elapsed = timestamp() - start2;
|
|
172186
172398
|
this.sendPerformanceEvent("UpdateGraph", elapsed);
|
|
172187
172399
|
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.
|
|
172400
|
+
if (this.projectService.logger.isTestLogger) {
|
|
172401
|
+
if (this.program !== oldProgram) {
|
|
172402
|
+
this.print(
|
|
172403
|
+
/*writeProjectFileNames*/
|
|
172404
|
+
true,
|
|
172405
|
+
this.hasAddedorRemovedFiles,
|
|
172406
|
+
/*writeFileVersionAndText*/
|
|
172407
|
+
true
|
|
172408
|
+
);
|
|
172409
|
+
} else {
|
|
172410
|
+
this.writeLog(`Same program as before`);
|
|
172411
|
+
}
|
|
172412
|
+
} else if (this.hasAddedorRemovedFiles) {
|
|
172189
172413
|
this.print(
|
|
172190
172414
|
/*writeProjectFileNames*/
|
|
172191
|
-
true
|
|
172415
|
+
true,
|
|
172416
|
+
/*writeFileExplaination*/
|
|
172417
|
+
true,
|
|
172418
|
+
/*writeFileVersionAndText*/
|
|
172419
|
+
false
|
|
172192
172420
|
);
|
|
172193
172421
|
} else if (this.program !== oldProgram) {
|
|
172194
172422
|
this.writeLog(`Different program with same set of files`);
|
|
@@ -172298,6 +172526,16 @@ var Project3 = class {
|
|
|
172298
172526
|
return this.projectService.getScriptInfo(uncheckedFileName);
|
|
172299
172527
|
}
|
|
172300
172528
|
filesToString(writeProjectFileNames) {
|
|
172529
|
+
return this.filesToStringWorker(
|
|
172530
|
+
writeProjectFileNames,
|
|
172531
|
+
/*writeFileExplaination*/
|
|
172532
|
+
true,
|
|
172533
|
+
/*writeFileVersionAndText*/
|
|
172534
|
+
false
|
|
172535
|
+
);
|
|
172536
|
+
}
|
|
172537
|
+
/** @internal */
|
|
172538
|
+
filesToStringWorker(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
172301
172539
|
if (this.isInitialLoadPending())
|
|
172302
172540
|
return " Files (0) InitialLoadPending\n";
|
|
172303
172541
|
if (!this.program)
|
|
@@ -172307,23 +172545,33 @@ var Project3 = class {
|
|
|
172307
172545
|
`;
|
|
172308
172546
|
if (writeProjectFileNames) {
|
|
172309
172547
|
for (const file of sourceFiles) {
|
|
172310
|
-
strBuilder += ` ${file.fileName}
|
|
172548
|
+
strBuilder += ` ${file.fileName}${writeFileVersionAndText ? ` ${file.version} ${JSON.stringify(file.text)}` : ""}
|
|
172311
172549
|
`;
|
|
172312
172550
|
}
|
|
172313
|
-
|
|
172314
|
-
|
|
172551
|
+
if (writeFileExplaination) {
|
|
172552
|
+
strBuilder += "\n\n";
|
|
172553
|
+
explainFiles(this.program, (s) => strBuilder += ` ${s}
|
|
172315
172554
|
`);
|
|
172555
|
+
}
|
|
172316
172556
|
}
|
|
172317
172557
|
return strBuilder;
|
|
172318
172558
|
}
|
|
172319
172559
|
/** @internal */
|
|
172320
|
-
print(writeProjectFileNames) {
|
|
172560
|
+
print(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
172321
172561
|
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
|
|
172322
|
-
this.writeLog(this.
|
|
172562
|
+
this.writeLog(this.filesToStringWorker(
|
|
172563
|
+
writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
172564
|
+
writeFileExplaination && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
172565
|
+
writeFileVersionAndText && this.projectService.logger.hasLevel(3 /* verbose */)
|
|
172566
|
+
));
|
|
172323
172567
|
this.writeLog("-----------------------------------------------");
|
|
172324
172568
|
if (this.autoImportProviderHost) {
|
|
172325
172569
|
this.autoImportProviderHost.print(
|
|
172326
172570
|
/*writeProjectFileNames*/
|
|
172571
|
+
false,
|
|
172572
|
+
/*writeFileExplaination*/
|
|
172573
|
+
false,
|
|
172574
|
+
/*writeFileVersionAndText*/
|
|
172327
172575
|
false
|
|
172328
172576
|
);
|
|
172329
172577
|
}
|
|
@@ -173347,7 +173595,7 @@ var ConfiguredProject2 = class extends Project3 {
|
|
|
173347
173595
|
return !!this.externalProjectRefCount;
|
|
173348
173596
|
}
|
|
173349
173597
|
getEffectiveTypeRoots() {
|
|
173350
|
-
return getEffectiveTypeRoots(this.getCompilationSettings(), this
|
|
173598
|
+
return getEffectiveTypeRoots(this.getCompilationSettings(), this) || [];
|
|
173351
173599
|
}
|
|
173352
173600
|
/** @internal */
|
|
173353
173601
|
updateErrorOnNoInputFiles(fileNames) {
|
|
@@ -174278,7 +174526,11 @@ var _ProjectService = class {
|
|
|
174278
174526
|
this.logger.info("`remove Project::");
|
|
174279
174527
|
project.print(
|
|
174280
174528
|
/*writeProjectFileNames*/
|
|
174281
|
-
true
|
|
174529
|
+
true,
|
|
174530
|
+
/*writeFileExplaination*/
|
|
174531
|
+
true,
|
|
174532
|
+
/*writeFileVersionAndText*/
|
|
174533
|
+
false
|
|
174282
174534
|
);
|
|
174283
174535
|
project.close();
|
|
174284
174536
|
if (Debug.shouldAssert(1 /* Normal */)) {
|
|
@@ -174417,7 +174669,7 @@ var _ProjectService = class {
|
|
|
174417
174669
|
}
|
|
174418
174670
|
deleteScriptInfo(info) {
|
|
174419
174671
|
this.filenameToScriptInfo.delete(info.path);
|
|
174420
|
-
this.filenameToScriptInfoVersion.set(info.path, info.
|
|
174672
|
+
this.filenameToScriptInfoVersion.set(info.path, info.textStorage.version);
|
|
174421
174673
|
const realpath = info.getRealpathIfDifferent();
|
|
174422
174674
|
if (realpath) {
|
|
174423
174675
|
this.realpathToScriptInfos.remove(realpath, info);
|
|
@@ -175501,7 +175753,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
175501
175753
|
const documentPositionMapper = getDocumentPositionMapper(
|
|
175502
175754
|
{ getCanonicalFileName: this.toCanonicalFileName, log: (s) => this.logger.info(s), getSourceFileLike: (f) => this.getSourceFileLike(f, projectName, declarationInfo) },
|
|
175503
175755
|
declarationInfo.fileName,
|
|
175504
|
-
declarationInfo.getLineInfo(),
|
|
175756
|
+
declarationInfo.textStorage.getLineInfo(),
|
|
175505
175757
|
readMapFile
|
|
175506
175758
|
);
|
|
175507
175759
|
readMapFile = void 0;
|
|
@@ -176632,6 +176884,10 @@ function isConfigFile(config) {
|
|
|
176632
176884
|
function printProjectWithoutFileNames(project) {
|
|
176633
176885
|
project.print(
|
|
176634
176886
|
/*writeProjectFileNames*/
|
|
176887
|
+
false,
|
|
176888
|
+
/*writeFileExplaination*/
|
|
176889
|
+
false,
|
|
176890
|
+
/*writeFileVersionAndText*/
|
|
176635
176891
|
false
|
|
176636
176892
|
);
|
|
176637
176893
|
}
|
|
@@ -177270,7 +177526,6 @@ var invalidSyntacticModeCommands = [
|
|
|
177270
177526
|
"signatureHelp-full" /* SignatureHelpFull */,
|
|
177271
177527
|
"navto" /* Navto */,
|
|
177272
177528
|
"navto-full" /* NavtoFull */,
|
|
177273
|
-
"occurrences" /* Occurrences */,
|
|
177274
177529
|
"documentHighlights" /* DocumentHighlights */,
|
|
177275
177530
|
"documentHighlights-full" /* DocumentHighlightsFull */
|
|
177276
177531
|
];
|
|
@@ -177703,9 +177958,6 @@ var Session3 = class {
|
|
|
177703
177958
|
false
|
|
177704
177959
|
));
|
|
177705
177960
|
},
|
|
177706
|
-
["occurrences" /* Occurrences */]: (request) => {
|
|
177707
|
-
return this.requiredResponse(this.getOccurrences(request.arguments));
|
|
177708
|
-
},
|
|
177709
177961
|
["documentHighlights" /* DocumentHighlights */]: (request) => {
|
|
177710
177962
|
return this.requiredResponse(this.getDocumentHighlights(
|
|
177711
177963
|
request.arguments,
|
|
@@ -178668,21 +178920,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
178668
178920
|
const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray2, project);
|
|
178669
178921
|
return simplifiedResult ? implementations.map(({ fileName, textSpan, contextSpan }) => this.toFileSpanWithContext(fileName, textSpan, contextSpan, project)) : implementations.map(Session3.mapToOriginalLocation);
|
|
178670
178922
|
}
|
|
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
178923
|
getSyntacticDiagnosticsSync(args) {
|
|
178687
178924
|
const { configFile } = this.getConfigFileAndProject(args);
|
|
178688
178925
|
if (configFile) {
|
|
@@ -179093,7 +179330,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
179093
179330
|
formatOptions
|
|
179094
179331
|
);
|
|
179095
179332
|
if (args.key === "\n" && (!edits || edits.length === 0 || allEditsBeforePos(edits, position))) {
|
|
179096
|
-
const { lineText, absolutePosition } = scriptInfo.getAbsolutePositionAndLineText(args.line);
|
|
179333
|
+
const { lineText, absolutePosition } = scriptInfo.textStorage.getAbsolutePositionAndLineText(args.line);
|
|
179097
179334
|
if (lineText && lineText.search("\\S") < 0) {
|
|
179098
179335
|
const preferredIndent = languageService.getIndentationAtPosition(file, position, formatOptions);
|
|
179099
179336
|
let hasIndent = 0;
|
|
@@ -179318,6 +179555,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
179318
179555
|
change(args) {
|
|
179319
179556
|
const scriptInfo = this.projectService.getScriptInfo(args.file);
|
|
179320
179557
|
Debug.assert(!!scriptInfo);
|
|
179558
|
+
scriptInfo.textStorage.switchToScriptVersionCache();
|
|
179321
179559
|
const start2 = scriptInfo.lineOffsetToPosition(args.line, args.offset);
|
|
179322
179560
|
const end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
|
|
179323
179561
|
if (start2 >= 0) {
|
|
@@ -179610,10 +179848,10 @@ ${e.message}`;
|
|
|
179610
179848
|
}
|
|
179611
179849
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
179612
179850
|
}
|
|
179613
|
-
getCombinedCodeFix({ scope, fixId:
|
|
179851
|
+
getCombinedCodeFix({ scope, fixId: fixId52 }, simplifiedResult) {
|
|
179614
179852
|
Debug.assert(scope.type === "file");
|
|
179615
179853
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
179616
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
179854
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId52, this.getFormatOptions(file), this.getPreferences(file));
|
|
179617
179855
|
if (simplifiedResult) {
|
|
179618
179856
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
179619
179857
|
} else {
|
|
@@ -179652,8 +179890,8 @@ ${e.message}`;
|
|
|
179652
179890
|
mapCodeAction({ description: description2, changes, commands }) {
|
|
179653
179891
|
return { description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
179654
179892
|
}
|
|
179655
|
-
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId:
|
|
179656
|
-
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
179893
|
+
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId: fixId52, fixAllDescription }) {
|
|
179894
|
+
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId52, fixAllDescription };
|
|
179657
179895
|
}
|
|
179658
179896
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
179659
179897
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -183463,7 +183701,6 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
183463
183701
|
nodeToDisplayParts,
|
|
183464
183702
|
noop,
|
|
183465
183703
|
noopFileWatcher,
|
|
183466
|
-
noopPush,
|
|
183467
183704
|
normalizePath,
|
|
183468
183705
|
normalizeSlashes,
|
|
183469
183706
|
not,
|