typescript 5.1.0-dev.20230227 → 5.1.0-dev.20230302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/lib.es2015.collection.d.ts +1 -1
- package/lib/tsc.js +216 -152
- package/lib/tsserver.js +960 -697
- package/lib/tsserverlibrary.d.ts +7 -44
- package/lib/tsserverlibrary.js +1019 -745
- package/lib/typescript.d.ts +5 -10
- package/lib/typescript.js +897 -634
- package/lib/typingsInstaller.js +50 -14
- package/package.json +14 -14
package/lib/tsserverlibrary.js
CHANGED
|
@@ -35,7 +35,7 @@ var ts = (() => {
|
|
|
35
35
|
"src/compiler/corePublic.ts"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
versionMajorMinor = "5.1";
|
|
38
|
-
version = `${versionMajorMinor}.0-dev.
|
|
38
|
+
version = `${versionMajorMinor}.0-dev.20230302`;
|
|
39
39
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
40
40
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
41
41
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -1000,9 +1000,6 @@ var ts = (() => {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
function createUnderscoreEscapedMultiMap() {
|
|
1004
|
-
return createMultiMap();
|
|
1005
|
-
}
|
|
1006
1003
|
function createQueue(items) {
|
|
1007
1004
|
const elements = (items == null ? void 0 : items.slice()) || [];
|
|
1008
1005
|
let headIndex = 0;
|
|
@@ -1625,7 +1622,7 @@ var ts = (() => {
|
|
|
1625
1622
|
function isNodeLikeSystem() {
|
|
1626
1623
|
return typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object";
|
|
1627
1624
|
}
|
|
1628
|
-
var emptyArray, emptyMap, emptySet, SortKind, elementAt, hasOwnProperty,
|
|
1625
|
+
var emptyArray, emptyMap, emptySet, SortKind, elementAt, hasOwnProperty, fileNameLowerCaseRegExp, AssertionLevel, createUIStringComparer, uiComparerCaseSensitive, uiLocale, trimString, trimStringEnd, trimStringStart;
|
|
1629
1626
|
var init_core = __esm({
|
|
1630
1627
|
"src/compiler/core.ts"() {
|
|
1631
1628
|
"use strict";
|
|
@@ -1650,10 +1647,6 @@ var ts = (() => {
|
|
|
1650
1647
|
return void 0;
|
|
1651
1648
|
};
|
|
1652
1649
|
hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1653
|
-
noopPush = {
|
|
1654
|
-
push: noop,
|
|
1655
|
-
length: 0
|
|
1656
|
-
};
|
|
1657
1650
|
fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
|
|
1658
1651
|
AssertionLevel = /* @__PURE__ */ ((AssertionLevel2) => {
|
|
1659
1652
|
AssertionLevel2[AssertionLevel2["None"] = 0] = "None";
|
|
@@ -8461,6 +8454,7 @@ ${lanes.join("\n")}
|
|
|
8461
8454
|
File_name_0_has_a_1_extension_looking_up_2_instead: diag(6262, 3 /* Message */, "File_name_0_has_a_1_extension_looking_up_2_instead_6262", "File name '{0}' has a '{1}' extension - looking up '{2}' instead."),
|
|
8462
8455
|
Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set: diag(6263, 1 /* Error */, "Module_0_was_resolved_to_1_but_allowArbitraryExtensions_is_not_set_6263", "Module '{0}' was resolved to '{1}', but '--allowArbitraryExtensions' is not set."),
|
|
8463
8456
|
Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present: diag(6264, 3 /* Message */, "Enable_importing_files_with_any_extension_provided_a_declaration_file_is_present_6264", "Enable importing files with any extension, provided a declaration file is present."),
|
|
8457
|
+
Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder: diag(6265, 3 /* Message */, "Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_no_6265", "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder."),
|
|
8464
8458
|
Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, 3 /* Message */, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."),
|
|
8465
8459
|
Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, 3 /* Message */, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."),
|
|
8466
8460
|
Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, 3 /* Message */, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."),
|
|
@@ -8856,6 +8850,8 @@ ${lanes.join("\n")}
|
|
|
8856
8850
|
This_may_be_converted_to_an_async_function: diag(80006, 2 /* Suggestion */, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."),
|
|
8857
8851
|
await_has_no_effect_on_the_type_of_this_expression: diag(80007, 2 /* Suggestion */, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."),
|
|
8858
8852
|
Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, 2 /* Suggestion */, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."),
|
|
8853
|
+
JSDoc_typedef_may_be_converted_to_TypeScript_type: diag(80009, 2 /* Suggestion */, "JSDoc_typedef_may_be_converted_to_TypeScript_type_80009", "JSDoc typedef may be converted to TypeScript type."),
|
|
8854
|
+
JSDoc_typedefs_may_be_converted_to_TypeScript_types: diag(80010, 2 /* Suggestion */, "JSDoc_typedefs_may_be_converted_to_TypeScript_types_80010", "JSDoc typedefs may be converted to TypeScript types."),
|
|
8859
8855
|
Add_missing_super_call: diag(90001, 3 /* Message */, "Add_missing_super_call_90001", "Add missing 'super()' call"),
|
|
8860
8856
|
Make_super_call_the_first_statement_in_the_constructor: diag(90002, 3 /* Message */, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"),
|
|
8861
8857
|
Change_extends_to_implements: diag(90003, 3 /* Message */, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
|
|
@@ -9070,6 +9066,8 @@ ${lanes.join("\n")}
|
|
|
9070
9066
|
Rename_param_tag_name_0_to_1: diag(95173, 3 /* Message */, "Rename_param_tag_name_0_to_1_95173", "Rename '@param' tag name '{0}' to '{1}'"),
|
|
9071
9067
|
Use_0: diag(95174, 3 /* Message */, "Use_0_95174", "Use `{0}`."),
|
|
9072
9068
|
Use_Number_isNaN_in_all_conditions: diag(95175, 3 /* Message */, "Use_Number_isNaN_in_all_conditions_95175", "Use `Number.isNaN` in all conditions."),
|
|
9069
|
+
Convert_typedef_to_TypeScript_type: diag(95176, 3 /* Message */, "Convert_typedef_to_TypeScript_type_95176", "Convert typedef to TypeScript type."),
|
|
9070
|
+
Convert_all_typedef_to_TypeScript_types: diag(95177, 3 /* Message */, "Convert_all_typedef_to_TypeScript_types_95177", "Convert all typedef to TypeScript types."),
|
|
9073
9071
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
9074
9072
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
9075
9073
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -38856,20 +38854,14 @@ ${lanes.join("\n")}
|
|
|
38856
38854
|
currentDirectory = host.getCurrentDirectory();
|
|
38857
38855
|
}
|
|
38858
38856
|
if (currentDirectory !== void 0) {
|
|
38859
|
-
return getDefaultTypeRoots(currentDirectory
|
|
38857
|
+
return getDefaultTypeRoots(currentDirectory);
|
|
38860
38858
|
}
|
|
38861
38859
|
}
|
|
38862
|
-
function getDefaultTypeRoots(currentDirectory
|
|
38863
|
-
if (!host.directoryExists) {
|
|
38864
|
-
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
|
|
38865
|
-
}
|
|
38860
|
+
function getDefaultTypeRoots(currentDirectory) {
|
|
38866
38861
|
let typeRoots;
|
|
38867
38862
|
forEachAncestorDirectory(normalizePath(currentDirectory), (directory) => {
|
|
38868
38863
|
const atTypes = combinePaths(directory, nodeModulesAtTypes);
|
|
38869
|
-
|
|
38870
|
-
(typeRoots || (typeRoots = [])).push(atTypes);
|
|
38871
|
-
}
|
|
38872
|
-
return void 0;
|
|
38864
|
+
(typeRoots != null ? typeRoots : typeRoots = []).push(atTypes);
|
|
38873
38865
|
});
|
|
38874
38866
|
return typeRoots;
|
|
38875
38867
|
}
|
|
@@ -39005,10 +38997,22 @@ ${lanes.join("\n")}
|
|
|
39005
38997
|
}
|
|
39006
38998
|
return firstDefined(typeRoots, (typeRoot) => {
|
|
39007
38999
|
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
|
|
39008
|
-
const
|
|
39009
|
-
const directoryExists = directoryProbablyExists(candidateDirectory, host);
|
|
39000
|
+
const directoryExists = directoryProbablyExists(typeRoot, host);
|
|
39010
39001
|
if (!directoryExists && traceEnabled) {
|
|
39011
|
-
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it,
|
|
39002
|
+
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
39003
|
+
}
|
|
39004
|
+
if (options.typeRoots) {
|
|
39005
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, moduleResolutionState);
|
|
39006
|
+
if (resolvedFromFile) {
|
|
39007
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
39008
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
39009
|
+
packageDirectory,
|
|
39010
|
+
/*onlyRecordFailures*/
|
|
39011
|
+
false,
|
|
39012
|
+
moduleResolutionState
|
|
39013
|
+
) : void 0;
|
|
39014
|
+
return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
|
|
39015
|
+
}
|
|
39012
39016
|
}
|
|
39013
39017
|
return resolvedTypeScriptOnly(
|
|
39014
39018
|
loadNodeModuleFromDirectory(
|
|
@@ -39028,33 +39032,37 @@ ${lanes.join("\n")}
|
|
|
39028
39032
|
function secondaryLookup() {
|
|
39029
39033
|
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
|
|
39030
39034
|
if (initialLocationForSecondaryLookup !== void 0) {
|
|
39031
|
-
if (traceEnabled) {
|
|
39032
|
-
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
39033
|
-
}
|
|
39034
39035
|
let result2;
|
|
39035
|
-
if (!
|
|
39036
|
-
|
|
39037
|
-
|
|
39038
|
-
|
|
39039
|
-
|
|
39040
|
-
|
|
39041
|
-
|
|
39042
|
-
|
|
39043
|
-
|
|
39044
|
-
|
|
39045
|
-
|
|
39046
|
-
|
|
39047
|
-
|
|
39048
|
-
|
|
39049
|
-
|
|
39050
|
-
|
|
39051
|
-
|
|
39052
|
-
|
|
39053
|
-
|
|
39054
|
-
|
|
39055
|
-
|
|
39056
|
-
|
|
39057
|
-
|
|
39036
|
+
if (!options.typeRoots || !endsWith(containingFile, inferredTypesContainingFile)) {
|
|
39037
|
+
if (traceEnabled) {
|
|
39038
|
+
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
|
|
39039
|
+
}
|
|
39040
|
+
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
|
|
39041
|
+
const searchResult = loadModuleFromNearestNodeModulesDirectory(
|
|
39042
|
+
4 /* Declaration */,
|
|
39043
|
+
typeReferenceDirectiveName,
|
|
39044
|
+
initialLocationForSecondaryLookup,
|
|
39045
|
+
moduleResolutionState,
|
|
39046
|
+
/*cache*/
|
|
39047
|
+
void 0,
|
|
39048
|
+
/*redirectedReference*/
|
|
39049
|
+
void 0
|
|
39050
|
+
);
|
|
39051
|
+
result2 = searchResult && searchResult.value;
|
|
39052
|
+
} else {
|
|
39053
|
+
const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
|
|
39054
|
+
result2 = nodeLoadModuleByRelativeName(
|
|
39055
|
+
4 /* Declaration */,
|
|
39056
|
+
candidate,
|
|
39057
|
+
/*onlyRecordFailures*/
|
|
39058
|
+
false,
|
|
39059
|
+
moduleResolutionState,
|
|
39060
|
+
/*considerPackageJson*/
|
|
39061
|
+
true
|
|
39062
|
+
);
|
|
39063
|
+
}
|
|
39064
|
+
} else if (traceEnabled) {
|
|
39065
|
+
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
|
|
39058
39066
|
}
|
|
39059
39067
|
return resolvedTypeScriptOnly(result2);
|
|
39060
39068
|
} else {
|
|
@@ -39873,6 +39881,9 @@ ${lanes.join("\n")}
|
|
|
39873
39881
|
}
|
|
39874
39882
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
39875
39883
|
}
|
|
39884
|
+
if (extensions2 & 4 /* Declaration */) {
|
|
39885
|
+
resolved2 != null ? resolved2 : resolved2 = resolveFromTypeRoot(moduleName, state2);
|
|
39886
|
+
}
|
|
39876
39887
|
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
39877
39888
|
} else {
|
|
39878
39889
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
@@ -40052,6 +40063,7 @@ ${lanes.join("\n")}
|
|
|
40052
40063
|
return forEach(state.compilerOptions.moduleSuffixes, (suffix) => tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state));
|
|
40053
40064
|
}
|
|
40054
40065
|
function tryFileLookup(fileName, onlyRecordFailures, state) {
|
|
40066
|
+
var _a2;
|
|
40055
40067
|
if (!onlyRecordFailures) {
|
|
40056
40068
|
if (state.host.fileExists(fileName)) {
|
|
40057
40069
|
if (state.traceEnabled) {
|
|
@@ -40064,7 +40076,7 @@ ${lanes.join("\n")}
|
|
|
40064
40076
|
}
|
|
40065
40077
|
}
|
|
40066
40078
|
}
|
|
40067
|
-
state.failedLookupLocations.push(fileName);
|
|
40079
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(fileName);
|
|
40068
40080
|
return void 0;
|
|
40069
40081
|
}
|
|
40070
40082
|
function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson = true) {
|
|
@@ -40179,8 +40191,8 @@ ${lanes.join("\n")}
|
|
|
40179
40191
|
host,
|
|
40180
40192
|
compilerOptions: options,
|
|
40181
40193
|
traceEnabled: isTraceEnabled(options, host),
|
|
40182
|
-
failedLookupLocations:
|
|
40183
|
-
affectingLocations:
|
|
40194
|
+
failedLookupLocations: void 0,
|
|
40195
|
+
affectingLocations: void 0,
|
|
40184
40196
|
packageJsonInfoCache,
|
|
40185
40197
|
features: 0 /* None */,
|
|
40186
40198
|
conditions: emptyArray,
|
|
@@ -40214,24 +40226,24 @@ ${lanes.join("\n")}
|
|
|
40214
40226
|
return packageJsonInfo.contents.versionPaths || void 0;
|
|
40215
40227
|
}
|
|
40216
40228
|
function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
|
|
40217
|
-
var _a2, _b, _c;
|
|
40229
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
40218
40230
|
const { host, traceEnabled } = state;
|
|
40219
40231
|
const packageJsonPath = combinePaths(packageDirectory, "package.json");
|
|
40220
40232
|
if (onlyRecordFailures) {
|
|
40221
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40233
|
+
(_a2 = state.failedLookupLocations) == null ? void 0 : _a2.push(packageJsonPath);
|
|
40222
40234
|
return void 0;
|
|
40223
40235
|
}
|
|
40224
|
-
const existing = (
|
|
40236
|
+
const existing = (_b = state.packageJsonInfoCache) == null ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
40225
40237
|
if (existing !== void 0) {
|
|
40226
40238
|
if (typeof existing !== "boolean") {
|
|
40227
40239
|
if (traceEnabled)
|
|
40228
40240
|
trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath);
|
|
40229
|
-
state.affectingLocations.push(packageJsonPath);
|
|
40241
|
+
(_c = state.affectingLocations) == null ? void 0 : _c.push(packageJsonPath);
|
|
40230
40242
|
return existing.packageDirectory === packageDirectory ? existing : { packageDirectory, contents: existing.contents };
|
|
40231
40243
|
} else {
|
|
40232
40244
|
if (existing && traceEnabled)
|
|
40233
40245
|
trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath);
|
|
40234
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40246
|
+
(_d = state.failedLookupLocations) == null ? void 0 : _d.push(packageJsonPath);
|
|
40235
40247
|
return void 0;
|
|
40236
40248
|
}
|
|
40237
40249
|
}
|
|
@@ -40242,15 +40254,15 @@ ${lanes.join("\n")}
|
|
|
40242
40254
|
trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
40243
40255
|
}
|
|
40244
40256
|
const result = { packageDirectory, contents: { packageJsonContent, versionPaths: void 0, resolvedEntrypoints: void 0 } };
|
|
40245
|
-
(
|
|
40246
|
-
state.affectingLocations.push(packageJsonPath);
|
|
40257
|
+
(_e = state.packageJsonInfoCache) == null ? void 0 : _e.setPackageJsonInfo(packageJsonPath, result);
|
|
40258
|
+
(_f = state.affectingLocations) == null ? void 0 : _f.push(packageJsonPath);
|
|
40247
40259
|
return result;
|
|
40248
40260
|
} else {
|
|
40249
40261
|
if (directoryExists && traceEnabled) {
|
|
40250
40262
|
trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath);
|
|
40251
40263
|
}
|
|
40252
|
-
(
|
|
40253
|
-
state.failedLookupLocations.push(packageJsonPath);
|
|
40264
|
+
(_g = state.packageJsonInfoCache) == null ? void 0 : _g.setPackageJsonInfo(packageJsonPath, directoryExists);
|
|
40265
|
+
(_h = state.failedLookupLocations) == null ? void 0 : _h.push(packageJsonPath);
|
|
40254
40266
|
}
|
|
40255
40267
|
}
|
|
40256
40268
|
function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
|
|
@@ -41070,11 +41082,13 @@ ${lanes.join("\n")}
|
|
|
41070
41082
|
state
|
|
41071
41083
|
));
|
|
41072
41084
|
});
|
|
41073
|
-
if (resolved2)
|
|
41085
|
+
if (resolved2)
|
|
41074
41086
|
return resolved2;
|
|
41075
|
-
}
|
|
41076
41087
|
if (extensions & (1 /* TypeScript */ | 4 /* Declaration */)) {
|
|
41077
|
-
|
|
41088
|
+
let resolved3 = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
|
|
41089
|
+
if (extensions & 4 /* Declaration */)
|
|
41090
|
+
resolved3 != null ? resolved3 : resolved3 = resolveFromTypeRoot(moduleName, state);
|
|
41091
|
+
return resolved3;
|
|
41078
41092
|
}
|
|
41079
41093
|
} else {
|
|
41080
41094
|
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
|
|
@@ -41088,6 +41102,31 @@ ${lanes.join("\n")}
|
|
|
41088
41102
|
}
|
|
41089
41103
|
}
|
|
41090
41104
|
}
|
|
41105
|
+
function resolveFromTypeRoot(moduleName, state) {
|
|
41106
|
+
if (!state.compilerOptions.typeRoots)
|
|
41107
|
+
return;
|
|
41108
|
+
for (const typeRoot of state.compilerOptions.typeRoots) {
|
|
41109
|
+
const candidate = combinePaths(typeRoot, moduleName);
|
|
41110
|
+
const directoryExists = directoryProbablyExists(typeRoot, state.host);
|
|
41111
|
+
if (!directoryExists && state.traceEnabled) {
|
|
41112
|
+
trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
|
|
41113
|
+
}
|
|
41114
|
+
const resolvedFromFile = loadModuleFromFile(4 /* Declaration */, candidate, !directoryExists, state);
|
|
41115
|
+
if (resolvedFromFile) {
|
|
41116
|
+
const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
|
|
41117
|
+
const packageInfo = packageDirectory ? getPackageJsonInfo(
|
|
41118
|
+
packageDirectory,
|
|
41119
|
+
/*onlyRecordFailures*/
|
|
41120
|
+
false,
|
|
41121
|
+
state
|
|
41122
|
+
) : void 0;
|
|
41123
|
+
return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
|
|
41124
|
+
}
|
|
41125
|
+
const resolved = loadNodeModuleFromDirectory(4 /* Declaration */, candidate, !directoryExists, state);
|
|
41126
|
+
if (resolved)
|
|
41127
|
+
return toSearchResult(resolved);
|
|
41128
|
+
}
|
|
41129
|
+
}
|
|
41091
41130
|
function shouldAllowImportingTsExtension(compilerOptions, fromFileName) {
|
|
41092
41131
|
return !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName);
|
|
41093
41132
|
}
|
|
@@ -50209,7 +50248,7 @@ ${lanes.join("\n")}
|
|
|
50209
50248
|
}
|
|
50210
50249
|
}
|
|
50211
50250
|
const mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */);
|
|
50212
|
-
const seenNames = mayHaveNameCollisions ?
|
|
50251
|
+
const seenNames = mayHaveNameCollisions ? createMultiMap() : void 0;
|
|
50213
50252
|
const result = [];
|
|
50214
50253
|
let i = 0;
|
|
50215
50254
|
for (const type of types) {
|
|
@@ -54010,7 +54049,11 @@ ${lanes.join("\n")}
|
|
|
54010
54049
|
const baseTypeVariable = getBaseTypeVariableOfClass(symbol);
|
|
54011
54050
|
return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
|
|
54012
54051
|
} else {
|
|
54013
|
-
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
54052
|
+
return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(
|
|
54053
|
+
type,
|
|
54054
|
+
/*isProperty*/
|
|
54055
|
+
true
|
|
54056
|
+
) : type;
|
|
54014
54057
|
}
|
|
54015
54058
|
}
|
|
54016
54059
|
function getTypeOfEnumMember(symbol) {
|
|
@@ -62490,7 +62533,7 @@ ${lanes.join("\n")}
|
|
|
62490
62533
|
0 /* None */
|
|
62491
62534
|
);
|
|
62492
62535
|
}
|
|
62493
|
-
} else if (result2 && isNonGenericObjectType(target2) && !isArrayOrTupleType(target2) && source2.flags & 2097152 /* Intersection */ && getApparentType(source2).flags & 3670016 /* StructuredType */ && !some(source2.types, (t) => !!(getObjectFlags(t) & 262144 /* NonInferrableType */))) {
|
|
62536
|
+
} else if (result2 && isNonGenericObjectType(target2) && !isArrayOrTupleType(target2) && source2.flags & 2097152 /* Intersection */ && getApparentType(source2).flags & 3670016 /* StructuredType */ && !some(source2.types, (t) => t === target2 || !!(getObjectFlags(t) & 262144 /* NonInferrableType */))) {
|
|
62494
62537
|
result2 &= propertiesRelatedTo(
|
|
62495
62538
|
source2,
|
|
62496
62539
|
target2,
|
|
@@ -62711,6 +62754,7 @@ ${lanes.join("\n")}
|
|
|
62711
62754
|
} else if (targetFlags & 8388608 /* IndexedAccess */) {
|
|
62712
62755
|
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
62713
62756
|
if (result2 = isRelatedTo(source2.objectType, target2.objectType, 3 /* Both */, reportErrors2)) {
|
|
62757
|
+
instantiateType(source2.objectType, reportUnreliableMapper);
|
|
62714
62758
|
result2 &= isRelatedTo(source2.indexType, target2.indexType, 3 /* Both */, reportErrors2);
|
|
62715
62759
|
}
|
|
62716
62760
|
if (result2) {
|
|
@@ -65856,7 +65900,7 @@ ${lanes.join("\n")}
|
|
|
65856
65900
|
);
|
|
65857
65901
|
}
|
|
65858
65902
|
function isInAmbientOrTypeNode(node) {
|
|
65859
|
-
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeLiteralNode(n)));
|
|
65903
|
+
return !!(node.flags & 16777216 /* Ambient */ || findAncestor(node, (n) => isInterfaceDeclaration(n) || isTypeAliasDeclaration(n) || isTypeLiteralNode(n)));
|
|
65860
65904
|
}
|
|
65861
65905
|
function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
|
|
65862
65906
|
switch (node.kind) {
|
|
@@ -69004,6 +69048,16 @@ ${lanes.join("\n")}
|
|
|
69004
69048
|
const symbol = getSymbolOfDeclaration(element);
|
|
69005
69049
|
return getTypeOfPropertyOfContextualType(type, symbol.escapedName, getSymbolLinks(symbol).nameType);
|
|
69006
69050
|
}
|
|
69051
|
+
if (hasDynamicName(element)) {
|
|
69052
|
+
const name = getNameOfDeclaration(element);
|
|
69053
|
+
if (name && isComputedPropertyName(name)) {
|
|
69054
|
+
const exprType = checkExpression(name.expression);
|
|
69055
|
+
const propType = isTypeUsableAsPropertyName(exprType) && getTypeOfPropertyOfContextualType(type, getPropertyNameFromType(exprType));
|
|
69056
|
+
if (propType) {
|
|
69057
|
+
return propType;
|
|
69058
|
+
}
|
|
69059
|
+
}
|
|
69060
|
+
}
|
|
69007
69061
|
if (element.name) {
|
|
69008
69062
|
const nameType = getLiteralTypeFromPropertyName(element.name);
|
|
69009
69063
|
return mapType(
|
|
@@ -73777,7 +73831,7 @@ ${lanes.join("\n")}
|
|
|
73777
73831
|
}
|
|
73778
73832
|
function getNonArrayRestType(signature) {
|
|
73779
73833
|
const restType = getEffectiveRestType(signature);
|
|
73780
|
-
return restType && !isArrayType(restType) && !isTypeAny(restType)
|
|
73834
|
+
return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : void 0;
|
|
73781
73835
|
}
|
|
73782
73836
|
function getTypeOfFirstParameterOfSignature(signature) {
|
|
73783
73837
|
return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
|
|
@@ -78591,6 +78645,9 @@ ${lanes.join("\n")}
|
|
|
78591
78645
|
return;
|
|
78592
78646
|
}
|
|
78593
78647
|
if (isBindingPattern(node.name)) {
|
|
78648
|
+
if (isInAmbientOrTypeNode(node)) {
|
|
78649
|
+
return;
|
|
78650
|
+
}
|
|
78594
78651
|
const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 246 /* ForInStatement */;
|
|
78595
78652
|
const needCheckWidenedType = !some(node.name.elements, not(isOmittedExpression));
|
|
78596
78653
|
if (needCheckInitializer || needCheckWidenedType) {
|
|
@@ -88009,6 +88066,7 @@ ${lanes.join("\n")}
|
|
|
88009
88066
|
);
|
|
88010
88067
|
}
|
|
88011
88068
|
function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
|
|
88069
|
+
const { factory: factory2 } = flattenContext.context;
|
|
88012
88070
|
if (isComputedPropertyName(propertyName)) {
|
|
88013
88071
|
const argumentExpression = ensureIdentifier(
|
|
88014
88072
|
flattenContext,
|
|
@@ -88020,7 +88078,7 @@ ${lanes.join("\n")}
|
|
|
88020
88078
|
);
|
|
88021
88079
|
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
|
88022
88080
|
} else if (isStringOrNumericLiteralLike(propertyName)) {
|
|
88023
|
-
const argumentExpression =
|
|
88081
|
+
const argumentExpression = factory2.cloneNode(propertyName);
|
|
88024
88082
|
return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
|
|
88025
88083
|
} else {
|
|
88026
88084
|
const name = flattenContext.context.factory.createIdentifier(idText(propertyName));
|
|
@@ -88102,28 +88160,29 @@ ${lanes.join("\n")}
|
|
|
88102
88160
|
if (level === 0 /* LiftRestriction */ && !hasInvalidEscape(template)) {
|
|
88103
88161
|
return visitEachChild(node, visitor, context);
|
|
88104
88162
|
}
|
|
88163
|
+
const { factory: factory2 } = context;
|
|
88105
88164
|
if (isNoSubstitutionTemplateLiteral(template)) {
|
|
88106
|
-
cookedStrings.push(createTemplateCooked(template));
|
|
88107
|
-
rawStrings.push(getRawLiteral(template, currentSourceFile));
|
|
88165
|
+
cookedStrings.push(createTemplateCooked(factory2, template));
|
|
88166
|
+
rawStrings.push(getRawLiteral(factory2, template, currentSourceFile));
|
|
88108
88167
|
} else {
|
|
88109
|
-
cookedStrings.push(createTemplateCooked(template.head));
|
|
88110
|
-
rawStrings.push(getRawLiteral(template.head, currentSourceFile));
|
|
88168
|
+
cookedStrings.push(createTemplateCooked(factory2, template.head));
|
|
88169
|
+
rawStrings.push(getRawLiteral(factory2, template.head, currentSourceFile));
|
|
88111
88170
|
for (const templateSpan of template.templateSpans) {
|
|
88112
|
-
cookedStrings.push(createTemplateCooked(templateSpan.literal));
|
|
88113
|
-
rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
|
|
88171
|
+
cookedStrings.push(createTemplateCooked(factory2, templateSpan.literal));
|
|
88172
|
+
rawStrings.push(getRawLiteral(factory2, templateSpan.literal, currentSourceFile));
|
|
88114
88173
|
templateArguments.push(Debug.checkDefined(visitNode(templateSpan.expression, visitor, isExpression)));
|
|
88115
88174
|
}
|
|
88116
88175
|
}
|
|
88117
88176
|
const helperCall = context.getEmitHelperFactory().createTemplateObjectHelper(
|
|
88118
|
-
|
|
88119
|
-
|
|
88177
|
+
factory2.createArrayLiteralExpression(cookedStrings),
|
|
88178
|
+
factory2.createArrayLiteralExpression(rawStrings)
|
|
88120
88179
|
);
|
|
88121
88180
|
if (isExternalModule(currentSourceFile)) {
|
|
88122
|
-
const tempVar =
|
|
88181
|
+
const tempVar = factory2.createUniqueName("templateObject");
|
|
88123
88182
|
recordTaggedTemplateString(tempVar);
|
|
88124
|
-
templateArguments[0] =
|
|
88183
|
+
templateArguments[0] = factory2.createLogicalOr(
|
|
88125
88184
|
tempVar,
|
|
88126
|
-
|
|
88185
|
+
factory2.createAssignment(
|
|
88127
88186
|
tempVar,
|
|
88128
88187
|
helperCall
|
|
88129
88188
|
)
|
|
@@ -88131,17 +88190,17 @@ ${lanes.join("\n")}
|
|
|
88131
88190
|
} else {
|
|
88132
88191
|
templateArguments[0] = helperCall;
|
|
88133
88192
|
}
|
|
88134
|
-
return
|
|
88193
|
+
return factory2.createCallExpression(
|
|
88135
88194
|
tag,
|
|
88136
88195
|
/*typeArguments*/
|
|
88137
88196
|
void 0,
|
|
88138
88197
|
templateArguments
|
|
88139
88198
|
);
|
|
88140
88199
|
}
|
|
88141
|
-
function createTemplateCooked(template) {
|
|
88142
|
-
return template.templateFlags ?
|
|
88200
|
+
function createTemplateCooked(factory2, template) {
|
|
88201
|
+
return template.templateFlags ? factory2.createVoidZero() : factory2.createStringLiteral(template.text);
|
|
88143
88202
|
}
|
|
88144
|
-
function getRawLiteral(node, currentSourceFile) {
|
|
88203
|
+
function getRawLiteral(factory2, node, currentSourceFile) {
|
|
88145
88204
|
let text = node.rawText;
|
|
88146
88205
|
if (text === void 0) {
|
|
88147
88206
|
Debug.assertIsDefined(
|
|
@@ -88153,7 +88212,7 @@ ${lanes.join("\n")}
|
|
|
88153
88212
|
text = text.substring(1, text.length - (isLast ? 1 : 2));
|
|
88154
88213
|
}
|
|
88155
88214
|
text = text.replace(/\r\n?/g, "\n");
|
|
88156
|
-
return setTextRange(
|
|
88215
|
+
return setTextRange(factory2.createStringLiteral(text), node);
|
|
88157
88216
|
}
|
|
88158
88217
|
var ProcessLevel;
|
|
88159
88218
|
var init_taggedTemplate = __esm({
|
|
@@ -91628,12 +91687,14 @@ ${lanes.join("\n")}
|
|
|
91628
91687
|
if (privateIdentifierInfo.kind === "f" /* Field */) {
|
|
91629
91688
|
if (!privateIdentifierInfo.isStatic) {
|
|
91630
91689
|
return createPrivateInstanceFieldInitializer(
|
|
91690
|
+
factory2,
|
|
91631
91691
|
receiver,
|
|
91632
91692
|
visitNode(property.initializer, initializerVisitor, isExpression),
|
|
91633
91693
|
privateIdentifierInfo.brandCheckIdentifier
|
|
91634
91694
|
);
|
|
91635
91695
|
} else {
|
|
91636
91696
|
return createPrivateStaticFieldInitializer(
|
|
91697
|
+
factory2,
|
|
91637
91698
|
privateIdentifierInfo.variableName,
|
|
91638
91699
|
visitNode(property.initializer, initializerVisitor, isExpression)
|
|
91639
91700
|
);
|
|
@@ -91715,7 +91776,7 @@ ${lanes.join("\n")}
|
|
|
91715
91776
|
Debug.assert(weakSetName, "weakSetName should be set in private identifier environment");
|
|
91716
91777
|
statements.push(
|
|
91717
91778
|
factory2.createExpressionStatement(
|
|
91718
|
-
createPrivateInstanceMethodInitializer(receiver, weakSetName)
|
|
91779
|
+
createPrivateInstanceMethodInitializer(factory2, receiver, weakSetName)
|
|
91719
91780
|
)
|
|
91720
91781
|
);
|
|
91721
91782
|
}
|
|
@@ -92168,25 +92229,25 @@ ${lanes.join("\n")}
|
|
|
92168
92229
|
return void 0;
|
|
92169
92230
|
}
|
|
92170
92231
|
}
|
|
92171
|
-
function createPrivateStaticFieldInitializer(variableName, initializer) {
|
|
92172
|
-
return
|
|
92232
|
+
function createPrivateStaticFieldInitializer(factory2, variableName, initializer) {
|
|
92233
|
+
return factory2.createAssignment(
|
|
92173
92234
|
variableName,
|
|
92174
|
-
|
|
92175
|
-
|
|
92235
|
+
factory2.createObjectLiteralExpression([
|
|
92236
|
+
factory2.createPropertyAssignment("value", initializer || factory2.createVoidZero())
|
|
92176
92237
|
])
|
|
92177
92238
|
);
|
|
92178
92239
|
}
|
|
92179
|
-
function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
|
|
92180
|
-
return
|
|
92181
|
-
|
|
92240
|
+
function createPrivateInstanceFieldInitializer(factory2, receiver, initializer, weakMapName) {
|
|
92241
|
+
return factory2.createCallExpression(
|
|
92242
|
+
factory2.createPropertyAccessExpression(weakMapName, "set"),
|
|
92182
92243
|
/*typeArguments*/
|
|
92183
92244
|
void 0,
|
|
92184
|
-
[receiver, initializer ||
|
|
92245
|
+
[receiver, initializer || factory2.createVoidZero()]
|
|
92185
92246
|
);
|
|
92186
92247
|
}
|
|
92187
|
-
function createPrivateInstanceMethodInitializer(receiver, weakSetName) {
|
|
92188
|
-
return
|
|
92189
|
-
|
|
92248
|
+
function createPrivateInstanceMethodInitializer(factory2, receiver, weakSetName) {
|
|
92249
|
+
return factory2.createCallExpression(
|
|
92250
|
+
factory2.createPropertyAccessExpression(weakSetName, "add"),
|
|
92190
92251
|
/*typeArguments*/
|
|
92191
92252
|
void 0,
|
|
92192
92253
|
[receiver]
|
|
@@ -92208,6 +92269,7 @@ ${lanes.join("\n")}
|
|
|
92208
92269
|
// src/compiler/transformers/typeSerializer.ts
|
|
92209
92270
|
function createRuntimeTypeSerializer(context) {
|
|
92210
92271
|
const {
|
|
92272
|
+
factory: factory2,
|
|
92211
92273
|
hoistVariableDeclaration
|
|
92212
92274
|
} = context;
|
|
92213
92275
|
const resolver = context.getEmitResolver();
|
|
@@ -92247,9 +92309,9 @@ ${lanes.join("\n")}
|
|
|
92247
92309
|
case 260 /* ClassDeclaration */:
|
|
92248
92310
|
case 228 /* ClassExpression */:
|
|
92249
92311
|
case 171 /* MethodDeclaration */:
|
|
92250
|
-
return
|
|
92312
|
+
return factory2.createIdentifier("Function");
|
|
92251
92313
|
default:
|
|
92252
|
-
return
|
|
92314
|
+
return factory2.createVoidZero();
|
|
92253
92315
|
}
|
|
92254
92316
|
}
|
|
92255
92317
|
function serializeParameterTypesOfNode(node, container) {
|
|
@@ -92270,7 +92332,7 @@ ${lanes.join("\n")}
|
|
|
92270
92332
|
}
|
|
92271
92333
|
}
|
|
92272
92334
|
}
|
|
92273
|
-
return
|
|
92335
|
+
return factory2.createArrayLiteralExpression(expressions);
|
|
92274
92336
|
}
|
|
92275
92337
|
function getParametersOfDecoratedDeclaration(node, container) {
|
|
92276
92338
|
if (container && node.kind === 174 /* GetAccessor */) {
|
|
@@ -92285,39 +92347,39 @@ ${lanes.join("\n")}
|
|
|
92285
92347
|
if (isFunctionLike(node) && node.type) {
|
|
92286
92348
|
return serializeTypeNode(node.type);
|
|
92287
92349
|
} else if (isAsyncFunction(node)) {
|
|
92288
|
-
return
|
|
92350
|
+
return factory2.createIdentifier("Promise");
|
|
92289
92351
|
}
|
|
92290
|
-
return
|
|
92352
|
+
return factory2.createVoidZero();
|
|
92291
92353
|
}
|
|
92292
92354
|
function serializeTypeNode(node) {
|
|
92293
92355
|
if (node === void 0) {
|
|
92294
|
-
return
|
|
92356
|
+
return factory2.createIdentifier("Object");
|
|
92295
92357
|
}
|
|
92296
92358
|
node = skipTypeParentheses(node);
|
|
92297
92359
|
switch (node.kind) {
|
|
92298
92360
|
case 114 /* VoidKeyword */:
|
|
92299
92361
|
case 155 /* UndefinedKeyword */:
|
|
92300
92362
|
case 144 /* NeverKeyword */:
|
|
92301
|
-
return
|
|
92363
|
+
return factory2.createVoidZero();
|
|
92302
92364
|
case 181 /* FunctionType */:
|
|
92303
92365
|
case 182 /* ConstructorType */:
|
|
92304
|
-
return
|
|
92366
|
+
return factory2.createIdentifier("Function");
|
|
92305
92367
|
case 185 /* ArrayType */:
|
|
92306
92368
|
case 186 /* TupleType */:
|
|
92307
|
-
return
|
|
92369
|
+
return factory2.createIdentifier("Array");
|
|
92308
92370
|
case 179 /* TypePredicate */:
|
|
92309
|
-
return node.assertsModifier ?
|
|
92371
|
+
return node.assertsModifier ? factory2.createVoidZero() : factory2.createIdentifier("Boolean");
|
|
92310
92372
|
case 134 /* BooleanKeyword */:
|
|
92311
|
-
return
|
|
92373
|
+
return factory2.createIdentifier("Boolean");
|
|
92312
92374
|
case 200 /* TemplateLiteralType */:
|
|
92313
92375
|
case 152 /* StringKeyword */:
|
|
92314
|
-
return
|
|
92376
|
+
return factory2.createIdentifier("String");
|
|
92315
92377
|
case 149 /* ObjectKeyword */:
|
|
92316
|
-
return
|
|
92378
|
+
return factory2.createIdentifier("Object");
|
|
92317
92379
|
case 198 /* LiteralType */:
|
|
92318
92380
|
return serializeLiteralOfLiteralTypeNode(node.literal);
|
|
92319
92381
|
case 148 /* NumberKeyword */:
|
|
92320
|
-
return
|
|
92382
|
+
return factory2.createIdentifier("Number");
|
|
92321
92383
|
case 160 /* BigIntKeyword */:
|
|
92322
92384
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92323
92385
|
case 153 /* SymbolKeyword */:
|
|
@@ -92369,13 +92431,13 @@ ${lanes.join("\n")}
|
|
|
92369
92431
|
default:
|
|
92370
92432
|
return Debug.failBadSyntaxKind(node);
|
|
92371
92433
|
}
|
|
92372
|
-
return
|
|
92434
|
+
return factory2.createIdentifier("Object");
|
|
92373
92435
|
}
|
|
92374
92436
|
function serializeLiteralOfLiteralTypeNode(node) {
|
|
92375
92437
|
switch (node.kind) {
|
|
92376
92438
|
case 10 /* StringLiteral */:
|
|
92377
92439
|
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
92378
|
-
return
|
|
92440
|
+
return factory2.createIdentifier("String");
|
|
92379
92441
|
case 221 /* PrefixUnaryExpression */: {
|
|
92380
92442
|
const operand = node.operand;
|
|
92381
92443
|
switch (operand.kind) {
|
|
@@ -92387,14 +92449,14 @@ ${lanes.join("\n")}
|
|
|
92387
92449
|
}
|
|
92388
92450
|
}
|
|
92389
92451
|
case 8 /* NumericLiteral */:
|
|
92390
|
-
return
|
|
92452
|
+
return factory2.createIdentifier("Number");
|
|
92391
92453
|
case 9 /* BigIntLiteral */:
|
|
92392
92454
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92393
92455
|
case 110 /* TrueKeyword */:
|
|
92394
92456
|
case 95 /* FalseKeyword */:
|
|
92395
|
-
return
|
|
92457
|
+
return factory2.createIdentifier("Boolean");
|
|
92396
92458
|
case 104 /* NullKeyword */:
|
|
92397
|
-
return
|
|
92459
|
+
return factory2.createVoidZero();
|
|
92398
92460
|
default:
|
|
92399
92461
|
return Debug.failBadSyntaxKind(node);
|
|
92400
92462
|
}
|
|
@@ -92405,16 +92467,16 @@ ${lanes.join("\n")}
|
|
|
92405
92467
|
typeNode = skipTypeParentheses(typeNode);
|
|
92406
92468
|
if (typeNode.kind === 144 /* NeverKeyword */) {
|
|
92407
92469
|
if (isIntersection)
|
|
92408
|
-
return
|
|
92470
|
+
return factory2.createVoidZero();
|
|
92409
92471
|
continue;
|
|
92410
92472
|
}
|
|
92411
92473
|
if (typeNode.kind === 157 /* UnknownKeyword */) {
|
|
92412
92474
|
if (!isIntersection)
|
|
92413
|
-
return
|
|
92475
|
+
return factory2.createIdentifier("Object");
|
|
92414
92476
|
continue;
|
|
92415
92477
|
}
|
|
92416
92478
|
if (typeNode.kind === 131 /* AnyKeyword */) {
|
|
92417
|
-
return
|
|
92479
|
+
return factory2.createIdentifier("Object");
|
|
92418
92480
|
}
|
|
92419
92481
|
if (!strictNullChecks && (isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 155 /* UndefinedKeyword */)) {
|
|
92420
92482
|
continue;
|
|
@@ -92425,13 +92487,13 @@ ${lanes.join("\n")}
|
|
|
92425
92487
|
}
|
|
92426
92488
|
if (serializedType) {
|
|
92427
92489
|
if (!equateSerializedTypeNodes(serializedType, serializedConstituent)) {
|
|
92428
|
-
return
|
|
92490
|
+
return factory2.createIdentifier("Object");
|
|
92429
92491
|
}
|
|
92430
92492
|
} else {
|
|
92431
92493
|
serializedType = serializedConstituent;
|
|
92432
92494
|
}
|
|
92433
92495
|
}
|
|
92434
|
-
return serializedType != null ? serializedType :
|
|
92496
|
+
return serializedType != null ? serializedType : factory2.createVoidZero();
|
|
92435
92497
|
}
|
|
92436
92498
|
function equateSerializedTypeNodes(left, right) {
|
|
92437
92499
|
return (
|
|
@@ -92465,48 +92527,48 @@ ${lanes.join("\n")}
|
|
|
92465
92527
|
switch (kind) {
|
|
92466
92528
|
case 0 /* Unknown */:
|
|
92467
92529
|
if (findAncestor(node, (n) => n.parent && isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n))) {
|
|
92468
|
-
return
|
|
92530
|
+
return factory2.createIdentifier("Object");
|
|
92469
92531
|
}
|
|
92470
92532
|
const serialized = serializeEntityNameAsExpressionFallback(node.typeName);
|
|
92471
|
-
const temp =
|
|
92472
|
-
return
|
|
92473
|
-
|
|
92533
|
+
const temp = factory2.createTempVariable(hoistVariableDeclaration);
|
|
92534
|
+
return factory2.createConditionalExpression(
|
|
92535
|
+
factory2.createTypeCheck(factory2.createAssignment(temp, serialized), "function"),
|
|
92474
92536
|
/*questionToken*/
|
|
92475
92537
|
void 0,
|
|
92476
92538
|
temp,
|
|
92477
92539
|
/*colonToken*/
|
|
92478
92540
|
void 0,
|
|
92479
|
-
|
|
92541
|
+
factory2.createIdentifier("Object")
|
|
92480
92542
|
);
|
|
92481
92543
|
case 1 /* TypeWithConstructSignatureAndValue */:
|
|
92482
92544
|
return serializeEntityNameAsExpression(node.typeName);
|
|
92483
92545
|
case 2 /* VoidNullableOrNeverType */:
|
|
92484
|
-
return
|
|
92546
|
+
return factory2.createVoidZero();
|
|
92485
92547
|
case 4 /* BigIntLikeType */:
|
|
92486
92548
|
return getGlobalConstructor("BigInt", 7 /* ES2020 */);
|
|
92487
92549
|
case 6 /* BooleanType */:
|
|
92488
|
-
return
|
|
92550
|
+
return factory2.createIdentifier("Boolean");
|
|
92489
92551
|
case 3 /* NumberLikeType */:
|
|
92490
|
-
return
|
|
92552
|
+
return factory2.createIdentifier("Number");
|
|
92491
92553
|
case 5 /* StringLikeType */:
|
|
92492
|
-
return
|
|
92554
|
+
return factory2.createIdentifier("String");
|
|
92493
92555
|
case 7 /* ArrayLikeType */:
|
|
92494
|
-
return
|
|
92556
|
+
return factory2.createIdentifier("Array");
|
|
92495
92557
|
case 8 /* ESSymbolType */:
|
|
92496
92558
|
return getGlobalConstructor("Symbol", 2 /* ES2015 */);
|
|
92497
92559
|
case 10 /* TypeWithCallSignature */:
|
|
92498
|
-
return
|
|
92560
|
+
return factory2.createIdentifier("Function");
|
|
92499
92561
|
case 9 /* Promise */:
|
|
92500
|
-
return
|
|
92562
|
+
return factory2.createIdentifier("Promise");
|
|
92501
92563
|
case 11 /* ObjectType */:
|
|
92502
|
-
return
|
|
92564
|
+
return factory2.createIdentifier("Object");
|
|
92503
92565
|
default:
|
|
92504
92566
|
return Debug.assertNever(kind);
|
|
92505
92567
|
}
|
|
92506
92568
|
}
|
|
92507
92569
|
function createCheckedValue(left, right) {
|
|
92508
|
-
return
|
|
92509
|
-
|
|
92570
|
+
return factory2.createLogicalAnd(
|
|
92571
|
+
factory2.createStrictInequality(factory2.createTypeOfExpression(left), factory2.createStringLiteral("undefined")),
|
|
92510
92572
|
right
|
|
92511
92573
|
);
|
|
92512
92574
|
}
|
|
@@ -92519,13 +92581,13 @@ ${lanes.join("\n")}
|
|
|
92519
92581
|
return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
|
|
92520
92582
|
}
|
|
92521
92583
|
const left = serializeEntityNameAsExpressionFallback(node.left);
|
|
92522
|
-
const temp =
|
|
92523
|
-
return
|
|
92524
|
-
|
|
92584
|
+
const temp = factory2.createTempVariable(hoistVariableDeclaration);
|
|
92585
|
+
return factory2.createLogicalAnd(
|
|
92586
|
+
factory2.createLogicalAnd(
|
|
92525
92587
|
left.left,
|
|
92526
|
-
|
|
92588
|
+
factory2.createStrictInequality(factory2.createAssignment(temp, left.right), factory2.createVoidZero())
|
|
92527
92589
|
),
|
|
92528
|
-
|
|
92590
|
+
factory2.createPropertyAccessExpression(temp, node.right)
|
|
92529
92591
|
);
|
|
92530
92592
|
}
|
|
92531
92593
|
function serializeEntityNameAsExpression(node) {
|
|
@@ -92540,21 +92602,21 @@ ${lanes.join("\n")}
|
|
|
92540
92602
|
}
|
|
92541
92603
|
}
|
|
92542
92604
|
function serializeQualifiedNameAsExpression(node) {
|
|
92543
|
-
return
|
|
92605
|
+
return factory2.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
|
|
92544
92606
|
}
|
|
92545
92607
|
function getGlobalConstructorWithFallback(name) {
|
|
92546
|
-
return
|
|
92547
|
-
|
|
92608
|
+
return factory2.createConditionalExpression(
|
|
92609
|
+
factory2.createTypeCheck(factory2.createIdentifier(name), "function"),
|
|
92548
92610
|
/*questionToken*/
|
|
92549
92611
|
void 0,
|
|
92550
|
-
|
|
92612
|
+
factory2.createIdentifier(name),
|
|
92551
92613
|
/*colonToken*/
|
|
92552
92614
|
void 0,
|
|
92553
|
-
|
|
92615
|
+
factory2.createIdentifier("Object")
|
|
92554
92616
|
);
|
|
92555
92617
|
}
|
|
92556
92618
|
function getGlobalConstructor(name, minLanguageVersion) {
|
|
92557
|
-
return languageVersion < minLanguageVersion ? getGlobalConstructorWithFallback(name) :
|
|
92619
|
+
return languageVersion < minLanguageVersion ? getGlobalConstructorWithFallback(name) : factory2.createIdentifier(name);
|
|
92558
92620
|
}
|
|
92559
92621
|
}
|
|
92560
92622
|
var init_typeSerializer = __esm({
|
|
@@ -107500,7 +107562,7 @@ ${lanes.join("\n")}
|
|
|
107500
107562
|
}
|
|
107501
107563
|
const newParam = factory2.updateParameterDeclaration(
|
|
107502
107564
|
p,
|
|
107503
|
-
maskModifiers(p, modifierMask),
|
|
107565
|
+
maskModifiers(factory2, p, modifierMask),
|
|
107504
107566
|
p.dotDotDotToken,
|
|
107505
107567
|
filterBindingPatternInitializersAndRenamings(p.name),
|
|
107506
107568
|
resolver.isOptionalParameter(p) ? p.questionToken || factory2.createToken(57 /* QuestionToken */) : void 0,
|
|
@@ -108614,8 +108676,8 @@ ${lanes.join("\n")}
|
|
|
108614
108676
|
}
|
|
108615
108677
|
return false;
|
|
108616
108678
|
}
|
|
108617
|
-
function maskModifiers(node, modifierMask, modifierAdditions) {
|
|
108618
|
-
return
|
|
108679
|
+
function maskModifiers(factory2, node, modifierMask, modifierAdditions) {
|
|
108680
|
+
return factory2.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
|
|
108619
108681
|
}
|
|
108620
108682
|
function maskModifierFlags(node, modifierMask = 258047 /* All */ ^ 4 /* Public */, modifierAdditions = 0 /* None */) {
|
|
108621
108683
|
let flags = getEffectiveModifierFlags(node) & modifierMask | modifierAdditions;
|
|
@@ -121571,7 +121633,7 @@ ${lanes.join("\n")}
|
|
|
121571
121633
|
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
121572
121634
|
}
|
|
121573
121635
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
121574
|
-
return resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
121636
|
+
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
121575
121637
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
121576
121638
|
if (cachedDirectoryStructureHost) {
|
|
121577
121639
|
cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
|
@@ -121582,7 +121644,7 @@ ${lanes.join("\n")}
|
|
|
121582
121644
|
if (dirPath) {
|
|
121583
121645
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
121584
121646
|
}
|
|
121585
|
-
}, 1 /* Recursive */);
|
|
121647
|
+
}, 1 /* Recursive */) : noopFileWatcher;
|
|
121586
121648
|
}
|
|
121587
121649
|
function updateTypeRootsWatch() {
|
|
121588
121650
|
const options = resolutionHost.getCompilationSettings();
|
|
@@ -121590,7 +121652,7 @@ ${lanes.join("\n")}
|
|
|
121590
121652
|
closeTypeRootsWatch();
|
|
121591
121653
|
return;
|
|
121592
121654
|
}
|
|
121593
|
-
const typeRoots = getEffectiveTypeRoots(options, {
|
|
121655
|
+
const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
|
|
121594
121656
|
if (typeRoots) {
|
|
121595
121657
|
mutateMap(
|
|
121596
121658
|
typeRootsWatches,
|
|
@@ -121604,7 +121666,9 @@ ${lanes.join("\n")}
|
|
|
121604
121666
|
closeTypeRootsWatch();
|
|
121605
121667
|
}
|
|
121606
121668
|
}
|
|
121607
|
-
function
|
|
121669
|
+
function canWatchTypeRootPath(nodeTypesDirectory) {
|
|
121670
|
+
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
121671
|
+
return true;
|
|
121608
121672
|
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
|
|
121609
121673
|
const dirPath = resolutionHost.toPath(dir);
|
|
121610
121674
|
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
@@ -131633,6 +131697,10 @@ ${lanes.join("\n")}
|
|
|
131633
131697
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
131634
131698
|
}
|
|
131635
131699
|
}
|
|
131700
|
+
const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
|
|
131701
|
+
if (jsdocTypedefNode) {
|
|
131702
|
+
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
131703
|
+
}
|
|
131636
131704
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
131637
131705
|
diags.push(createDiagnosticForNode(node.name || node, Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types));
|
|
131638
131706
|
}
|
|
@@ -133448,18 +133516,6 @@ ${lanes.join("\n")}
|
|
|
133448
133516
|
synchronizeHostData();
|
|
133449
133517
|
return ts_FindAllReferences_exports.getImplementationsAtPosition(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
133450
133518
|
}
|
|
133451
|
-
function getOccurrencesAtPosition(fileName, position) {
|
|
133452
|
-
return flatMap(
|
|
133453
|
-
getDocumentHighlights(fileName, position, [fileName]),
|
|
133454
|
-
(entry) => entry.highlightSpans.map((highlightSpan) => ({
|
|
133455
|
-
fileName: entry.fileName,
|
|
133456
|
-
textSpan: highlightSpan.textSpan,
|
|
133457
|
-
isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */,
|
|
133458
|
-
...highlightSpan.isInString && { isInString: true },
|
|
133459
|
-
...highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan }
|
|
133460
|
-
}))
|
|
133461
|
-
);
|
|
133462
|
-
}
|
|
133463
133519
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
133464
133520
|
const normalizedFileName = normalizePath(fileName);
|
|
133465
133521
|
Debug.assert(filesToSearch.some((f) => normalizePath(f) === normalizedFileName));
|
|
@@ -133652,22 +133708,22 @@ ${lanes.join("\n")}
|
|
|
133652
133708
|
}
|
|
133653
133709
|
return [];
|
|
133654
133710
|
}
|
|
133655
|
-
function getCodeFixesAtPosition(fileName, start, end,
|
|
133711
|
+
function getCodeFixesAtPosition(fileName, start, end, errorCodes64, formatOptions, preferences = emptyOptions) {
|
|
133656
133712
|
synchronizeHostData();
|
|
133657
133713
|
const sourceFile = getValidSourceFile(fileName);
|
|
133658
133714
|
const span = createTextSpanFromBounds(start, end);
|
|
133659
133715
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
133660
|
-
return flatMap(deduplicate(
|
|
133716
|
+
return flatMap(deduplicate(errorCodes64, equateValues, compareValues), (errorCode) => {
|
|
133661
133717
|
cancellationToken.throwIfCancellationRequested();
|
|
133662
133718
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
133663
133719
|
});
|
|
133664
133720
|
}
|
|
133665
|
-
function getCombinedCodeFix(scope,
|
|
133721
|
+
function getCombinedCodeFix(scope, fixId52, formatOptions, preferences = emptyOptions) {
|
|
133666
133722
|
synchronizeHostData();
|
|
133667
133723
|
Debug.assert(scope.type === "file");
|
|
133668
133724
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
133669
133725
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
133670
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
133726
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId52, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
133671
133727
|
}
|
|
133672
133728
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
133673
133729
|
var _a3;
|
|
@@ -134089,7 +134145,6 @@ ${lanes.join("\n")}
|
|
|
134089
134145
|
getReferencesAtPosition,
|
|
134090
134146
|
findReferences,
|
|
134091
134147
|
getFileReferences,
|
|
134092
|
-
getOccurrencesAtPosition,
|
|
134093
134148
|
getDocumentHighlights,
|
|
134094
134149
|
getNameOrDottedNameSpan,
|
|
134095
134150
|
getBreakpointStatementAtPosition,
|
|
@@ -134915,7 +134970,6 @@ ${lanes.join("\n")}
|
|
|
134915
134970
|
"getTypeDefinitionAtPosition",
|
|
134916
134971
|
"getReferencesAtPosition",
|
|
134917
134972
|
"findReferences",
|
|
134918
|
-
"getOccurrencesAtPosition",
|
|
134919
134973
|
"getDocumentHighlights",
|
|
134920
134974
|
"getNavigateToItems",
|
|
134921
134975
|
"getRenameInfo",
|
|
@@ -135499,12 +135553,6 @@ ${lanes.join("\n")}
|
|
|
135499
135553
|
() => this.languageService.getFileReferences(fileName)
|
|
135500
135554
|
);
|
|
135501
135555
|
}
|
|
135502
|
-
getOccurrencesAtPosition(fileName, position) {
|
|
135503
|
-
return this.forwardJSONCall(
|
|
135504
|
-
`getOccurrencesAtPosition('${fileName}', ${position})`,
|
|
135505
|
-
() => this.languageService.getOccurrencesAtPosition(fileName, position)
|
|
135506
|
-
);
|
|
135507
|
-
}
|
|
135508
135556
|
getDocumentHighlights(fileName, position, filesToSearch) {
|
|
135509
135557
|
return this.forwardJSONCall(
|
|
135510
135558
|
`getDocumentHighlights('${fileName}', ${position})`,
|
|
@@ -137138,23 +137186,23 @@ ${lanes.join("\n")}
|
|
|
137138
137186
|
void 0
|
|
137139
137187
|
);
|
|
137140
137188
|
}
|
|
137141
|
-
function createCodeFixAction(fixName8, changes, description2,
|
|
137142
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
137189
|
+
function createCodeFixAction(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
137190
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, diagnosticToString(fixAllDescription), command);
|
|
137143
137191
|
}
|
|
137144
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description2,
|
|
137145
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes,
|
|
137192
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description2, fixId52, fixAllDescription, command) {
|
|
137193
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description2), changes, fixId52, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
137146
137194
|
}
|
|
137147
|
-
function createCodeFixActionWorker(fixName8, description2, changes,
|
|
137148
|
-
return { fixName: fixName8, description: description2, changes, fixId:
|
|
137195
|
+
function createCodeFixActionWorker(fixName8, description2, changes, fixId52, fixAllDescription, command) {
|
|
137196
|
+
return { fixName: fixName8, description: description2, changes, fixId: fixId52, fixAllDescription, commands: command ? [command] : void 0 };
|
|
137149
137197
|
}
|
|
137150
137198
|
function registerCodeFix(reg) {
|
|
137151
137199
|
for (const error of reg.errorCodes) {
|
|
137152
137200
|
errorCodeToFixes.add(String(error), reg);
|
|
137153
137201
|
}
|
|
137154
137202
|
if (reg.fixIds) {
|
|
137155
|
-
for (const
|
|
137156
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
137157
|
-
fixIdToRegistration.set(
|
|
137203
|
+
for (const fixId52 of reg.fixIds) {
|
|
137204
|
+
Debug.assert(!fixIdToRegistration.has(fixId52));
|
|
137205
|
+
fixIdToRegistration.set(fixId52, reg);
|
|
137158
137206
|
}
|
|
137159
137207
|
}
|
|
137160
137208
|
}
|
|
@@ -137162,17 +137210,17 @@ ${lanes.join("\n")}
|
|
|
137162
137210
|
return arrayFrom(errorCodeToFixes.keys());
|
|
137163
137211
|
}
|
|
137164
137212
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
137165
|
-
const { errorCodes:
|
|
137213
|
+
const { errorCodes: errorCodes64 } = registration;
|
|
137166
137214
|
let maybeFixableDiagnostics = 0;
|
|
137167
137215
|
for (const diag2 of diagnostics) {
|
|
137168
|
-
if (contains(
|
|
137216
|
+
if (contains(errorCodes64, diag2.code))
|
|
137169
137217
|
maybeFixableDiagnostics++;
|
|
137170
137218
|
if (maybeFixableDiagnostics > 1)
|
|
137171
137219
|
break;
|
|
137172
137220
|
}
|
|
137173
137221
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
137174
|
-
return ({ fixId:
|
|
137175
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
137222
|
+
return ({ fixId: fixId52, fixAllDescription, ...action }) => {
|
|
137223
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId52, fixAllDescription };
|
|
137176
137224
|
};
|
|
137177
137225
|
}
|
|
137178
137226
|
function getFixes(context) {
|
|
@@ -137189,14 +137237,14 @@ ${lanes.join("\n")}
|
|
|
137189
137237
|
function createFileTextChanges(fileName, textChanges2) {
|
|
137190
137238
|
return { fileName, textChanges: textChanges2 };
|
|
137191
137239
|
}
|
|
137192
|
-
function codeFixAll(context,
|
|
137240
|
+
function codeFixAll(context, errorCodes64, use) {
|
|
137193
137241
|
const commands = [];
|
|
137194
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
137242
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes64, (diag2) => use(t, diag2, commands)));
|
|
137195
137243
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
137196
137244
|
}
|
|
137197
|
-
function eachDiagnostic(context,
|
|
137245
|
+
function eachDiagnostic(context, errorCodes64, cb) {
|
|
137198
137246
|
for (const diag2 of getDiagnostics(context)) {
|
|
137199
|
-
if (contains(
|
|
137247
|
+
if (contains(errorCodes64, diag2.code)) {
|
|
137200
137248
|
cb(diag2);
|
|
137201
137249
|
}
|
|
137202
137250
|
}
|
|
@@ -139778,32 +139826,96 @@ ${lanes.join("\n")}
|
|
|
139778
139826
|
});
|
|
139779
139827
|
|
|
139780
139828
|
// src/services/codefixes/convertToTypeOnlyImport.ts
|
|
139781
|
-
function
|
|
139782
|
-
|
|
139829
|
+
function getDeclaration2(sourceFile, pos) {
|
|
139830
|
+
const { parent: parent2 } = getTokenAtPosition(sourceFile, pos);
|
|
139831
|
+
return isImportSpecifier(parent2) || isImportDeclaration(parent2) && parent2.importClause ? parent2 : void 0;
|
|
139783
139832
|
}
|
|
139784
|
-
function
|
|
139785
|
-
if (
|
|
139786
|
-
|
|
139787
|
-
|
|
139788
|
-
|
|
139789
|
-
|
|
139790
|
-
|
|
139791
|
-
|
|
139792
|
-
changes.insertNodeBefore(context.sourceFile, importDeclaration, factory.updateImportDeclaration(
|
|
139793
|
-
importDeclaration,
|
|
139794
|
-
/*modifiers*/
|
|
139795
|
-
void 0,
|
|
139796
|
-
factory.createImportClause(
|
|
139797
|
-
/*isTypeOnly*/
|
|
139798
|
-
true,
|
|
139799
|
-
importClause.name,
|
|
139800
|
-
/*namedBindings*/
|
|
139801
|
-
void 0
|
|
139802
|
-
),
|
|
139803
|
-
importDeclaration.moduleSpecifier,
|
|
139804
|
-
/*assertClause*/
|
|
139805
|
-
void 0
|
|
139833
|
+
function doChange4(changes, sourceFile, declaration) {
|
|
139834
|
+
if (isImportSpecifier(declaration)) {
|
|
139835
|
+
changes.replaceNode(sourceFile, declaration, factory.updateImportSpecifier(
|
|
139836
|
+
declaration,
|
|
139837
|
+
/*isTypeOnly*/
|
|
139838
|
+
true,
|
|
139839
|
+
declaration.propertyName,
|
|
139840
|
+
declaration.name
|
|
139806
139841
|
));
|
|
139842
|
+
} else {
|
|
139843
|
+
const importClause = declaration.importClause;
|
|
139844
|
+
if (importClause.name && importClause.namedBindings) {
|
|
139845
|
+
changes.replaceNodeWithNodes(sourceFile, declaration, [
|
|
139846
|
+
factory.createImportDeclaration(
|
|
139847
|
+
getSynthesizedDeepClones(
|
|
139848
|
+
declaration.modifiers,
|
|
139849
|
+
/*includeTrivia*/
|
|
139850
|
+
true
|
|
139851
|
+
),
|
|
139852
|
+
factory.createImportClause(
|
|
139853
|
+
/*isTypeOnly*/
|
|
139854
|
+
true,
|
|
139855
|
+
getSynthesizedDeepClone(
|
|
139856
|
+
importClause.name,
|
|
139857
|
+
/*includeTrivia*/
|
|
139858
|
+
true
|
|
139859
|
+
),
|
|
139860
|
+
/*namedBindings*/
|
|
139861
|
+
void 0
|
|
139862
|
+
),
|
|
139863
|
+
getSynthesizedDeepClone(
|
|
139864
|
+
declaration.moduleSpecifier,
|
|
139865
|
+
/*includeTrivia*/
|
|
139866
|
+
true
|
|
139867
|
+
),
|
|
139868
|
+
getSynthesizedDeepClone(
|
|
139869
|
+
declaration.assertClause,
|
|
139870
|
+
/*includeTrivia*/
|
|
139871
|
+
true
|
|
139872
|
+
)
|
|
139873
|
+
),
|
|
139874
|
+
factory.createImportDeclaration(
|
|
139875
|
+
getSynthesizedDeepClones(
|
|
139876
|
+
declaration.modifiers,
|
|
139877
|
+
/*includeTrivia*/
|
|
139878
|
+
true
|
|
139879
|
+
),
|
|
139880
|
+
factory.createImportClause(
|
|
139881
|
+
/*isTypeOnly*/
|
|
139882
|
+
true,
|
|
139883
|
+
/*name*/
|
|
139884
|
+
void 0,
|
|
139885
|
+
getSynthesizedDeepClone(
|
|
139886
|
+
importClause.namedBindings,
|
|
139887
|
+
/*includeTrivia*/
|
|
139888
|
+
true
|
|
139889
|
+
)
|
|
139890
|
+
),
|
|
139891
|
+
getSynthesizedDeepClone(
|
|
139892
|
+
declaration.moduleSpecifier,
|
|
139893
|
+
/*includeTrivia*/
|
|
139894
|
+
true
|
|
139895
|
+
),
|
|
139896
|
+
getSynthesizedDeepClone(
|
|
139897
|
+
declaration.assertClause,
|
|
139898
|
+
/*includeTrivia*/
|
|
139899
|
+
true
|
|
139900
|
+
)
|
|
139901
|
+
)
|
|
139902
|
+
]);
|
|
139903
|
+
} else {
|
|
139904
|
+
const importDeclaration = factory.updateImportDeclaration(
|
|
139905
|
+
declaration,
|
|
139906
|
+
declaration.modifiers,
|
|
139907
|
+
factory.updateImportClause(
|
|
139908
|
+
importClause,
|
|
139909
|
+
/*isTypeOnly*/
|
|
139910
|
+
true,
|
|
139911
|
+
importClause.name,
|
|
139912
|
+
importClause.namedBindings
|
|
139913
|
+
),
|
|
139914
|
+
declaration.moduleSpecifier,
|
|
139915
|
+
declaration.assertClause
|
|
139916
|
+
);
|
|
139917
|
+
changes.replaceNode(sourceFile, declaration, importDeclaration);
|
|
139918
|
+
}
|
|
139807
139919
|
}
|
|
139808
139920
|
}
|
|
139809
139921
|
var errorCodes14, fixId13;
|
|
@@ -139812,30 +139924,181 @@ ${lanes.join("\n")}
|
|
|
139812
139924
|
"use strict";
|
|
139813
139925
|
init_ts4();
|
|
139814
139926
|
init_ts_codefix();
|
|
139815
|
-
errorCodes14 = [
|
|
139927
|
+
errorCodes14 = [
|
|
139928
|
+
Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error.code,
|
|
139929
|
+
Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code
|
|
139930
|
+
];
|
|
139816
139931
|
fixId13 = "convertToTypeOnlyImport";
|
|
139817
139932
|
registerCodeFix({
|
|
139818
139933
|
errorCodes: errorCodes14,
|
|
139819
139934
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
139820
|
-
const
|
|
139821
|
-
|
|
139822
|
-
|
|
139823
|
-
});
|
|
139824
|
-
if (changes.length) {
|
|
139935
|
+
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
139936
|
+
if (declaration) {
|
|
139937
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange4(t, context.sourceFile, declaration));
|
|
139825
139938
|
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_import, fixId13, Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)];
|
|
139826
139939
|
}
|
|
139940
|
+
return void 0;
|
|
139827
139941
|
},
|
|
139828
139942
|
fixIds: [fixId13],
|
|
139829
139943
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
139830
139944
|
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
139831
|
-
const
|
|
139832
|
-
|
|
139945
|
+
const declaration = getDeclaration2(diag2.file, diag2.start);
|
|
139946
|
+
if (declaration) {
|
|
139947
|
+
doChange4(changes, diag2.file, declaration);
|
|
139948
|
+
}
|
|
139833
139949
|
});
|
|
139834
139950
|
}
|
|
139835
139951
|
});
|
|
139836
139952
|
}
|
|
139837
139953
|
});
|
|
139838
139954
|
|
|
139955
|
+
// src/services/codefixes/convertTypedefToType.ts
|
|
139956
|
+
function doChange5(changes, node, sourceFile) {
|
|
139957
|
+
if (isJSDocTypedefTag(node)) {
|
|
139958
|
+
fixSingleTypeDef(changes, node, sourceFile);
|
|
139959
|
+
}
|
|
139960
|
+
}
|
|
139961
|
+
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
139962
|
+
if (!typeDefNode)
|
|
139963
|
+
return;
|
|
139964
|
+
const declaration = createDeclaration(typeDefNode);
|
|
139965
|
+
if (!declaration)
|
|
139966
|
+
return;
|
|
139967
|
+
const comment = typeDefNode.parent;
|
|
139968
|
+
changes.replaceNode(
|
|
139969
|
+
sourceFile,
|
|
139970
|
+
comment,
|
|
139971
|
+
declaration
|
|
139972
|
+
);
|
|
139973
|
+
}
|
|
139974
|
+
function createDeclaration(tag) {
|
|
139975
|
+
var _a2;
|
|
139976
|
+
const { typeExpression } = tag;
|
|
139977
|
+
if (!typeExpression)
|
|
139978
|
+
return;
|
|
139979
|
+
const typeName = (_a2 = tag.name) == null ? void 0 : _a2.getText();
|
|
139980
|
+
if (!typeName)
|
|
139981
|
+
return;
|
|
139982
|
+
if (typeExpression.kind === 325 /* JSDocTypeLiteral */) {
|
|
139983
|
+
return createInterfaceForTypeLiteral(typeName, typeExpression);
|
|
139984
|
+
}
|
|
139985
|
+
if (typeExpression.kind === 312 /* JSDocTypeExpression */) {
|
|
139986
|
+
return createTypeAliasForTypeExpression(typeName, typeExpression);
|
|
139987
|
+
}
|
|
139988
|
+
}
|
|
139989
|
+
function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
139990
|
+
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
139991
|
+
if (!some(propertySignatures))
|
|
139992
|
+
return;
|
|
139993
|
+
const interfaceDeclaration = factory.createInterfaceDeclaration(
|
|
139994
|
+
/*modifiers*/
|
|
139995
|
+
void 0,
|
|
139996
|
+
typeName,
|
|
139997
|
+
/*typeParameters*/
|
|
139998
|
+
void 0,
|
|
139999
|
+
/*heritageClauses*/
|
|
140000
|
+
void 0,
|
|
140001
|
+
propertySignatures
|
|
140002
|
+
);
|
|
140003
|
+
return interfaceDeclaration;
|
|
140004
|
+
}
|
|
140005
|
+
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
140006
|
+
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
140007
|
+
if (!typeReference)
|
|
140008
|
+
return;
|
|
140009
|
+
const declaration = factory.createTypeAliasDeclaration(
|
|
140010
|
+
/*modifiers*/
|
|
140011
|
+
void 0,
|
|
140012
|
+
factory.createIdentifier(typeName),
|
|
140013
|
+
/*typeParameters*/
|
|
140014
|
+
void 0,
|
|
140015
|
+
typeReference
|
|
140016
|
+
);
|
|
140017
|
+
return declaration;
|
|
140018
|
+
}
|
|
140019
|
+
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
140020
|
+
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
140021
|
+
if (!some(propertyTags))
|
|
140022
|
+
return;
|
|
140023
|
+
const getSignature = (tag) => {
|
|
140024
|
+
var _a2;
|
|
140025
|
+
const name = getPropertyName(tag);
|
|
140026
|
+
const type = (_a2 = tag.typeExpression) == null ? void 0 : _a2.type;
|
|
140027
|
+
const isOptional = tag.isBracketed;
|
|
140028
|
+
let typeReference;
|
|
140029
|
+
if (type && isJSDocTypeLiteral(type)) {
|
|
140030
|
+
const signatures = createSignatureFromTypeLiteral(type);
|
|
140031
|
+
typeReference = factory.createTypeLiteralNode(signatures);
|
|
140032
|
+
} else if (type) {
|
|
140033
|
+
typeReference = getSynthesizedDeepClone(type);
|
|
140034
|
+
}
|
|
140035
|
+
if (typeReference && name) {
|
|
140036
|
+
const questionToken = isOptional ? factory.createToken(57 /* QuestionToken */) : void 0;
|
|
140037
|
+
const prop = factory.createPropertySignature(
|
|
140038
|
+
/*modifiers*/
|
|
140039
|
+
void 0,
|
|
140040
|
+
name,
|
|
140041
|
+
questionToken,
|
|
140042
|
+
typeReference
|
|
140043
|
+
);
|
|
140044
|
+
return prop;
|
|
140045
|
+
}
|
|
140046
|
+
};
|
|
140047
|
+
const props = mapDefined(propertyTags, getSignature);
|
|
140048
|
+
return props;
|
|
140049
|
+
}
|
|
140050
|
+
function getPropertyName(tag) {
|
|
140051
|
+
return tag.name.kind === 79 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
140052
|
+
}
|
|
140053
|
+
function getJSDocTypedefNode(node) {
|
|
140054
|
+
if (hasJSDocNodes(node)) {
|
|
140055
|
+
return forEach(node.jsDoc, (node2) => {
|
|
140056
|
+
var _a2;
|
|
140057
|
+
return (_a2 = node2.tags) == null ? void 0 : _a2.find(isJSDocTypedefTag);
|
|
140058
|
+
});
|
|
140059
|
+
}
|
|
140060
|
+
return void 0;
|
|
140061
|
+
}
|
|
140062
|
+
var fixId14, errorCodes15;
|
|
140063
|
+
var init_convertTypedefToType = __esm({
|
|
140064
|
+
"src/services/codefixes/convertTypedefToType.ts"() {
|
|
140065
|
+
"use strict";
|
|
140066
|
+
init_ts4();
|
|
140067
|
+
init_ts_codefix();
|
|
140068
|
+
fixId14 = "convertTypedefToType";
|
|
140069
|
+
errorCodes15 = [Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type.code];
|
|
140070
|
+
registerCodeFix({
|
|
140071
|
+
fixIds: [fixId14],
|
|
140072
|
+
errorCodes: errorCodes15,
|
|
140073
|
+
getCodeActions(context) {
|
|
140074
|
+
const node = getTokenAtPosition(
|
|
140075
|
+
context.sourceFile,
|
|
140076
|
+
context.span.start
|
|
140077
|
+
);
|
|
140078
|
+
if (!node)
|
|
140079
|
+
return;
|
|
140080
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange5(t, node, context.sourceFile));
|
|
140081
|
+
if (changes.length > 0) {
|
|
140082
|
+
return [
|
|
140083
|
+
createCodeFixAction(
|
|
140084
|
+
fixId14,
|
|
140085
|
+
changes,
|
|
140086
|
+
Diagnostics.Convert_typedef_to_TypeScript_type,
|
|
140087
|
+
fixId14,
|
|
140088
|
+
Diagnostics.Convert_all_typedef_to_TypeScript_types
|
|
140089
|
+
)
|
|
140090
|
+
];
|
|
140091
|
+
}
|
|
140092
|
+
},
|
|
140093
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
|
|
140094
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
140095
|
+
if (node)
|
|
140096
|
+
doChange5(changes, node, diag2.file);
|
|
140097
|
+
})
|
|
140098
|
+
});
|
|
140099
|
+
}
|
|
140100
|
+
});
|
|
140101
|
+
|
|
139839
140102
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
139840
140103
|
function getInfo2(sourceFile, pos) {
|
|
139841
140104
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -139851,7 +140114,7 @@ ${lanes.join("\n")}
|
|
|
139851
140114
|
}
|
|
139852
140115
|
return void 0;
|
|
139853
140116
|
}
|
|
139854
|
-
function
|
|
140117
|
+
function doChange6(changes, sourceFile, { container, typeNode, constraint, name }) {
|
|
139855
140118
|
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
|
|
139856
140119
|
/*readonlyToken*/
|
|
139857
140120
|
void 0,
|
|
@@ -139870,16 +140133,16 @@ ${lanes.join("\n")}
|
|
|
139870
140133
|
void 0
|
|
139871
140134
|
));
|
|
139872
140135
|
}
|
|
139873
|
-
var
|
|
140136
|
+
var fixId15, errorCodes16;
|
|
139874
140137
|
var init_convertLiteralTypeToMappedType = __esm({
|
|
139875
140138
|
"src/services/codefixes/convertLiteralTypeToMappedType.ts"() {
|
|
139876
140139
|
"use strict";
|
|
139877
140140
|
init_ts4();
|
|
139878
140141
|
init_ts_codefix();
|
|
139879
|
-
|
|
139880
|
-
|
|
140142
|
+
fixId15 = "convertLiteralTypeToMappedType";
|
|
140143
|
+
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];
|
|
139881
140144
|
registerCodeFix({
|
|
139882
|
-
errorCodes:
|
|
140145
|
+
errorCodes: errorCodes16,
|
|
139883
140146
|
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
|
|
139884
140147
|
const { sourceFile, span } = context;
|
|
139885
140148
|
const info = getInfo2(sourceFile, span.start);
|
|
@@ -139887,14 +140150,14 @@ ${lanes.join("\n")}
|
|
|
139887
140150
|
return void 0;
|
|
139888
140151
|
}
|
|
139889
140152
|
const { name, constraint } = info;
|
|
139890
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
139891
|
-
return [createCodeFixAction(
|
|
140153
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange6(t, sourceFile, info));
|
|
140154
|
+
return [createCodeFixAction(fixId15, changes, [Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId15, Diagnostics.Convert_all_type_literals_to_mapped_type)];
|
|
139892
140155
|
},
|
|
139893
|
-
fixIds: [
|
|
139894
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
140156
|
+
fixIds: [fixId15],
|
|
140157
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes16, (changes, diag2) => {
|
|
139895
140158
|
const info = getInfo2(diag2.file, diag2.start);
|
|
139896
140159
|
if (info) {
|
|
139897
|
-
|
|
140160
|
+
doChange6(changes, diag2.file, info);
|
|
139898
140161
|
}
|
|
139899
140162
|
})
|
|
139900
140163
|
});
|
|
@@ -139953,31 +140216,31 @@ ${lanes.join("\n")}
|
|
|
139953
140216
|
const heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType);
|
|
139954
140217
|
return createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember));
|
|
139955
140218
|
}
|
|
139956
|
-
var
|
|
140219
|
+
var errorCodes17, fixId16;
|
|
139957
140220
|
var init_fixClassIncorrectlyImplementsInterface = __esm({
|
|
139958
140221
|
"src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts"() {
|
|
139959
140222
|
"use strict";
|
|
139960
140223
|
init_ts4();
|
|
139961
140224
|
init_ts_codefix();
|
|
139962
|
-
|
|
140225
|
+
errorCodes17 = [
|
|
139963
140226
|
Diagnostics.Class_0_incorrectly_implements_interface_1.code,
|
|
139964
140227
|
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code
|
|
139965
140228
|
];
|
|
139966
|
-
|
|
140229
|
+
fixId16 = "fixClassIncorrectlyImplementsInterface";
|
|
139967
140230
|
registerCodeFix({
|
|
139968
|
-
errorCodes:
|
|
140231
|
+
errorCodes: errorCodes17,
|
|
139969
140232
|
getCodeActions(context) {
|
|
139970
140233
|
const { sourceFile, span } = context;
|
|
139971
140234
|
const classDeclaration = getClass(sourceFile, span.start);
|
|
139972
140235
|
return mapDefined(getEffectiveImplementsTypeNodes(classDeclaration), (implementedTypeNode) => {
|
|
139973
140236
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences));
|
|
139974
|
-
return changes.length === 0 ? void 0 : createCodeFixAction(
|
|
140237
|
+
return changes.length === 0 ? void 0 : createCodeFixAction(fixId16, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId16, Diagnostics.Implement_all_unimplemented_interfaces);
|
|
139975
140238
|
});
|
|
139976
140239
|
},
|
|
139977
|
-
fixIds: [
|
|
140240
|
+
fixIds: [fixId16],
|
|
139978
140241
|
getAllCodeActions(context) {
|
|
139979
140242
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
139980
|
-
return codeFixAll(context,
|
|
140243
|
+
return codeFixAll(context, errorCodes17, (changes, diag2) => {
|
|
139981
140244
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
139982
140245
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
139983
140246
|
for (const implementedTypeNode of getEffectiveImplementsTypeNodes(classDeclaration)) {
|
|
@@ -141151,7 +141414,7 @@ ${lanes.join("\n")}
|
|
|
141151
141414
|
}
|
|
141152
141415
|
return !isStringANonContextualKeyword(res) ? res || "_" : `_${res}`;
|
|
141153
141416
|
}
|
|
141154
|
-
var importFixName, importFixId,
|
|
141417
|
+
var importFixName, importFixId, errorCodes18;
|
|
141155
141418
|
var init_importFixes = __esm({
|
|
141156
141419
|
"src/services/codefixes/importFixes.ts"() {
|
|
141157
141420
|
"use strict";
|
|
@@ -141159,7 +141422,7 @@ ${lanes.join("\n")}
|
|
|
141159
141422
|
init_ts_codefix();
|
|
141160
141423
|
importFixName = "import";
|
|
141161
141424
|
importFixId = "fixMissingImport";
|
|
141162
|
-
|
|
141425
|
+
errorCodes18 = [
|
|
141163
141426
|
Diagnostics.Cannot_find_name_0.code,
|
|
141164
141427
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
141165
141428
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
@@ -141171,7 +141434,7 @@ ${lanes.join("\n")}
|
|
|
141171
141434
|
Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code
|
|
141172
141435
|
];
|
|
141173
141436
|
registerCodeFix({
|
|
141174
|
-
errorCodes:
|
|
141437
|
+
errorCodes: errorCodes18,
|
|
141175
141438
|
getCodeActions(context) {
|
|
141176
141439
|
const { errorCode, preferences, sourceFile, span, program } = context;
|
|
141177
141440
|
const info = getFixInfos(
|
|
@@ -141206,7 +141469,7 @@ ${lanes.join("\n")}
|
|
|
141206
141469
|
host,
|
|
141207
141470
|
cancellationToken
|
|
141208
141471
|
);
|
|
141209
|
-
eachDiagnostic(context,
|
|
141472
|
+
eachDiagnostic(context, errorCodes18, (diag2) => importAdder.addImportFromDiagnostic(diag2, context));
|
|
141210
141473
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, importAdder.writeFixes));
|
|
141211
141474
|
}
|
|
141212
141475
|
});
|
|
@@ -141281,14 +141544,14 @@ ${lanes.join("\n")}
|
|
|
141281
141544
|
const contextualType = isExpression(node) ? checker.getContextualType(node) : void 0;
|
|
141282
141545
|
return contextualType || checker.getTypeAtLocation(node);
|
|
141283
141546
|
}
|
|
141284
|
-
var
|
|
141547
|
+
var fixId17, errorCodes19;
|
|
141285
141548
|
var init_fixAddMissingConstraint = __esm({
|
|
141286
141549
|
"src/services/codefixes/fixAddMissingConstraint.ts"() {
|
|
141287
141550
|
"use strict";
|
|
141288
141551
|
init_ts4();
|
|
141289
141552
|
init_ts_codefix();
|
|
141290
|
-
|
|
141291
|
-
|
|
141553
|
+
fixId17 = "addMissingConstraint";
|
|
141554
|
+
errorCodes19 = [
|
|
141292
141555
|
// We want errors this could be attached to:
|
|
141293
141556
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
141294
141557
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -141301,21 +141564,21 @@ ${lanes.join("\n")}
|
|
|
141301
141564
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
141302
141565
|
];
|
|
141303
141566
|
registerCodeFix({
|
|
141304
|
-
errorCodes:
|
|
141567
|
+
errorCodes: errorCodes19,
|
|
141305
141568
|
getCodeActions(context) {
|
|
141306
141569
|
const { sourceFile, span, program, preferences, host } = context;
|
|
141307
141570
|
const info = getInfo3(program, sourceFile, span);
|
|
141308
141571
|
if (info === void 0)
|
|
141309
141572
|
return;
|
|
141310
141573
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
141311
|
-
return [createCodeFixAction(
|
|
141574
|
+
return [createCodeFixAction(fixId17, changes, Diagnostics.Add_extends_constraint, fixId17, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
141312
141575
|
},
|
|
141313
|
-
fixIds: [
|
|
141576
|
+
fixIds: [fixId17],
|
|
141314
141577
|
getAllCodeActions: (context) => {
|
|
141315
141578
|
const { program, preferences, host } = context;
|
|
141316
141579
|
const seen = /* @__PURE__ */ new Map();
|
|
141317
141580
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
141318
|
-
eachDiagnostic(context,
|
|
141581
|
+
eachDiagnostic(context, errorCodes19, (diag2) => {
|
|
141319
141582
|
const info = getInfo3(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
141320
141583
|
if (info) {
|
|
141321
141584
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -141397,7 +141660,7 @@ ${lanes.join("\n")}
|
|
|
141397
141660
|
Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement));
|
|
141398
141661
|
return classElement;
|
|
141399
141662
|
}
|
|
141400
|
-
var fixName, fixAddOverrideId, fixRemoveOverrideId,
|
|
141663
|
+
var fixName, fixAddOverrideId, fixRemoveOverrideId, errorCodes20, errorCodeFixIdMap;
|
|
141401
141664
|
var init_fixOverrideModifier = __esm({
|
|
141402
141665
|
"src/services/codefixes/fixOverrideModifier.ts"() {
|
|
141403
141666
|
"use strict";
|
|
@@ -141406,7 +141669,7 @@ ${lanes.join("\n")}
|
|
|
141406
141669
|
fixName = "fixOverrideModifier";
|
|
141407
141670
|
fixAddOverrideId = "fixAddOverrideModifier";
|
|
141408
141671
|
fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
141409
|
-
|
|
141672
|
+
errorCodes20 = [
|
|
141410
141673
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
141411
141674
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
141412
141675
|
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
|
@@ -141470,20 +141733,20 @@ ${lanes.join("\n")}
|
|
|
141470
141733
|
}
|
|
141471
141734
|
};
|
|
141472
141735
|
registerCodeFix({
|
|
141473
|
-
errorCodes:
|
|
141736
|
+
errorCodes: errorCodes20,
|
|
141474
141737
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
141475
141738
|
const { errorCode, span } = context;
|
|
141476
141739
|
const info = errorCodeFixIdMap[errorCode];
|
|
141477
141740
|
if (!info)
|
|
141478
141741
|
return emptyArray;
|
|
141479
|
-
const { descriptions, fixId:
|
|
141742
|
+
const { descriptions, fixId: fixId52, fixAllDescriptions } = info;
|
|
141480
141743
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
141481
141744
|
return [
|
|
141482
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
141745
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId52, fixAllDescriptions)
|
|
141483
141746
|
];
|
|
141484
141747
|
},
|
|
141485
141748
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
141486
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141749
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes20, (changes, diag2) => {
|
|
141487
141750
|
const { code, start } = diag2;
|
|
141488
141751
|
const info = errorCodeFixIdMap[code];
|
|
141489
141752
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -141496,7 +141759,7 @@ ${lanes.join("\n")}
|
|
|
141496
141759
|
});
|
|
141497
141760
|
|
|
141498
141761
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
141499
|
-
function
|
|
141762
|
+
function doChange7(changes, sourceFile, node, preferences) {
|
|
141500
141763
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
141501
141764
|
const argumentsExpression = factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */);
|
|
141502
141765
|
changes.replaceNode(
|
|
@@ -141508,32 +141771,32 @@ ${lanes.join("\n")}
|
|
|
141508
141771
|
function getPropertyAccessExpression(sourceFile, pos) {
|
|
141509
141772
|
return cast(getTokenAtPosition(sourceFile, pos).parent, isPropertyAccessExpression);
|
|
141510
141773
|
}
|
|
141511
|
-
var
|
|
141774
|
+
var fixId18, errorCodes21;
|
|
141512
141775
|
var init_fixNoPropertyAccessFromIndexSignature = __esm({
|
|
141513
141776
|
"src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts"() {
|
|
141514
141777
|
"use strict";
|
|
141515
141778
|
init_ts4();
|
|
141516
141779
|
init_ts_codefix();
|
|
141517
|
-
|
|
141518
|
-
|
|
141780
|
+
fixId18 = "fixNoPropertyAccessFromIndexSignature";
|
|
141781
|
+
errorCodes21 = [
|
|
141519
141782
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
141520
141783
|
];
|
|
141521
141784
|
registerCodeFix({
|
|
141522
|
-
errorCodes:
|
|
141523
|
-
fixIds: [
|
|
141785
|
+
errorCodes: errorCodes21,
|
|
141786
|
+
fixIds: [fixId18],
|
|
141524
141787
|
getCodeActions(context) {
|
|
141525
141788
|
const { sourceFile, span, preferences } = context;
|
|
141526
141789
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
141527
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141528
|
-
return [createCodeFixAction(
|
|
141790
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange7(t, context.sourceFile, property, preferences));
|
|
141791
|
+
return [createCodeFixAction(fixId18, changes, [Diagnostics.Use_element_access_for_0, property.name.text], fixId18, Diagnostics.Use_element_access_for_all_undeclared_properties)];
|
|
141529
141792
|
},
|
|
141530
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141793
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => doChange7(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
141531
141794
|
});
|
|
141532
141795
|
}
|
|
141533
141796
|
});
|
|
141534
141797
|
|
|
141535
141798
|
// src/services/codefixes/fixImplicitThis.ts
|
|
141536
|
-
function
|
|
141799
|
+
function doChange8(changes, sourceFile, pos, checker) {
|
|
141537
141800
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
141538
141801
|
if (!isThis(token))
|
|
141539
141802
|
return void 0;
|
|
@@ -141574,27 +141837,27 @@ ${lanes.join("\n")}
|
|
|
141574
141837
|
}
|
|
141575
141838
|
}
|
|
141576
141839
|
}
|
|
141577
|
-
var
|
|
141840
|
+
var fixId19, errorCodes22;
|
|
141578
141841
|
var init_fixImplicitThis = __esm({
|
|
141579
141842
|
"src/services/codefixes/fixImplicitThis.ts"() {
|
|
141580
141843
|
"use strict";
|
|
141581
141844
|
init_ts4();
|
|
141582
141845
|
init_ts_codefix();
|
|
141583
|
-
|
|
141584
|
-
|
|
141846
|
+
fixId19 = "fixImplicitThis";
|
|
141847
|
+
errorCodes22 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
141585
141848
|
registerCodeFix({
|
|
141586
|
-
errorCodes:
|
|
141849
|
+
errorCodes: errorCodes22,
|
|
141587
141850
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
141588
141851
|
const { sourceFile, program, span } = context;
|
|
141589
141852
|
let diagnostic;
|
|
141590
141853
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
141591
|
-
diagnostic =
|
|
141854
|
+
diagnostic = doChange8(t, sourceFile, span.start, program.getTypeChecker());
|
|
141592
141855
|
});
|
|
141593
|
-
return diagnostic ? [createCodeFixAction(
|
|
141856
|
+
return diagnostic ? [createCodeFixAction(fixId19, changes, diagnostic, fixId19, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
141594
141857
|
},
|
|
141595
|
-
fixIds: [
|
|
141596
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
141597
|
-
|
|
141858
|
+
fixIds: [fixId19],
|
|
141859
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => {
|
|
141860
|
+
doChange8(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
141598
141861
|
})
|
|
141599
141862
|
});
|
|
141600
141863
|
}
|
|
@@ -141637,7 +141900,7 @@ ${lanes.join("\n")}
|
|
|
141637
141900
|
}
|
|
141638
141901
|
return void 0;
|
|
141639
141902
|
}
|
|
141640
|
-
function
|
|
141903
|
+
function doChange9(changes, program, { exportName, node, moduleSourceFile }) {
|
|
141641
141904
|
const exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
141642
141905
|
if (exportDeclaration) {
|
|
141643
141906
|
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
@@ -141719,32 +141982,32 @@ ${lanes.join("\n")}
|
|
|
141719
141982
|
const variableStatement = isVariableDeclaration(declaration) ? tryCast(declaration.parent.parent, isVariableStatement) : void 0;
|
|
141720
141983
|
return variableStatement && length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
141721
141984
|
}
|
|
141722
|
-
var
|
|
141985
|
+
var fixId20, errorCodes23;
|
|
141723
141986
|
var init_fixImportNonExportedMember = __esm({
|
|
141724
141987
|
"src/services/codefixes/fixImportNonExportedMember.ts"() {
|
|
141725
141988
|
"use strict";
|
|
141726
141989
|
init_ts4();
|
|
141727
141990
|
init_ts_codefix();
|
|
141728
|
-
|
|
141729
|
-
|
|
141991
|
+
fixId20 = "fixImportNonExportedMember";
|
|
141992
|
+
errorCodes23 = [
|
|
141730
141993
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
141731
141994
|
];
|
|
141732
141995
|
registerCodeFix({
|
|
141733
|
-
errorCodes:
|
|
141734
|
-
fixIds: [
|
|
141996
|
+
errorCodes: errorCodes23,
|
|
141997
|
+
fixIds: [fixId20],
|
|
141735
141998
|
getCodeActions(context) {
|
|
141736
141999
|
const { sourceFile, span, program } = context;
|
|
141737
142000
|
const info = getInfo4(sourceFile, span.start, program);
|
|
141738
142001
|
if (info === void 0)
|
|
141739
142002
|
return void 0;
|
|
141740
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141741
|
-
return [createCodeFixAction(
|
|
142003
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange9(t, program, info));
|
|
142004
|
+
return [createCodeFixAction(fixId20, changes, [Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId20, Diagnostics.Export_all_referenced_locals)];
|
|
141742
142005
|
},
|
|
141743
142006
|
getAllCodeActions(context) {
|
|
141744
142007
|
const { program } = context;
|
|
141745
142008
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
141746
142009
|
const exports = /* @__PURE__ */ new Map();
|
|
141747
|
-
eachDiagnostic(context,
|
|
142010
|
+
eachDiagnostic(context, errorCodes23, (diag2) => {
|
|
141748
142011
|
const info = getInfo4(diag2.file, diag2.start, program);
|
|
141749
142012
|
if (info === void 0)
|
|
141750
142013
|
return void 0;
|
|
@@ -141789,7 +142052,7 @@ ${lanes.join("\n")}
|
|
|
141789
142052
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
141790
142053
|
return findAncestor(token, (t) => t.kind === 199 /* NamedTupleMember */);
|
|
141791
142054
|
}
|
|
141792
|
-
function
|
|
142055
|
+
function doChange10(changes, sourceFile, namedTupleMember) {
|
|
141793
142056
|
if (!namedTupleMember) {
|
|
141794
142057
|
return;
|
|
141795
142058
|
}
|
|
@@ -141816,26 +142079,26 @@ ${lanes.join("\n")}
|
|
|
141816
142079
|
}
|
|
141817
142080
|
changes.replaceNode(sourceFile, namedTupleMember, updated);
|
|
141818
142081
|
}
|
|
141819
|
-
var
|
|
142082
|
+
var fixId21, errorCodes24;
|
|
141820
142083
|
var init_fixIncorrectNamedTupleSyntax = __esm({
|
|
141821
142084
|
"src/services/codefixes/fixIncorrectNamedTupleSyntax.ts"() {
|
|
141822
142085
|
"use strict";
|
|
141823
142086
|
init_ts4();
|
|
141824
142087
|
init_ts_codefix();
|
|
141825
|
-
|
|
141826
|
-
|
|
142088
|
+
fixId21 = "fixIncorrectNamedTupleSyntax";
|
|
142089
|
+
errorCodes24 = [
|
|
141827
142090
|
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,
|
|
141828
142091
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
141829
142092
|
];
|
|
141830
142093
|
registerCodeFix({
|
|
141831
|
-
errorCodes:
|
|
142094
|
+
errorCodes: errorCodes24,
|
|
141832
142095
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
141833
142096
|
const { sourceFile, span } = context;
|
|
141834
142097
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
141835
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141836
|
-
return [createCodeFixAction(
|
|
142098
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange10(t, sourceFile, namedTupleMember));
|
|
142099
|
+
return [createCodeFixAction(fixId21, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId21, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
141837
142100
|
},
|
|
141838
|
-
fixIds: [
|
|
142101
|
+
fixIds: [fixId21]
|
|
141839
142102
|
});
|
|
141840
142103
|
}
|
|
141841
142104
|
});
|
|
@@ -141890,7 +142153,7 @@ ${lanes.join("\n")}
|
|
|
141890
142153
|
}
|
|
141891
142154
|
return suggestedSymbol === void 0 ? void 0 : { node, suggestedSymbol };
|
|
141892
142155
|
}
|
|
141893
|
-
function
|
|
142156
|
+
function doChange11(changes, sourceFile, node, suggestedSymbol, target) {
|
|
141894
142157
|
const suggestion = symbolName(suggestedSymbol);
|
|
141895
142158
|
if (!isIdentifierText(suggestion, target) && isPropertyAccessExpression(node.parent)) {
|
|
141896
142159
|
const valDecl = suggestedSymbol.valueDeclaration;
|
|
@@ -141924,14 +142187,14 @@ ${lanes.join("\n")}
|
|
|
141924
142187
|
return void 0;
|
|
141925
142188
|
return context.program.getSourceFile(resolvedModule.resolvedFileName);
|
|
141926
142189
|
}
|
|
141927
|
-
var
|
|
142190
|
+
var fixId22, errorCodes25;
|
|
141928
142191
|
var init_fixSpelling = __esm({
|
|
141929
142192
|
"src/services/codefixes/fixSpelling.ts"() {
|
|
141930
142193
|
"use strict";
|
|
141931
142194
|
init_ts4();
|
|
141932
142195
|
init_ts_codefix();
|
|
141933
|
-
|
|
141934
|
-
|
|
142196
|
+
fixId22 = "fixSpelling";
|
|
142197
|
+
errorCodes25 = [
|
|
141935
142198
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
141936
142199
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
141937
142200
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -141948,7 +142211,7 @@ ${lanes.join("\n")}
|
|
|
141948
142211
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
141949
142212
|
];
|
|
141950
142213
|
registerCodeFix({
|
|
141951
|
-
errorCodes:
|
|
142214
|
+
errorCodes: errorCodes25,
|
|
141952
142215
|
getCodeActions(context) {
|
|
141953
142216
|
const { sourceFile, errorCode } = context;
|
|
141954
142217
|
const info = getInfo5(sourceFile, context.span.start, context, errorCode);
|
|
@@ -141956,15 +142219,15 @@ ${lanes.join("\n")}
|
|
|
141956
142219
|
return void 0;
|
|
141957
142220
|
const { node, suggestedSymbol } = info;
|
|
141958
142221
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
141959
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
141960
|
-
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)],
|
|
142222
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, sourceFile, node, suggestedSymbol, target));
|
|
142223
|
+
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId22, Diagnostics.Fix_all_detected_spelling_errors)];
|
|
141961
142224
|
},
|
|
141962
|
-
fixIds: [
|
|
141963
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142225
|
+
fixIds: [fixId22],
|
|
142226
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes25, (changes, diag2) => {
|
|
141964
142227
|
const info = getInfo5(diag2.file, diag2.start, context, diag2.code);
|
|
141965
142228
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
141966
142229
|
if (info)
|
|
141967
|
-
|
|
142230
|
+
doChange11(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
141968
142231
|
})
|
|
141969
142232
|
});
|
|
141970
142233
|
}
|
|
@@ -142148,7 +142411,7 @@ ${lanes.join("\n")}
|
|
|
142148
142411
|
}
|
|
142149
142412
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
142150
142413
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
142151
|
-
return createCodeFixAction(
|
|
142414
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
142152
142415
|
}
|
|
142153
142416
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
142154
142417
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -142160,29 +142423,29 @@ ${lanes.join("\n")}
|
|
|
142160
142423
|
/* withParen */
|
|
142161
142424
|
false
|
|
142162
142425
|
));
|
|
142163
|
-
return createCodeFixAction(
|
|
142426
|
+
return createCodeFixAction(fixId23, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
|
142164
142427
|
}
|
|
142165
142428
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
142166
142429
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
142167
|
-
return createCodeFixAction(
|
|
142430
|
+
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);
|
|
142168
142431
|
}
|
|
142169
|
-
var
|
|
142432
|
+
var fixId23, fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen, errorCodes26;
|
|
142170
142433
|
var init_returnValueCorrect = __esm({
|
|
142171
142434
|
"src/services/codefixes/returnValueCorrect.ts"() {
|
|
142172
142435
|
"use strict";
|
|
142173
142436
|
init_ts4();
|
|
142174
142437
|
init_ts_codefix();
|
|
142175
|
-
|
|
142438
|
+
fixId23 = "returnValueCorrect";
|
|
142176
142439
|
fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
142177
142440
|
fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
142178
142441
|
fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
142179
|
-
|
|
142442
|
+
errorCodes26 = [
|
|
142180
142443
|
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
142181
142444
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
142182
142445
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
142183
142446
|
];
|
|
142184
142447
|
registerCodeFix({
|
|
142185
|
-
errorCodes:
|
|
142448
|
+
errorCodes: errorCodes26,
|
|
142186
142449
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
142187
142450
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
142188
142451
|
const { program, sourceFile, span: { start }, errorCode } = context;
|
|
@@ -142198,7 +142461,7 @@ ${lanes.join("\n")}
|
|
|
142198
142461
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
142199
142462
|
}
|
|
142200
142463
|
},
|
|
142201
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
142464
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
142202
142465
|
const info = getInfo6(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
142203
142466
|
if (!info)
|
|
142204
142467
|
return void 0;
|
|
@@ -142764,7 +143027,7 @@ ${lanes.join("\n")}
|
|
|
142764
143027
|
}
|
|
142765
143028
|
return getSourceFileOfNode(node);
|
|
142766
143029
|
}
|
|
142767
|
-
var fixMissingMember, fixMissingProperties, fixMissingAttributes, fixMissingFunctionDeclaration,
|
|
143030
|
+
var fixMissingMember, fixMissingProperties, fixMissingAttributes, fixMissingFunctionDeclaration, errorCodes27;
|
|
142768
143031
|
var init_fixAddMissingMember = __esm({
|
|
142769
143032
|
"src/services/codefixes/fixAddMissingMember.ts"() {
|
|
142770
143033
|
"use strict";
|
|
@@ -142774,7 +143037,7 @@ ${lanes.join("\n")}
|
|
|
142774
143037
|
fixMissingProperties = "fixMissingProperties";
|
|
142775
143038
|
fixMissingAttributes = "fixMissingAttributes";
|
|
142776
143039
|
fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
142777
|
-
|
|
143040
|
+
errorCodes27 = [
|
|
142778
143041
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
142779
143042
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
142780
143043
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -142784,7 +143047,7 @@ ${lanes.join("\n")}
|
|
|
142784
143047
|
Diagnostics.Cannot_find_name_0.code
|
|
142785
143048
|
];
|
|
142786
143049
|
registerCodeFix({
|
|
142787
|
-
errorCodes:
|
|
143050
|
+
errorCodes: errorCodes27,
|
|
142788
143051
|
getCodeActions(context) {
|
|
142789
143052
|
const typeChecker = context.program.getTypeChecker();
|
|
142790
143053
|
const info = getInfo7(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -142811,21 +143074,21 @@ ${lanes.join("\n")}
|
|
|
142811
143074
|
},
|
|
142812
143075
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
142813
143076
|
getAllCodeActions: (context) => {
|
|
142814
|
-
const { program, fixId:
|
|
143077
|
+
const { program, fixId: fixId52 } = context;
|
|
142815
143078
|
const checker = program.getTypeChecker();
|
|
142816
143079
|
const seen = /* @__PURE__ */ new Map();
|
|
142817
143080
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
142818
143081
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
142819
|
-
eachDiagnostic(context,
|
|
143082
|
+
eachDiagnostic(context, errorCodes27, (diag2) => {
|
|
142820
143083
|
const info = getInfo7(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
142821
143084
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) {
|
|
142822
143085
|
return;
|
|
142823
143086
|
}
|
|
142824
|
-
if (
|
|
143087
|
+
if (fixId52 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
142825
143088
|
addFunctionDeclaration(changes, context, info);
|
|
142826
|
-
} else if (
|
|
143089
|
+
} else if (fixId52 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
142827
143090
|
addObjectLiteralProperties(changes, context, info);
|
|
142828
|
-
} else if (
|
|
143091
|
+
} else if (fixId52 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
142829
143092
|
addJsxAttributes(changes, context, info);
|
|
142830
143093
|
} else {
|
|
142831
143094
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -142881,23 +143144,23 @@ ${lanes.join("\n")}
|
|
|
142881
143144
|
}
|
|
142882
143145
|
return token;
|
|
142883
143146
|
}
|
|
142884
|
-
var
|
|
143147
|
+
var fixId24, errorCodes28;
|
|
142885
143148
|
var init_fixAddMissingNewOperator = __esm({
|
|
142886
143149
|
"src/services/codefixes/fixAddMissingNewOperator.ts"() {
|
|
142887
143150
|
"use strict";
|
|
142888
143151
|
init_ts4();
|
|
142889
143152
|
init_ts_codefix();
|
|
142890
|
-
|
|
142891
|
-
|
|
143153
|
+
fixId24 = "addMissingNewOperator";
|
|
143154
|
+
errorCodes28 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
142892
143155
|
registerCodeFix({
|
|
142893
|
-
errorCodes:
|
|
143156
|
+
errorCodes: errorCodes28,
|
|
142894
143157
|
getCodeActions(context) {
|
|
142895
143158
|
const { sourceFile, span } = context;
|
|
142896
143159
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
142897
|
-
return [createCodeFixAction(
|
|
143160
|
+
return [createCodeFixAction(fixId24, changes, Diagnostics.Add_missing_new_operator_to_call, fixId24, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
142898
143161
|
},
|
|
142899
|
-
fixIds: [
|
|
142900
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143162
|
+
fixIds: [fixId24],
|
|
143163
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes28, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
142901
143164
|
});
|
|
142902
143165
|
}
|
|
142903
143166
|
});
|
|
@@ -142918,7 +143181,7 @@ ${lanes.join("\n")}
|
|
|
142918
143181
|
var _a2;
|
|
142919
143182
|
return diagCode === errorCodeCannotFindModule ? ts_JsTyping_exports.nodeCoreModules.has(packageName) ? "@types/node" : void 0 : ((_a2 = host.isKnownTypesPackageName) == null ? void 0 : _a2.call(host, packageName)) ? getTypesPackageName(packageName) : void 0;
|
|
142920
143183
|
}
|
|
142921
|
-
var fixName2, fixIdInstallTypesPackage, errorCodeCannotFindModule,
|
|
143184
|
+
var fixName2, fixIdInstallTypesPackage, errorCodeCannotFindModule, errorCodes29;
|
|
142922
143185
|
var init_fixCannotFindModule = __esm({
|
|
142923
143186
|
"src/services/codefixes/fixCannotFindModule.ts"() {
|
|
142924
143187
|
"use strict";
|
|
@@ -142927,12 +143190,12 @@ ${lanes.join("\n")}
|
|
|
142927
143190
|
fixName2 = "fixCannotFindModule";
|
|
142928
143191
|
fixIdInstallTypesPackage = "installTypesPackage";
|
|
142929
143192
|
errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
142930
|
-
|
|
143193
|
+
errorCodes29 = [
|
|
142931
143194
|
errorCodeCannotFindModule,
|
|
142932
143195
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
142933
143196
|
];
|
|
142934
143197
|
registerCodeFix({
|
|
142935
|
-
errorCodes:
|
|
143198
|
+
errorCodes: errorCodes29,
|
|
142936
143199
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
142937
143200
|
const { host, sourceFile, span: { start } } = context;
|
|
142938
143201
|
const packageName = tryGetImportedPackageName(sourceFile, start);
|
|
@@ -142951,7 +143214,7 @@ ${lanes.join("\n")}
|
|
|
142951
143214
|
},
|
|
142952
143215
|
fixIds: [fixIdInstallTypesPackage],
|
|
142953
143216
|
getAllCodeActions: (context) => {
|
|
142954
|
-
return codeFixAll(context,
|
|
143217
|
+
return codeFixAll(context, errorCodes29, (_changes, diag2, commands) => {
|
|
142955
143218
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
142956
143219
|
if (packageName === void 0)
|
|
142957
143220
|
return void 0;
|
|
@@ -142990,28 +143253,28 @@ ${lanes.join("\n")}
|
|
|
142990
143253
|
const flags = getSyntacticModifierFlags(first(symbol.getDeclarations()));
|
|
142991
143254
|
return !(flags & 8 /* Private */) && !!(flags & 256 /* Abstract */);
|
|
142992
143255
|
}
|
|
142993
|
-
var
|
|
143256
|
+
var errorCodes30, fixId25;
|
|
142994
143257
|
var init_fixClassDoesntImplementInheritedAbstractMember = __esm({
|
|
142995
143258
|
"src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts"() {
|
|
142996
143259
|
"use strict";
|
|
142997
143260
|
init_ts4();
|
|
142998
143261
|
init_ts_codefix();
|
|
142999
|
-
|
|
143262
|
+
errorCodes30 = [
|
|
143000
143263
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
143001
143264
|
Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1.code
|
|
143002
143265
|
];
|
|
143003
|
-
|
|
143266
|
+
fixId25 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
143004
143267
|
registerCodeFix({
|
|
143005
|
-
errorCodes:
|
|
143268
|
+
errorCodes: errorCodes30,
|
|
143006
143269
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
143007
143270
|
const { sourceFile, span } = context;
|
|
143008
143271
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
143009
|
-
return changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
143272
|
+
return changes.length === 0 ? void 0 : [createCodeFixAction(fixId25, changes, Diagnostics.Implement_inherited_abstract_class, fixId25, Diagnostics.Implement_all_inherited_abstract_classes)];
|
|
143010
143273
|
},
|
|
143011
|
-
fixIds: [
|
|
143274
|
+
fixIds: [fixId25],
|
|
143012
143275
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
143013
143276
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
143014
|
-
return codeFixAll(context,
|
|
143277
|
+
return codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
143015
143278
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
143016
143279
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
143017
143280
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -143023,7 +143286,7 @@ ${lanes.join("\n")}
|
|
|
143023
143286
|
});
|
|
143024
143287
|
|
|
143025
143288
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
143026
|
-
function
|
|
143289
|
+
function doChange12(changes, sourceFile, constructor, superCall) {
|
|
143027
143290
|
changes.insertNodeAtConstructorStart(sourceFile, constructor, superCall);
|
|
143028
143291
|
changes.delete(sourceFile, superCall);
|
|
143029
143292
|
}
|
|
@@ -143038,36 +143301,36 @@ ${lanes.join("\n")}
|
|
|
143038
143301
|
function findSuperCall(n) {
|
|
143039
143302
|
return isExpressionStatement(n) && isSuperCall(n.expression) ? n : isFunctionLike(n) ? void 0 : forEachChild(n, findSuperCall);
|
|
143040
143303
|
}
|
|
143041
|
-
var
|
|
143304
|
+
var fixId26, errorCodes31;
|
|
143042
143305
|
var init_fixClassSuperMustPrecedeThisAccess = __esm({
|
|
143043
143306
|
"src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts"() {
|
|
143044
143307
|
"use strict";
|
|
143045
143308
|
init_ts4();
|
|
143046
143309
|
init_ts_codefix();
|
|
143047
|
-
|
|
143048
|
-
|
|
143310
|
+
fixId26 = "classSuperMustPrecedeThisAccess";
|
|
143311
|
+
errorCodes31 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
143049
143312
|
registerCodeFix({
|
|
143050
|
-
errorCodes:
|
|
143313
|
+
errorCodes: errorCodes31,
|
|
143051
143314
|
getCodeActions(context) {
|
|
143052
143315
|
const { sourceFile, span } = context;
|
|
143053
143316
|
const nodes = getNodes(sourceFile, span.start);
|
|
143054
143317
|
if (!nodes)
|
|
143055
143318
|
return void 0;
|
|
143056
143319
|
const { constructor, superCall } = nodes;
|
|
143057
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143058
|
-
return [createCodeFixAction(
|
|
143320
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, sourceFile, constructor, superCall));
|
|
143321
|
+
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)];
|
|
143059
143322
|
},
|
|
143060
|
-
fixIds: [
|
|
143323
|
+
fixIds: [fixId26],
|
|
143061
143324
|
getAllCodeActions(context) {
|
|
143062
143325
|
const { sourceFile } = context;
|
|
143063
143326
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
143064
|
-
return codeFixAll(context,
|
|
143327
|
+
return codeFixAll(context, errorCodes31, (changes, diag2) => {
|
|
143065
143328
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
143066
143329
|
if (!nodes)
|
|
143067
143330
|
return;
|
|
143068
143331
|
const { constructor, superCall } = nodes;
|
|
143069
143332
|
if (addToSeen(seenClasses, getNodeId(constructor.parent))) {
|
|
143070
|
-
|
|
143333
|
+
doChange12(changes, sourceFile, constructor, superCall);
|
|
143071
143334
|
}
|
|
143072
143335
|
});
|
|
143073
143336
|
}
|
|
@@ -143081,7 +143344,7 @@ ${lanes.join("\n")}
|
|
|
143081
143344
|
Debug.assert(isConstructorDeclaration(token.parent), "token should be at the constructor declaration");
|
|
143082
143345
|
return token.parent;
|
|
143083
143346
|
}
|
|
143084
|
-
function
|
|
143347
|
+
function doChange13(changes, sourceFile, ctr) {
|
|
143085
143348
|
const superCall = factory.createExpressionStatement(factory.createCallExpression(
|
|
143086
143349
|
factory.createSuper(),
|
|
143087
143350
|
/*typeArguments*/
|
|
@@ -143091,42 +143354,42 @@ ${lanes.join("\n")}
|
|
|
143091
143354
|
));
|
|
143092
143355
|
changes.insertNodeAtConstructorStart(sourceFile, ctr, superCall);
|
|
143093
143356
|
}
|
|
143094
|
-
var
|
|
143357
|
+
var fixId27, errorCodes32;
|
|
143095
143358
|
var init_fixConstructorForDerivedNeedSuperCall = __esm({
|
|
143096
143359
|
"src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts"() {
|
|
143097
143360
|
"use strict";
|
|
143098
143361
|
init_ts4();
|
|
143099
143362
|
init_ts_codefix();
|
|
143100
|
-
|
|
143101
|
-
|
|
143363
|
+
fixId27 = "constructorForDerivedNeedSuperCall";
|
|
143364
|
+
errorCodes32 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
143102
143365
|
registerCodeFix({
|
|
143103
|
-
errorCodes:
|
|
143366
|
+
errorCodes: errorCodes32,
|
|
143104
143367
|
getCodeActions(context) {
|
|
143105
143368
|
const { sourceFile, span } = context;
|
|
143106
143369
|
const ctr = getNode(sourceFile, span.start);
|
|
143107
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143108
|
-
return [createCodeFixAction(
|
|
143370
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange13(t, sourceFile, ctr));
|
|
143371
|
+
return [createCodeFixAction(fixId27, changes, Diagnostics.Add_missing_super_call, fixId27, Diagnostics.Add_all_missing_super_calls)];
|
|
143109
143372
|
},
|
|
143110
|
-
fixIds: [
|
|
143111
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143373
|
+
fixIds: [fixId27],
|
|
143374
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes32, (changes, diag2) => doChange13(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
143112
143375
|
});
|
|
143113
143376
|
}
|
|
143114
143377
|
});
|
|
143115
143378
|
|
|
143116
143379
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
143117
|
-
function
|
|
143380
|
+
function doChange14(changeTracker, configFile) {
|
|
143118
143381
|
setJsonCompilerOptionValue(changeTracker, configFile, "jsx", factory.createStringLiteral("react"));
|
|
143119
143382
|
}
|
|
143120
|
-
var fixID,
|
|
143383
|
+
var fixID, errorCodes33;
|
|
143121
143384
|
var init_fixEnableJsxFlag = __esm({
|
|
143122
143385
|
"src/services/codefixes/fixEnableJsxFlag.ts"() {
|
|
143123
143386
|
"use strict";
|
|
143124
143387
|
init_ts4();
|
|
143125
143388
|
init_ts_codefix();
|
|
143126
143389
|
fixID = "fixEnableJsxFlag";
|
|
143127
|
-
|
|
143390
|
+
errorCodes33 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
143128
143391
|
registerCodeFix({
|
|
143129
|
-
errorCodes:
|
|
143392
|
+
errorCodes: errorCodes33,
|
|
143130
143393
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
143131
143394
|
const { configFile } = context.program.getCompilerOptions();
|
|
143132
143395
|
if (configFile === void 0) {
|
|
@@ -143134,19 +143397,19 @@ ${lanes.join("\n")}
|
|
|
143134
143397
|
}
|
|
143135
143398
|
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
143136
143399
|
context,
|
|
143137
|
-
(changeTracker) =>
|
|
143400
|
+
(changeTracker) => doChange14(changeTracker, configFile)
|
|
143138
143401
|
);
|
|
143139
143402
|
return [
|
|
143140
143403
|
createCodeFixActionWithoutFixAll(fixID, changes, Diagnostics.Enable_the_jsx_flag_in_your_configuration_file)
|
|
143141
143404
|
];
|
|
143142
143405
|
},
|
|
143143
143406
|
fixIds: [fixID],
|
|
143144
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143407
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes33, (changes) => {
|
|
143145
143408
|
const { configFile } = context.program.getCompilerOptions();
|
|
143146
143409
|
if (configFile === void 0) {
|
|
143147
143410
|
return void 0;
|
|
143148
143411
|
}
|
|
143149
|
-
|
|
143412
|
+
doChange14(changes, configFile);
|
|
143150
143413
|
})
|
|
143151
143414
|
});
|
|
143152
143415
|
}
|
|
@@ -143168,7 +143431,7 @@ ${lanes.join("\n")}
|
|
|
143168
143431
|
}
|
|
143169
143432
|
return void 0;
|
|
143170
143433
|
}
|
|
143171
|
-
function
|
|
143434
|
+
function doChange15(changes, sourceFile, arg, expression) {
|
|
143172
143435
|
const callExpression = factory.createCallExpression(
|
|
143173
143436
|
factory.createPropertyAccessExpression(factory.createIdentifier("Number"), factory.createIdentifier("isNaN")),
|
|
143174
143437
|
/*typeArguments*/
|
|
@@ -143186,33 +143449,33 @@ ${lanes.join("\n")}
|
|
|
143186
143449
|
const [_, suggestion] = flattenDiagnosticMessageText(messageText, "\n", 0).match(/\'(.*)\'/) || [];
|
|
143187
143450
|
return suggestion;
|
|
143188
143451
|
}
|
|
143189
|
-
var
|
|
143452
|
+
var fixId28, errorCodes34;
|
|
143190
143453
|
var init_fixNaNEquality = __esm({
|
|
143191
143454
|
"src/services/codefixes/fixNaNEquality.ts"() {
|
|
143192
143455
|
"use strict";
|
|
143193
143456
|
init_ts4();
|
|
143194
143457
|
init_ts_codefix();
|
|
143195
|
-
|
|
143196
|
-
|
|
143458
|
+
fixId28 = "fixNaNEquality";
|
|
143459
|
+
errorCodes34 = [
|
|
143197
143460
|
Diagnostics.This_condition_will_always_return_0.code
|
|
143198
143461
|
];
|
|
143199
143462
|
registerCodeFix({
|
|
143200
|
-
errorCodes:
|
|
143463
|
+
errorCodes: errorCodes34,
|
|
143201
143464
|
getCodeActions(context) {
|
|
143202
143465
|
const { sourceFile, span, program } = context;
|
|
143203
143466
|
const info = getInfo8(program, sourceFile, span);
|
|
143204
143467
|
if (info === void 0)
|
|
143205
143468
|
return;
|
|
143206
143469
|
const { suggestion, expression, arg } = info;
|
|
143207
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143208
|
-
return [createCodeFixAction(
|
|
143470
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange15(t, sourceFile, arg, expression));
|
|
143471
|
+
return [createCodeFixAction(fixId28, changes, [Diagnostics.Use_0, suggestion], fixId28, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
143209
143472
|
},
|
|
143210
|
-
fixIds: [
|
|
143473
|
+
fixIds: [fixId28],
|
|
143211
143474
|
getAllCodeActions: (context) => {
|
|
143212
|
-
return codeFixAll(context,
|
|
143475
|
+
return codeFixAll(context, errorCodes34, (changes, diag2) => {
|
|
143213
143476
|
const info = getInfo8(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
143214
143477
|
if (info) {
|
|
143215
|
-
|
|
143478
|
+
doChange15(changes, diag2.file, info.arg, info.expression);
|
|
143216
143479
|
}
|
|
143217
143480
|
});
|
|
143218
143481
|
}
|
|
@@ -143268,32 +143531,32 @@ ${lanes.join("\n")}
|
|
|
143268
143531
|
});
|
|
143269
143532
|
|
|
143270
143533
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
143271
|
-
function
|
|
143534
|
+
function doChange16(changes, sourceFile, node) {
|
|
143272
143535
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
143273
143536
|
}
|
|
143274
143537
|
function getProperty2(sourceFile, pos) {
|
|
143275
143538
|
return cast(getTokenAtPosition(sourceFile, pos).parent, isShorthandPropertyAssignment);
|
|
143276
143539
|
}
|
|
143277
|
-
var
|
|
143540
|
+
var fixId29, errorCodes35;
|
|
143278
143541
|
var init_fixPropertyAssignment = __esm({
|
|
143279
143542
|
"src/services/codefixes/fixPropertyAssignment.ts"() {
|
|
143280
143543
|
"use strict";
|
|
143281
143544
|
init_ts4();
|
|
143282
143545
|
init_ts_codefix();
|
|
143283
|
-
|
|
143284
|
-
|
|
143546
|
+
fixId29 = "fixPropertyAssignment";
|
|
143547
|
+
errorCodes35 = [
|
|
143285
143548
|
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
|
|
143286
143549
|
];
|
|
143287
143550
|
registerCodeFix({
|
|
143288
|
-
errorCodes:
|
|
143289
|
-
fixIds: [
|
|
143551
|
+
errorCodes: errorCodes35,
|
|
143552
|
+
fixIds: [fixId29],
|
|
143290
143553
|
getCodeActions(context) {
|
|
143291
143554
|
const { sourceFile, span } = context;
|
|
143292
143555
|
const property = getProperty2(sourceFile, span.start);
|
|
143293
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143294
|
-
return [createCodeFixAction(
|
|
143556
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, context.sourceFile, property));
|
|
143557
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId29, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
143295
143558
|
},
|
|
143296
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143559
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes, diag2) => doChange16(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
143297
143560
|
});
|
|
143298
143561
|
}
|
|
143299
143562
|
});
|
|
@@ -143319,16 +143582,16 @@ ${lanes.join("\n")}
|
|
|
143319
143582
|
changes.deleteRange(sourceFile, { pos: implementsToken.getStart(), end });
|
|
143320
143583
|
}
|
|
143321
143584
|
}
|
|
143322
|
-
var
|
|
143585
|
+
var fixId30, errorCodes36;
|
|
143323
143586
|
var init_fixExtendsInterfaceBecomesImplements = __esm({
|
|
143324
143587
|
"src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts"() {
|
|
143325
143588
|
"use strict";
|
|
143326
143589
|
init_ts4();
|
|
143327
143590
|
init_ts_codefix();
|
|
143328
|
-
|
|
143329
|
-
|
|
143591
|
+
fixId30 = "extendsInterfaceBecomesImplements";
|
|
143592
|
+
errorCodes36 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
143330
143593
|
registerCodeFix({
|
|
143331
|
-
errorCodes:
|
|
143594
|
+
errorCodes: errorCodes36,
|
|
143332
143595
|
getCodeActions(context) {
|
|
143333
143596
|
const { sourceFile } = context;
|
|
143334
143597
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
@@ -143336,10 +143599,10 @@ ${lanes.join("\n")}
|
|
|
143336
143599
|
return void 0;
|
|
143337
143600
|
const { extendsToken, heritageClauses } = nodes;
|
|
143338
143601
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
143339
|
-
return [createCodeFixAction(
|
|
143602
|
+
return [createCodeFixAction(fixId30, changes, Diagnostics.Change_extends_to_implements, fixId30, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
143340
143603
|
},
|
|
143341
|
-
fixIds: [
|
|
143342
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143604
|
+
fixIds: [fixId30],
|
|
143605
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
143343
143606
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
143344
143607
|
if (nodes)
|
|
143345
143608
|
doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
@@ -143355,39 +143618,39 @@ ${lanes.join("\n")}
|
|
|
143355
143618
|
return { node, className: diagCode === didYouMeanStaticMemberCode ? getContainingClass(node).name.text : void 0 };
|
|
143356
143619
|
}
|
|
143357
143620
|
}
|
|
143358
|
-
function
|
|
143621
|
+
function doChange17(changes, sourceFile, { node, className }) {
|
|
143359
143622
|
suppressLeadingAndTrailingTrivia(node);
|
|
143360
143623
|
changes.replaceNode(sourceFile, node, factory.createPropertyAccessExpression(className ? factory.createIdentifier(className) : factory.createThis(), node));
|
|
143361
143624
|
}
|
|
143362
|
-
var
|
|
143625
|
+
var fixId31, didYouMeanStaticMemberCode, errorCodes37;
|
|
143363
143626
|
var init_fixForgottenThisPropertyAccess = __esm({
|
|
143364
143627
|
"src/services/codefixes/fixForgottenThisPropertyAccess.ts"() {
|
|
143365
143628
|
"use strict";
|
|
143366
143629
|
init_ts4();
|
|
143367
143630
|
init_ts_codefix();
|
|
143368
|
-
|
|
143631
|
+
fixId31 = "forgottenThisPropertyAccess";
|
|
143369
143632
|
didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
143370
|
-
|
|
143633
|
+
errorCodes37 = [
|
|
143371
143634
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
143372
143635
|
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,
|
|
143373
143636
|
didYouMeanStaticMemberCode
|
|
143374
143637
|
];
|
|
143375
143638
|
registerCodeFix({
|
|
143376
|
-
errorCodes:
|
|
143639
|
+
errorCodes: errorCodes37,
|
|
143377
143640
|
getCodeActions(context) {
|
|
143378
143641
|
const { sourceFile } = context;
|
|
143379
143642
|
const info = getInfo9(sourceFile, context.span.start, context.errorCode);
|
|
143380
143643
|
if (!info) {
|
|
143381
143644
|
return void 0;
|
|
143382
143645
|
}
|
|
143383
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143384
|
-
return [createCodeFixAction(
|
|
143646
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, info));
|
|
143647
|
+
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)];
|
|
143385
143648
|
},
|
|
143386
|
-
fixIds: [
|
|
143387
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
143649
|
+
fixIds: [fixId31],
|
|
143650
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => {
|
|
143388
143651
|
const info = getInfo9(diag2.file, diag2.start, diag2.code);
|
|
143389
143652
|
if (info)
|
|
143390
|
-
|
|
143653
|
+
doChange17(changes, context.sourceFile, info);
|
|
143391
143654
|
})
|
|
143392
143655
|
});
|
|
143393
143656
|
}
|
|
@@ -143397,7 +143660,7 @@ ${lanes.join("\n")}
|
|
|
143397
143660
|
function isValidCharacter(character) {
|
|
143398
143661
|
return hasProperty(htmlEntity, character);
|
|
143399
143662
|
}
|
|
143400
|
-
function
|
|
143663
|
+
function doChange18(changes, preferences, sourceFile, start, useHtmlEntity) {
|
|
143401
143664
|
const character = sourceFile.getText()[start];
|
|
143402
143665
|
if (!isValidCharacter(character)) {
|
|
143403
143666
|
return;
|
|
@@ -143405,7 +143668,7 @@ ${lanes.join("\n")}
|
|
|
143405
143668
|
const replacement = useHtmlEntity ? htmlEntity[character] : `{${quote(sourceFile, preferences, character)}}`;
|
|
143406
143669
|
changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement);
|
|
143407
143670
|
}
|
|
143408
|
-
var fixIdExpression, fixIdHtmlEntity,
|
|
143671
|
+
var fixIdExpression, fixIdHtmlEntity, errorCodes38, htmlEntity;
|
|
143409
143672
|
var init_fixInvalidJsxCharacters = __esm({
|
|
143410
143673
|
"src/services/codefixes/fixInvalidJsxCharacters.ts"() {
|
|
143411
143674
|
"use strict";
|
|
@@ -143413,16 +143676,16 @@ ${lanes.join("\n")}
|
|
|
143413
143676
|
init_ts_codefix();
|
|
143414
143677
|
fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
143415
143678
|
fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
143416
|
-
|
|
143679
|
+
errorCodes38 = [
|
|
143417
143680
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
143418
143681
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
143419
143682
|
];
|
|
143420
143683
|
registerCodeFix({
|
|
143421
|
-
errorCodes:
|
|
143684
|
+
errorCodes: errorCodes38,
|
|
143422
143685
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
143423
143686
|
getCodeActions(context) {
|
|
143424
143687
|
const { sourceFile, preferences, span } = context;
|
|
143425
|
-
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143688
|
+
const changeToExpression = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
143426
143689
|
t,
|
|
143427
143690
|
preferences,
|
|
143428
143691
|
sourceFile,
|
|
@@ -143430,7 +143693,7 @@ ${lanes.join("\n")}
|
|
|
143430
143693
|
/* useHtmlEntity */
|
|
143431
143694
|
false
|
|
143432
143695
|
));
|
|
143433
|
-
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
143696
|
+
const changeToHtmlEntity = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(
|
|
143434
143697
|
t,
|
|
143435
143698
|
preferences,
|
|
143436
143699
|
sourceFile,
|
|
@@ -143444,7 +143707,7 @@ ${lanes.join("\n")}
|
|
|
143444
143707
|
];
|
|
143445
143708
|
},
|
|
143446
143709
|
getAllCodeActions(context) {
|
|
143447
|
-
return codeFixAll(context,
|
|
143710
|
+
return codeFixAll(context, errorCodes38, (changes, diagnostic) => doChange18(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
143448
143711
|
}
|
|
143449
143712
|
});
|
|
143450
143713
|
htmlEntity = {
|
|
@@ -143503,7 +143766,7 @@ ${lanes.join("\n")}
|
|
|
143503
143766
|
}
|
|
143504
143767
|
return void 0;
|
|
143505
143768
|
}
|
|
143506
|
-
var deleteUnmatchedParameter, renameUnmatchedParameter,
|
|
143769
|
+
var deleteUnmatchedParameter, renameUnmatchedParameter, errorCodes39;
|
|
143507
143770
|
var init_fixUnmatchedParameter = __esm({
|
|
143508
143771
|
"src/services/codefixes/fixUnmatchedParameter.ts"() {
|
|
143509
143772
|
"use strict";
|
|
@@ -143511,12 +143774,12 @@ ${lanes.join("\n")}
|
|
|
143511
143774
|
init_ts_codefix();
|
|
143512
143775
|
deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
143513
143776
|
renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
143514
|
-
|
|
143777
|
+
errorCodes39 = [
|
|
143515
143778
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
143516
143779
|
];
|
|
143517
143780
|
registerCodeFix({
|
|
143518
143781
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
143519
|
-
errorCodes:
|
|
143782
|
+
errorCodes: errorCodes39,
|
|
143520
143783
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
143521
143784
|
const { sourceFile, span } = context;
|
|
143522
143785
|
const actions2 = [];
|
|
@@ -143531,7 +143794,7 @@ ${lanes.join("\n")}
|
|
|
143531
143794
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
143532
143795
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
143533
143796
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
143534
|
-
eachDiagnostic(context,
|
|
143797
|
+
eachDiagnostic(context, errorCodes39, ({ file, start }) => {
|
|
143535
143798
|
const info = getInfo10(file, start);
|
|
143536
143799
|
if (info) {
|
|
143537
143800
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -143580,16 +143843,16 @@ ${lanes.join("\n")}
|
|
|
143580
143843
|
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
|
|
143581
143844
|
ts_refactor_exports.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
|
|
143582
143845
|
}
|
|
143583
|
-
var
|
|
143846
|
+
var fixId32, errorCodes40;
|
|
143584
143847
|
var init_fixUnreferenceableDecoratorMetadata = __esm({
|
|
143585
143848
|
"src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts"() {
|
|
143586
143849
|
"use strict";
|
|
143587
143850
|
init_ts4();
|
|
143588
143851
|
init_ts_codefix();
|
|
143589
|
-
|
|
143590
|
-
|
|
143852
|
+
fixId32 = "fixUnreferenceableDecoratorMetadata";
|
|
143853
|
+
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];
|
|
143591
143854
|
registerCodeFix({
|
|
143592
|
-
errorCodes:
|
|
143855
|
+
errorCodes: errorCodes40,
|
|
143593
143856
|
getCodeActions: (context) => {
|
|
143594
143857
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
143595
143858
|
if (!importDeclaration)
|
|
@@ -143598,14 +143861,14 @@ ${lanes.join("\n")}
|
|
|
143598
143861
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
143599
143862
|
let actions2;
|
|
143600
143863
|
if (namespaceChanges.length) {
|
|
143601
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
143864
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
143602
143865
|
}
|
|
143603
143866
|
if (typeOnlyChanges.length) {
|
|
143604
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
143867
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId32, typeOnlyChanges, Diagnostics.Convert_to_type_only_import));
|
|
143605
143868
|
}
|
|
143606
143869
|
return actions2;
|
|
143607
143870
|
},
|
|
143608
|
-
fixIds: [
|
|
143871
|
+
fixIds: [fixId32]
|
|
143609
143872
|
});
|
|
143610
143873
|
}
|
|
143611
143874
|
});
|
|
@@ -143758,7 +144021,7 @@ ${lanes.join("\n")}
|
|
|
143758
144021
|
function mayDeleteExpression(node) {
|
|
143759
144022
|
return (isBinaryExpression(node.parent) && node.parent.left === node || (isPostfixUnaryExpression(node.parent) || isPrefixUnaryExpression(node.parent)) && node.parent.operand === node) && isExpressionStatement(node.parent.parent);
|
|
143760
144023
|
}
|
|
143761
|
-
var fixName3, fixIdPrefix, fixIdDelete, fixIdDeleteImports, fixIdInfer,
|
|
144024
|
+
var fixName3, fixIdPrefix, fixIdDelete, fixIdDeleteImports, fixIdInfer, errorCodes41;
|
|
143762
144025
|
var init_fixUnusedIdentifier = __esm({
|
|
143763
144026
|
"src/services/codefixes/fixUnusedIdentifier.ts"() {
|
|
143764
144027
|
"use strict";
|
|
@@ -143769,7 +144032,7 @@ ${lanes.join("\n")}
|
|
|
143769
144032
|
fixIdDelete = "unusedIdentifier_delete";
|
|
143770
144033
|
fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
143771
144034
|
fixIdInfer = "unusedIdentifier_infer";
|
|
143772
|
-
|
|
144035
|
+
errorCodes41 = [
|
|
143773
144036
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
143774
144037
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
143775
144038
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -143779,7 +144042,7 @@ ${lanes.join("\n")}
|
|
|
143779
144042
|
Diagnostics.All_type_parameters_are_unused.code
|
|
143780
144043
|
];
|
|
143781
144044
|
registerCodeFix({
|
|
143782
|
-
errorCodes:
|
|
144045
|
+
errorCodes: errorCodes41,
|
|
143783
144046
|
getCodeActions(context) {
|
|
143784
144047
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
143785
144048
|
const checker = program.getTypeChecker();
|
|
@@ -143865,7 +144128,7 @@ ${lanes.join("\n")}
|
|
|
143865
144128
|
const { sourceFile, program, cancellationToken } = context;
|
|
143866
144129
|
const checker = program.getTypeChecker();
|
|
143867
144130
|
const sourceFiles = program.getSourceFiles();
|
|
143868
|
-
return codeFixAll(context,
|
|
144131
|
+
return codeFixAll(context, errorCodes41, (changes, diag2) => {
|
|
143869
144132
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
143870
144133
|
switch (context.fixId) {
|
|
143871
144134
|
case fixIdPrefix:
|
|
@@ -143937,7 +144200,7 @@ ${lanes.join("\n")}
|
|
|
143937
144200
|
});
|
|
143938
144201
|
|
|
143939
144202
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
143940
|
-
function
|
|
144203
|
+
function doChange19(changes, sourceFile, start, length2, errorCode) {
|
|
143941
144204
|
const token = getTokenAtPosition(sourceFile, start);
|
|
143942
144205
|
const statement = findAncestor(token, isStatement);
|
|
143943
144206
|
if (statement.getStart(sourceFile) !== token.getStart(sourceFile)) {
|
|
@@ -143985,31 +144248,31 @@ ${lanes.join("\n")}
|
|
|
143985
144248
|
}
|
|
143986
144249
|
return last2;
|
|
143987
144250
|
}
|
|
143988
|
-
var
|
|
144251
|
+
var fixId33, errorCodes42;
|
|
143989
144252
|
var init_fixUnreachableCode = __esm({
|
|
143990
144253
|
"src/services/codefixes/fixUnreachableCode.ts"() {
|
|
143991
144254
|
"use strict";
|
|
143992
144255
|
init_ts4();
|
|
143993
144256
|
init_ts_codefix();
|
|
143994
|
-
|
|
143995
|
-
|
|
144257
|
+
fixId33 = "fixUnreachableCode";
|
|
144258
|
+
errorCodes42 = [Diagnostics.Unreachable_code_detected.code];
|
|
143996
144259
|
registerCodeFix({
|
|
143997
|
-
errorCodes:
|
|
144260
|
+
errorCodes: errorCodes42,
|
|
143998
144261
|
getCodeActions(context) {
|
|
143999
144262
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
144000
144263
|
if (syntacticDiagnostics.length)
|
|
144001
144264
|
return;
|
|
144002
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144003
|
-
return [createCodeFixAction(
|
|
144265
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange19(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
144266
|
+
return [createCodeFixAction(fixId33, changes, Diagnostics.Remove_unreachable_code, fixId33, Diagnostics.Remove_all_unreachable_code)];
|
|
144004
144267
|
},
|
|
144005
|
-
fixIds: [
|
|
144006
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144268
|
+
fixIds: [fixId33],
|
|
144269
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes42, (changes, diag2) => doChange19(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
144007
144270
|
});
|
|
144008
144271
|
}
|
|
144009
144272
|
});
|
|
144010
144273
|
|
|
144011
144274
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
144012
|
-
function
|
|
144275
|
+
function doChange20(changes, sourceFile, start) {
|
|
144013
144276
|
const token = getTokenAtPosition(sourceFile, start);
|
|
144014
144277
|
const labeledStatement = cast(token.parent, isLabeledStatement);
|
|
144015
144278
|
const pos = token.getStart(sourceFile);
|
|
@@ -144022,28 +144285,28 @@ ${lanes.join("\n")}
|
|
|
144022
144285
|
);
|
|
144023
144286
|
changes.deleteRange(sourceFile, { pos, end });
|
|
144024
144287
|
}
|
|
144025
|
-
var
|
|
144288
|
+
var fixId34, errorCodes43;
|
|
144026
144289
|
var init_fixUnusedLabel = __esm({
|
|
144027
144290
|
"src/services/codefixes/fixUnusedLabel.ts"() {
|
|
144028
144291
|
"use strict";
|
|
144029
144292
|
init_ts4();
|
|
144030
144293
|
init_ts_codefix();
|
|
144031
|
-
|
|
144032
|
-
|
|
144294
|
+
fixId34 = "fixUnusedLabel";
|
|
144295
|
+
errorCodes43 = [Diagnostics.Unused_label.code];
|
|
144033
144296
|
registerCodeFix({
|
|
144034
|
-
errorCodes:
|
|
144297
|
+
errorCodes: errorCodes43,
|
|
144035
144298
|
getCodeActions(context) {
|
|
144036
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144037
|
-
return [createCodeFixAction(
|
|
144299
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, context.sourceFile, context.span.start));
|
|
144300
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unused_label, fixId34, Diagnostics.Remove_all_unused_labels)];
|
|
144038
144301
|
},
|
|
144039
|
-
fixIds: [
|
|
144040
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144302
|
+
fixIds: [fixId34],
|
|
144303
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes43, (changes, diag2) => doChange20(changes, diag2.file, diag2.start))
|
|
144041
144304
|
});
|
|
144042
144305
|
}
|
|
144043
144306
|
});
|
|
144044
144307
|
|
|
144045
144308
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
144046
|
-
function
|
|
144309
|
+
function doChange21(changes, sourceFile, oldTypeNode, newType, checker) {
|
|
144047
144310
|
changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(
|
|
144048
144311
|
newType,
|
|
144049
144312
|
/*enclosingDeclaration*/
|
|
@@ -144092,7 +144355,7 @@ ${lanes.join("\n")}
|
|
|
144092
144355
|
}
|
|
144093
144356
|
return checker.getTypeFromTypeNode(node);
|
|
144094
144357
|
}
|
|
144095
|
-
var fixIdPlain, fixIdNullable,
|
|
144358
|
+
var fixIdPlain, fixIdNullable, errorCodes44;
|
|
144096
144359
|
var init_fixJSDocTypes = __esm({
|
|
144097
144360
|
"src/services/codefixes/fixJSDocTypes.ts"() {
|
|
144098
144361
|
"use strict";
|
|
@@ -144100,13 +144363,13 @@ ${lanes.join("\n")}
|
|
|
144100
144363
|
init_ts_codefix();
|
|
144101
144364
|
fixIdPlain = "fixJSDocTypes_plain";
|
|
144102
144365
|
fixIdNullable = "fixJSDocTypes_nullable";
|
|
144103
|
-
|
|
144366
|
+
errorCodes44 = [
|
|
144104
144367
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
144105
144368
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
144106
144369
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
144107
144370
|
];
|
|
144108
144371
|
registerCodeFix({
|
|
144109
|
-
errorCodes:
|
|
144372
|
+
errorCodes: errorCodes44,
|
|
144110
144373
|
getCodeActions(context) {
|
|
144111
144374
|
const { sourceFile } = context;
|
|
144112
144375
|
const checker = context.program.getTypeChecker();
|
|
@@ -144120,22 +144383,22 @@ ${lanes.join("\n")}
|
|
|
144120
144383
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
144121
144384
|
}
|
|
144122
144385
|
return actions2;
|
|
144123
|
-
function fix(type2,
|
|
144124
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144125
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
144386
|
+
function fix(type2, fixId52, fixAllDescription) {
|
|
144387
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, typeNode, type2, checker));
|
|
144388
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId52, fixAllDescription);
|
|
144126
144389
|
}
|
|
144127
144390
|
},
|
|
144128
144391
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
144129
144392
|
getAllCodeActions(context) {
|
|
144130
|
-
const { fixId:
|
|
144393
|
+
const { fixId: fixId52, program, sourceFile } = context;
|
|
144131
144394
|
const checker = program.getTypeChecker();
|
|
144132
|
-
return codeFixAll(context,
|
|
144395
|
+
return codeFixAll(context, errorCodes44, (changes, err) => {
|
|
144133
144396
|
const info = getInfo11(err.file, err.start, checker);
|
|
144134
144397
|
if (!info)
|
|
144135
144398
|
return;
|
|
144136
144399
|
const { typeNode, type } = info;
|
|
144137
|
-
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ &&
|
|
144138
|
-
|
|
144400
|
+
const fixedType = typeNode.kind === 317 /* JSDocNullableType */ && fixId52 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
144401
|
+
doChange21(changes, sourceFile, typeNode, fixedType, checker);
|
|
144139
144402
|
});
|
|
144140
144403
|
}
|
|
144141
144404
|
});
|
|
@@ -144143,7 +144406,7 @@ ${lanes.join("\n")}
|
|
|
144143
144406
|
});
|
|
144144
144407
|
|
|
144145
144408
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
144146
|
-
function
|
|
144409
|
+
function doChange22(changes, sourceFile, name) {
|
|
144147
144410
|
changes.replaceNodeWithText(sourceFile, name, `${name.text}()`);
|
|
144148
144411
|
}
|
|
144149
144412
|
function getCallName(sourceFile, start) {
|
|
@@ -144160,31 +144423,31 @@ ${lanes.join("\n")}
|
|
|
144160
144423
|
}
|
|
144161
144424
|
return void 0;
|
|
144162
144425
|
}
|
|
144163
|
-
var
|
|
144426
|
+
var fixId35, errorCodes45;
|
|
144164
144427
|
var init_fixMissingCallParentheses = __esm({
|
|
144165
144428
|
"src/services/codefixes/fixMissingCallParentheses.ts"() {
|
|
144166
144429
|
"use strict";
|
|
144167
144430
|
init_ts4();
|
|
144168
144431
|
init_ts_codefix();
|
|
144169
|
-
|
|
144170
|
-
|
|
144432
|
+
fixId35 = "fixMissingCallParentheses";
|
|
144433
|
+
errorCodes45 = [
|
|
144171
144434
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
144172
144435
|
];
|
|
144173
144436
|
registerCodeFix({
|
|
144174
|
-
errorCodes:
|
|
144175
|
-
fixIds: [
|
|
144437
|
+
errorCodes: errorCodes45,
|
|
144438
|
+
fixIds: [fixId35],
|
|
144176
144439
|
getCodeActions(context) {
|
|
144177
144440
|
const { sourceFile, span } = context;
|
|
144178
144441
|
const callName = getCallName(sourceFile, span.start);
|
|
144179
144442
|
if (!callName)
|
|
144180
144443
|
return;
|
|
144181
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144182
|
-
return [createCodeFixAction(
|
|
144444
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange22(t, context.sourceFile, callName));
|
|
144445
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Add_missing_call_parentheses, fixId35, Diagnostics.Add_all_missing_call_parentheses)];
|
|
144183
144446
|
},
|
|
144184
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144447
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => {
|
|
144185
144448
|
const callName = getCallName(diag2.file, diag2.start);
|
|
144186
144449
|
if (callName)
|
|
144187
|
-
|
|
144450
|
+
doChange22(changes, diag2.file, callName);
|
|
144188
144451
|
})
|
|
144189
144452
|
});
|
|
144190
144453
|
}
|
|
@@ -144226,7 +144489,7 @@ ${lanes.join("\n")}
|
|
|
144226
144489
|
returnType: getReturnType(containingFunction)
|
|
144227
144490
|
};
|
|
144228
144491
|
}
|
|
144229
|
-
function
|
|
144492
|
+
function doChange23(changes, sourceFile, { insertBefore, returnType }) {
|
|
144230
144493
|
if (returnType) {
|
|
144231
144494
|
const entityName = getEntityNameFromTypeNode(returnType);
|
|
144232
144495
|
if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") {
|
|
@@ -144235,36 +144498,36 @@ ${lanes.join("\n")}
|
|
|
144235
144498
|
}
|
|
144236
144499
|
changes.insertModifierBefore(sourceFile, 132 /* AsyncKeyword */, insertBefore);
|
|
144237
144500
|
}
|
|
144238
|
-
var
|
|
144501
|
+
var fixId36, errorCodes46;
|
|
144239
144502
|
var init_fixAwaitInSyncFunction = __esm({
|
|
144240
144503
|
"src/services/codefixes/fixAwaitInSyncFunction.ts"() {
|
|
144241
144504
|
"use strict";
|
|
144242
144505
|
init_ts4();
|
|
144243
144506
|
init_ts_codefix();
|
|
144244
|
-
|
|
144245
|
-
|
|
144507
|
+
fixId36 = "fixAwaitInSyncFunction";
|
|
144508
|
+
errorCodes46 = [
|
|
144246
144509
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
144247
144510
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
144248
144511
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
144249
144512
|
];
|
|
144250
144513
|
registerCodeFix({
|
|
144251
|
-
errorCodes:
|
|
144514
|
+
errorCodes: errorCodes46,
|
|
144252
144515
|
getCodeActions(context) {
|
|
144253
144516
|
const { sourceFile, span } = context;
|
|
144254
144517
|
const nodes = getNodes3(sourceFile, span.start);
|
|
144255
144518
|
if (!nodes)
|
|
144256
144519
|
return void 0;
|
|
144257
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
144258
|
-
return [createCodeFixAction(
|
|
144520
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, nodes));
|
|
144521
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId36, Diagnostics.Add_all_missing_async_modifiers)];
|
|
144259
144522
|
},
|
|
144260
|
-
fixIds: [
|
|
144523
|
+
fixIds: [fixId36],
|
|
144261
144524
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
144262
144525
|
const seen = /* @__PURE__ */ new Map();
|
|
144263
|
-
return codeFixAll(context,
|
|
144526
|
+
return codeFixAll(context, errorCodes46, (changes, diag2) => {
|
|
144264
144527
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
144265
144528
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore)))
|
|
144266
144529
|
return;
|
|
144267
|
-
|
|
144530
|
+
doChange23(changes, context.sourceFile, nodes);
|
|
144268
144531
|
});
|
|
144269
144532
|
}
|
|
144270
144533
|
});
|
|
@@ -144272,7 +144535,7 @@ ${lanes.join("\n")}
|
|
|
144272
144535
|
});
|
|
144273
144536
|
|
|
144274
144537
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
144275
|
-
function
|
|
144538
|
+
function doChange24(file, start, length2, code, context) {
|
|
144276
144539
|
let startPosition;
|
|
144277
144540
|
let endPosition;
|
|
144278
144541
|
if (code === Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code) {
|
|
@@ -144299,28 +144562,28 @@ ${lanes.join("\n")}
|
|
|
144299
144562
|
}
|
|
144300
144563
|
return generateAccessorFromProperty(file, context.program, startPosition, endPosition, context, Diagnostics.Generate_get_and_set_accessors.message);
|
|
144301
144564
|
}
|
|
144302
|
-
var
|
|
144565
|
+
var errorCodes47, fixId37;
|
|
144303
144566
|
var init_fixPropertyOverrideAccessor = __esm({
|
|
144304
144567
|
"src/services/codefixes/fixPropertyOverrideAccessor.ts"() {
|
|
144305
144568
|
"use strict";
|
|
144306
144569
|
init_ts4();
|
|
144307
144570
|
init_ts_codefix();
|
|
144308
|
-
|
|
144571
|
+
errorCodes47 = [
|
|
144309
144572
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
144310
144573
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
144311
144574
|
];
|
|
144312
|
-
|
|
144575
|
+
fixId37 = "fixPropertyOverrideAccessor";
|
|
144313
144576
|
registerCodeFix({
|
|
144314
|
-
errorCodes:
|
|
144577
|
+
errorCodes: errorCodes47,
|
|
144315
144578
|
getCodeActions(context) {
|
|
144316
|
-
const edits =
|
|
144579
|
+
const edits = doChange24(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
144317
144580
|
if (edits) {
|
|
144318
|
-
return [createCodeFixAction(
|
|
144581
|
+
return [createCodeFixAction(fixId37, edits, Diagnostics.Generate_get_and_set_accessors, fixId37, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
144319
144582
|
}
|
|
144320
144583
|
},
|
|
144321
|
-
fixIds: [
|
|
144322
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
144323
|
-
const edits =
|
|
144584
|
+
fixIds: [fixId37],
|
|
144585
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
144586
|
+
const edits = doChange24(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
144324
144587
|
if (edits) {
|
|
144325
144588
|
for (const edit of edits) {
|
|
144326
144589
|
changes.pushRaw(context.sourceFile, edit);
|
|
@@ -144367,7 +144630,7 @@ ${lanes.join("\n")}
|
|
|
144367
144630
|
}
|
|
144368
144631
|
return errorCode;
|
|
144369
144632
|
}
|
|
144370
|
-
function
|
|
144633
|
+
function doChange25(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) {
|
|
144371
144634
|
if (!isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) {
|
|
144372
144635
|
return void 0;
|
|
144373
144636
|
}
|
|
@@ -145031,7 +145294,7 @@ ${lanes.join("\n")}
|
|
|
145031
145294
|
const props = createMultiMap();
|
|
145032
145295
|
for (const anon2 of anons) {
|
|
145033
145296
|
for (const p of checker.getPropertiesOfType(anon2)) {
|
|
145034
|
-
props.add(p.
|
|
145297
|
+
props.add(p.escapedName, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType());
|
|
145035
145298
|
}
|
|
145036
145299
|
calls.push(...checker.getSignaturesOfType(anon2, 0 /* Call */));
|
|
145037
145300
|
constructs.push(...checker.getSignaturesOfType(anon2, 1 /* Construct */));
|
|
@@ -145261,14 +145524,14 @@ ${lanes.join("\n")}
|
|
|
145261
145524
|
}
|
|
145262
145525
|
}
|
|
145263
145526
|
}
|
|
145264
|
-
var
|
|
145527
|
+
var fixId38, errorCodes48;
|
|
145265
145528
|
var init_inferFromUsage = __esm({
|
|
145266
145529
|
"src/services/codefixes/inferFromUsage.ts"() {
|
|
145267
145530
|
"use strict";
|
|
145268
145531
|
init_ts4();
|
|
145269
145532
|
init_ts_codefix();
|
|
145270
|
-
|
|
145271
|
-
|
|
145533
|
+
fixId38 = "inferFromUsage";
|
|
145534
|
+
errorCodes48 = [
|
|
145272
145535
|
// Variable declarations
|
|
145273
145536
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
145274
145537
|
// Variable uses
|
|
@@ -145302,13 +145565,13 @@ ${lanes.join("\n")}
|
|
|
145302
145565
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
145303
145566
|
];
|
|
145304
145567
|
registerCodeFix({
|
|
145305
|
-
errorCodes:
|
|
145568
|
+
errorCodes: errorCodes48,
|
|
145306
145569
|
getCodeActions(context) {
|
|
145307
145570
|
const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
|
|
145308
145571
|
const token = getTokenAtPosition(sourceFile, start);
|
|
145309
145572
|
let declaration;
|
|
145310
145573
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => {
|
|
145311
|
-
declaration =
|
|
145574
|
+
declaration = doChange25(
|
|
145312
145575
|
changes2,
|
|
145313
145576
|
sourceFile,
|
|
145314
145577
|
token,
|
|
@@ -145322,14 +145585,14 @@ ${lanes.join("\n")}
|
|
|
145322
145585
|
);
|
|
145323
145586
|
});
|
|
145324
145587
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
145325
|
-
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
145588
|
+
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId38, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId38, Diagnostics.Infer_all_types_from_usage)];
|
|
145326
145589
|
},
|
|
145327
|
-
fixIds: [
|
|
145590
|
+
fixIds: [fixId38],
|
|
145328
145591
|
getAllCodeActions(context) {
|
|
145329
145592
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
145330
145593
|
const markSeen = nodeSeenTracker();
|
|
145331
|
-
return codeFixAll(context,
|
|
145332
|
-
|
|
145594
|
+
return codeFixAll(context, errorCodes48, (changes, err) => {
|
|
145595
|
+
doChange25(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
145333
145596
|
});
|
|
145334
145597
|
}
|
|
145335
145598
|
});
|
|
@@ -145360,22 +145623,22 @@ ${lanes.join("\n")}
|
|
|
145360
145623
|
return { returnTypeNode, returnType, promisedTypeNode, promisedType };
|
|
145361
145624
|
}
|
|
145362
145625
|
}
|
|
145363
|
-
function
|
|
145626
|
+
function doChange26(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
145364
145627
|
changes.replaceNode(sourceFile, returnTypeNode, factory.createTypeReferenceNode("Promise", [promisedTypeNode]));
|
|
145365
145628
|
}
|
|
145366
|
-
var
|
|
145629
|
+
var fixId39, errorCodes49;
|
|
145367
145630
|
var init_fixReturnTypeInAsyncFunction = __esm({
|
|
145368
145631
|
"src/services/codefixes/fixReturnTypeInAsyncFunction.ts"() {
|
|
145369
145632
|
"use strict";
|
|
145370
145633
|
init_ts4();
|
|
145371
145634
|
init_ts_codefix();
|
|
145372
|
-
|
|
145373
|
-
|
|
145635
|
+
fixId39 = "fixReturnTypeInAsyncFunction";
|
|
145636
|
+
errorCodes49 = [
|
|
145374
145637
|
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
|
|
145375
145638
|
];
|
|
145376
145639
|
registerCodeFix({
|
|
145377
|
-
errorCodes:
|
|
145378
|
-
fixIds: [
|
|
145640
|
+
errorCodes: errorCodes49,
|
|
145641
|
+
fixIds: [fixId39],
|
|
145379
145642
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
145380
145643
|
const { sourceFile, program, span } = context;
|
|
145381
145644
|
const checker = program.getTypeChecker();
|
|
@@ -145384,23 +145647,23 @@ ${lanes.join("\n")}
|
|
|
145384
145647
|
return void 0;
|
|
145385
145648
|
}
|
|
145386
145649
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
145387
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
145650
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange26(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
145388
145651
|
return [createCodeFixAction(
|
|
145389
|
-
|
|
145652
|
+
fixId39,
|
|
145390
145653
|
changes,
|
|
145391
145654
|
[
|
|
145392
145655
|
Diagnostics.Replace_0_with_Promise_1,
|
|
145393
145656
|
checker.typeToString(returnType),
|
|
145394
145657
|
checker.typeToString(promisedType)
|
|
145395
145658
|
],
|
|
145396
|
-
|
|
145659
|
+
fixId39,
|
|
145397
145660
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
145398
145661
|
)];
|
|
145399
145662
|
},
|
|
145400
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
145663
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
145401
145664
|
const info = getInfo12(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
145402
145665
|
if (info) {
|
|
145403
|
-
|
|
145666
|
+
doChange26(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
145404
145667
|
}
|
|
145405
145668
|
})
|
|
145406
145669
|
});
|
|
@@ -145414,20 +145677,20 @@ ${lanes.join("\n")}
|
|
|
145414
145677
|
changes.insertCommentBeforeLine(sourceFile, lineNumber, position, " @ts-ignore");
|
|
145415
145678
|
}
|
|
145416
145679
|
}
|
|
145417
|
-
var fixName4,
|
|
145680
|
+
var fixName4, fixId40, errorCodes50;
|
|
145418
145681
|
var init_disableJsDiagnostics = __esm({
|
|
145419
145682
|
"src/services/codefixes/disableJsDiagnostics.ts"() {
|
|
145420
145683
|
"use strict";
|
|
145421
145684
|
init_ts4();
|
|
145422
145685
|
init_ts_codefix();
|
|
145423
145686
|
fixName4 = "disableJsDiagnostics";
|
|
145424
|
-
|
|
145425
|
-
|
|
145687
|
+
fixId40 = "disableJsDiagnostics";
|
|
145688
|
+
errorCodes50 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
145426
145689
|
const diag2 = Diagnostics[key];
|
|
145427
145690
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
145428
145691
|
});
|
|
145429
145692
|
registerCodeFix({
|
|
145430
|
-
errorCodes:
|
|
145693
|
+
errorCodes: errorCodes50,
|
|
145431
145694
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
145432
145695
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
145433
145696
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -145445,14 +145708,14 @@ ${lanes.join("\n")}
|
|
|
145445
145708
|
)
|
|
145446
145709
|
];
|
|
145447
145710
|
if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
|
|
145448
|
-
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message,
|
|
145711
|
+
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));
|
|
145449
145712
|
}
|
|
145450
145713
|
return fixes;
|
|
145451
145714
|
},
|
|
145452
|
-
fixIds: [
|
|
145715
|
+
fixIds: [fixId40],
|
|
145453
145716
|
getAllCodeActions: (context) => {
|
|
145454
145717
|
const seenLines = /* @__PURE__ */ new Set();
|
|
145455
|
-
return codeFixAll(context,
|
|
145718
|
+
return codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
145456
145719
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
145457
145720
|
makeChange8(changes, diag2.file, diag2.start, seenLines);
|
|
145458
145721
|
}
|
|
@@ -146549,7 +146812,7 @@ ${lanes.join("\n")}
|
|
|
146549
146812
|
}
|
|
146550
146813
|
return void 0;
|
|
146551
146814
|
}
|
|
146552
|
-
var fixName6, fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer,
|
|
146815
|
+
var fixName6, fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer, errorCodes51;
|
|
146553
146816
|
var init_fixStrictClassInitialization = __esm({
|
|
146554
146817
|
"src/services/codefixes/fixStrictClassInitialization.ts"() {
|
|
146555
146818
|
"use strict";
|
|
@@ -146559,9 +146822,9 @@ ${lanes.join("\n")}
|
|
|
146559
146822
|
fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
146560
146823
|
fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
146561
146824
|
fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
146562
|
-
|
|
146825
|
+
errorCodes51 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
146563
146826
|
registerCodeFix({
|
|
146564
|
-
errorCodes:
|
|
146827
|
+
errorCodes: errorCodes51,
|
|
146565
146828
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
146566
146829
|
const info = getInfo13(context.sourceFile, context.span.start);
|
|
146567
146830
|
if (!info)
|
|
@@ -146574,7 +146837,7 @@ ${lanes.join("\n")}
|
|
|
146574
146837
|
},
|
|
146575
146838
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
146576
146839
|
getAllCodeActions: (context) => {
|
|
146577
|
-
return codeFixAll(context,
|
|
146840
|
+
return codeFixAll(context, errorCodes51, (changes, diag2) => {
|
|
146578
146841
|
const info = getInfo13(diag2.file, diag2.start);
|
|
146579
146842
|
if (!info)
|
|
146580
146843
|
return;
|
|
@@ -146602,7 +146865,7 @@ ${lanes.join("\n")}
|
|
|
146602
146865
|
});
|
|
146603
146866
|
|
|
146604
146867
|
// src/services/codefixes/requireInTs.ts
|
|
146605
|
-
function
|
|
146868
|
+
function doChange27(changes, sourceFile, info) {
|
|
146606
146869
|
const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info;
|
|
146607
146870
|
changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults ? factory.createImportEqualsDeclaration(
|
|
146608
146871
|
/*modifiers*/
|
|
@@ -146664,29 +146927,29 @@ ${lanes.join("\n")}
|
|
|
146664
146927
|
return factory.createNamedImports(importSpecifiers);
|
|
146665
146928
|
}
|
|
146666
146929
|
}
|
|
146667
|
-
var
|
|
146930
|
+
var fixId41, errorCodes52;
|
|
146668
146931
|
var init_requireInTs = __esm({
|
|
146669
146932
|
"src/services/codefixes/requireInTs.ts"() {
|
|
146670
146933
|
"use strict";
|
|
146671
146934
|
init_ts4();
|
|
146672
146935
|
init_ts_codefix();
|
|
146673
|
-
|
|
146674
|
-
|
|
146936
|
+
fixId41 = "requireInTs";
|
|
146937
|
+
errorCodes52 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
146675
146938
|
registerCodeFix({
|
|
146676
|
-
errorCodes:
|
|
146939
|
+
errorCodes: errorCodes52,
|
|
146677
146940
|
getCodeActions(context) {
|
|
146678
146941
|
const info = getInfo14(context.sourceFile, context.program, context.span.start);
|
|
146679
146942
|
if (!info) {
|
|
146680
146943
|
return void 0;
|
|
146681
146944
|
}
|
|
146682
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146683
|
-
return [createCodeFixAction(
|
|
146945
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, info));
|
|
146946
|
+
return [createCodeFixAction(fixId41, changes, Diagnostics.Convert_require_to_import, fixId41, Diagnostics.Convert_all_require_to_import)];
|
|
146684
146947
|
},
|
|
146685
|
-
fixIds: [
|
|
146686
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
146948
|
+
fixIds: [fixId41],
|
|
146949
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
146687
146950
|
const info = getInfo14(diag2.file, context.program, diag2.start);
|
|
146688
146951
|
if (info) {
|
|
146689
|
-
|
|
146952
|
+
doChange27(changes, context.sourceFile, info);
|
|
146690
146953
|
}
|
|
146691
146954
|
})
|
|
146692
146955
|
});
|
|
@@ -146706,7 +146969,7 @@ ${lanes.join("\n")}
|
|
|
146706
146969
|
return { importNode, name, moduleSpecifier: importNode.moduleSpecifier };
|
|
146707
146970
|
}
|
|
146708
146971
|
}
|
|
146709
|
-
function
|
|
146972
|
+
function doChange28(changes, sourceFile, info, preferences) {
|
|
146710
146973
|
changes.replaceNode(sourceFile, info.importNode, makeImport(
|
|
146711
146974
|
info.name,
|
|
146712
146975
|
/*namedImports*/
|
|
@@ -146715,29 +146978,29 @@ ${lanes.join("\n")}
|
|
|
146715
146978
|
getQuotePreference(sourceFile, preferences)
|
|
146716
146979
|
));
|
|
146717
146980
|
}
|
|
146718
|
-
var
|
|
146981
|
+
var fixId42, errorCodes53;
|
|
146719
146982
|
var init_useDefaultImport = __esm({
|
|
146720
146983
|
"src/services/codefixes/useDefaultImport.ts"() {
|
|
146721
146984
|
"use strict";
|
|
146722
146985
|
init_ts4();
|
|
146723
146986
|
init_ts_codefix();
|
|
146724
|
-
|
|
146725
|
-
|
|
146987
|
+
fixId42 = "useDefaultImport";
|
|
146988
|
+
errorCodes53 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
146726
146989
|
registerCodeFix({
|
|
146727
|
-
errorCodes:
|
|
146990
|
+
errorCodes: errorCodes53,
|
|
146728
146991
|
getCodeActions(context) {
|
|
146729
146992
|
const { sourceFile, span: { start } } = context;
|
|
146730
146993
|
const info = getInfo15(sourceFile, start);
|
|
146731
146994
|
if (!info)
|
|
146732
146995
|
return void 0;
|
|
146733
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146734
|
-
return [createCodeFixAction(
|
|
146996
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, sourceFile, info, context.preferences));
|
|
146997
|
+
return [createCodeFixAction(fixId42, changes, Diagnostics.Convert_to_default_import, fixId42, Diagnostics.Convert_all_to_default_imports)];
|
|
146735
146998
|
},
|
|
146736
|
-
fixIds: [
|
|
146737
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
146999
|
+
fixIds: [fixId42],
|
|
147000
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
146738
147001
|
const info = getInfo15(diag2.file, diag2.start);
|
|
146739
147002
|
if (info)
|
|
146740
|
-
|
|
147003
|
+
doChange28(changes, diag2.file, info, context.preferences);
|
|
146741
147004
|
})
|
|
146742
147005
|
});
|
|
146743
147006
|
}
|
|
@@ -146752,27 +147015,27 @@ ${lanes.join("\n")}
|
|
|
146752
147015
|
const newText = numericLiteral.getText(sourceFile) + "n";
|
|
146753
147016
|
changeTracker.replaceNode(sourceFile, numericLiteral, factory.createBigIntLiteral(newText));
|
|
146754
147017
|
}
|
|
146755
|
-
var
|
|
147018
|
+
var fixId43, errorCodes54;
|
|
146756
147019
|
var init_useBigintLiteral = __esm({
|
|
146757
147020
|
"src/services/codefixes/useBigintLiteral.ts"() {
|
|
146758
147021
|
"use strict";
|
|
146759
147022
|
init_ts4();
|
|
146760
147023
|
init_ts_codefix();
|
|
146761
|
-
|
|
146762
|
-
|
|
147024
|
+
fixId43 = "useBigintLiteral";
|
|
147025
|
+
errorCodes54 = [
|
|
146763
147026
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
146764
147027
|
];
|
|
146765
147028
|
registerCodeFix({
|
|
146766
|
-
errorCodes:
|
|
147029
|
+
errorCodes: errorCodes54,
|
|
146767
147030
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
146768
147031
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, context.sourceFile, context.span));
|
|
146769
147032
|
if (changes.length > 0) {
|
|
146770
|
-
return [createCodeFixAction(
|
|
147033
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId43, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
146771
147034
|
}
|
|
146772
147035
|
},
|
|
146773
|
-
fixIds: [
|
|
147036
|
+
fixIds: [fixId43],
|
|
146774
147037
|
getAllCodeActions: (context) => {
|
|
146775
|
-
return codeFixAll(context,
|
|
147038
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => makeChange9(changes, diag2.file, diag2));
|
|
146776
147039
|
}
|
|
146777
147040
|
});
|
|
146778
147041
|
}
|
|
@@ -146785,7 +147048,7 @@ ${lanes.join("\n")}
|
|
|
146785
147048
|
Debug.assert(token.parent.kind === 202 /* ImportType */, "Token parent should be an ImportType");
|
|
146786
147049
|
return token.parent;
|
|
146787
147050
|
}
|
|
146788
|
-
function
|
|
147051
|
+
function doChange29(changes, sourceFile, importType) {
|
|
146789
147052
|
const newTypeNode = factory.updateImportTypeNode(
|
|
146790
147053
|
importType,
|
|
146791
147054
|
importType.argument,
|
|
@@ -146797,25 +147060,25 @@ ${lanes.join("\n")}
|
|
|
146797
147060
|
);
|
|
146798
147061
|
changes.replaceNode(sourceFile, importType, newTypeNode);
|
|
146799
147062
|
}
|
|
146800
|
-
var fixIdAddMissingTypeof,
|
|
147063
|
+
var fixIdAddMissingTypeof, fixId44, errorCodes55;
|
|
146801
147064
|
var init_fixAddModuleReferTypeMissingTypeof = __esm({
|
|
146802
147065
|
"src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts"() {
|
|
146803
147066
|
"use strict";
|
|
146804
147067
|
init_ts4();
|
|
146805
147068
|
init_ts_codefix();
|
|
146806
147069
|
fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
146807
|
-
|
|
146808
|
-
|
|
147070
|
+
fixId44 = fixIdAddMissingTypeof;
|
|
147071
|
+
errorCodes55 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
|
146809
147072
|
registerCodeFix({
|
|
146810
|
-
errorCodes:
|
|
147073
|
+
errorCodes: errorCodes55,
|
|
146811
147074
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
146812
147075
|
const { sourceFile, span } = context;
|
|
146813
147076
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
146814
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
146815
|
-
return [createCodeFixAction(
|
|
147077
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, importType));
|
|
147078
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Add_missing_typeof, fixId44, Diagnostics.Add_missing_typeof)];
|
|
146816
147079
|
},
|
|
146817
|
-
fixIds: [
|
|
146818
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147080
|
+
fixIds: [fixId44],
|
|
147081
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => doChange29(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
146819
147082
|
});
|
|
146820
147083
|
}
|
|
146821
147084
|
});
|
|
@@ -146834,7 +147097,7 @@ ${lanes.join("\n")}
|
|
|
146834
147097
|
return void 0;
|
|
146835
147098
|
return binaryExpr;
|
|
146836
147099
|
}
|
|
146837
|
-
function
|
|
147100
|
+
function doChange30(changeTracker, sf, node) {
|
|
146838
147101
|
const jsx = flattenInvalidBinaryExpr(node);
|
|
146839
147102
|
if (jsx)
|
|
146840
147103
|
changeTracker.replaceNode(sf, node, factory.createJsxFragment(factory.createJsxOpeningFragment(), jsx, factory.createJsxJsxClosingFragment()));
|
|
@@ -146857,30 +147120,30 @@ ${lanes.join("\n")}
|
|
|
146857
147120
|
return void 0;
|
|
146858
147121
|
}
|
|
146859
147122
|
}
|
|
146860
|
-
var fixID2,
|
|
147123
|
+
var fixID2, errorCodes56;
|
|
146861
147124
|
var init_wrapJsxInFragment = __esm({
|
|
146862
147125
|
"src/services/codefixes/wrapJsxInFragment.ts"() {
|
|
146863
147126
|
"use strict";
|
|
146864
147127
|
init_ts4();
|
|
146865
147128
|
init_ts_codefix();
|
|
146866
147129
|
fixID2 = "wrapJsxInFragment";
|
|
146867
|
-
|
|
147130
|
+
errorCodes56 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
146868
147131
|
registerCodeFix({
|
|
146869
|
-
errorCodes:
|
|
147132
|
+
errorCodes: errorCodes56,
|
|
146870
147133
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
146871
147134
|
const { sourceFile, span } = context;
|
|
146872
147135
|
const node = findNodeToFix(sourceFile, span.start);
|
|
146873
147136
|
if (!node)
|
|
146874
147137
|
return void 0;
|
|
146875
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147138
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, sourceFile, node));
|
|
146876
147139
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
146877
147140
|
},
|
|
146878
147141
|
fixIds: [fixID2],
|
|
146879
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147142
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
146880
147143
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
146881
147144
|
if (!node)
|
|
146882
147145
|
return void 0;
|
|
146883
|
-
|
|
147146
|
+
doChange30(changes, context.sourceFile, node);
|
|
146884
147147
|
})
|
|
146885
147148
|
});
|
|
146886
147149
|
}
|
|
@@ -146900,7 +147163,7 @@ ${lanes.join("\n")}
|
|
|
146900
147163
|
function createTypeAliasFromInterface(declaration, type) {
|
|
146901
147164
|
return factory.createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
|
|
146902
147165
|
}
|
|
146903
|
-
function
|
|
147166
|
+
function doChange31(changes, sourceFile, { indexSignature, container }) {
|
|
146904
147167
|
const members = isInterfaceDeclaration(container) ? container.members : container.type.members;
|
|
146905
147168
|
const otherMembers = members.filter((member) => !isIndexSignatureDeclaration(member));
|
|
146906
147169
|
const parameter = first(indexSignature.parameters);
|
|
@@ -146927,48 +147190,48 @@ ${lanes.join("\n")}
|
|
|
146927
147190
|
]);
|
|
146928
147191
|
changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType));
|
|
146929
147192
|
}
|
|
146930
|
-
var
|
|
147193
|
+
var fixId45, errorCodes57;
|
|
146931
147194
|
var init_convertToMappedObjectType = __esm({
|
|
146932
147195
|
"src/services/codefixes/convertToMappedObjectType.ts"() {
|
|
146933
147196
|
"use strict";
|
|
146934
147197
|
init_ts4();
|
|
146935
147198
|
init_ts_codefix();
|
|
146936
|
-
|
|
146937
|
-
|
|
147199
|
+
fixId45 = "fixConvertToMappedObjectType";
|
|
147200
|
+
errorCodes57 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
146938
147201
|
registerCodeFix({
|
|
146939
|
-
errorCodes:
|
|
147202
|
+
errorCodes: errorCodes57,
|
|
146940
147203
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
146941
147204
|
const { sourceFile, span } = context;
|
|
146942
147205
|
const info = getInfo16(sourceFile, span.start);
|
|
146943
147206
|
if (!info)
|
|
146944
147207
|
return void 0;
|
|
146945
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147208
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, info));
|
|
146946
147209
|
const name = idText(info.container.name);
|
|
146947
|
-
return [createCodeFixAction(
|
|
147210
|
+
return [createCodeFixAction(fixId45, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId45, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
146948
147211
|
},
|
|
146949
|
-
fixIds: [
|
|
146950
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147212
|
+
fixIds: [fixId45],
|
|
147213
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes57, (changes, diag2) => {
|
|
146951
147214
|
const info = getInfo16(diag2.file, diag2.start);
|
|
146952
147215
|
if (info)
|
|
146953
|
-
|
|
147216
|
+
doChange31(changes, diag2.file, info);
|
|
146954
147217
|
})
|
|
146955
147218
|
});
|
|
146956
147219
|
}
|
|
146957
147220
|
});
|
|
146958
147221
|
|
|
146959
147222
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
146960
|
-
var
|
|
147223
|
+
var fixId46, errorCodes58;
|
|
146961
147224
|
var init_removeAccidentalCallParentheses = __esm({
|
|
146962
147225
|
"src/services/codefixes/removeAccidentalCallParentheses.ts"() {
|
|
146963
147226
|
"use strict";
|
|
146964
147227
|
init_ts4();
|
|
146965
147228
|
init_ts_codefix();
|
|
146966
|
-
|
|
146967
|
-
|
|
147229
|
+
fixId46 = "removeAccidentalCallParentheses";
|
|
147230
|
+
errorCodes58 = [
|
|
146968
147231
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
146969
147232
|
];
|
|
146970
147233
|
registerCodeFix({
|
|
146971
|
-
errorCodes:
|
|
147234
|
+
errorCodes: errorCodes58,
|
|
146972
147235
|
getCodeActions(context) {
|
|
146973
147236
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
146974
147237
|
if (!callExpression) {
|
|
@@ -146977,9 +147240,9 @@ ${lanes.join("\n")}
|
|
|
146977
147240
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
146978
147241
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
146979
147242
|
});
|
|
146980
|
-
return [createCodeFixActionWithoutFixAll(
|
|
147243
|
+
return [createCodeFixActionWithoutFixAll(fixId46, changes, Diagnostics.Remove_parentheses)];
|
|
146981
147244
|
},
|
|
146982
|
-
fixIds: [
|
|
147245
|
+
fixIds: [fixId46]
|
|
146983
147246
|
});
|
|
146984
147247
|
}
|
|
146985
147248
|
});
|
|
@@ -147008,27 +147271,27 @@ ${lanes.join("\n")}
|
|
|
147008
147271
|
}
|
|
147009
147272
|
changeTracker.replaceNode(sourceFile, expressionToReplace, awaitExpression.expression);
|
|
147010
147273
|
}
|
|
147011
|
-
var
|
|
147274
|
+
var fixId47, errorCodes59;
|
|
147012
147275
|
var init_removeUnnecessaryAwait = __esm({
|
|
147013
147276
|
"src/services/codefixes/removeUnnecessaryAwait.ts"() {
|
|
147014
147277
|
"use strict";
|
|
147015
147278
|
init_ts4();
|
|
147016
147279
|
init_ts_codefix();
|
|
147017
|
-
|
|
147018
|
-
|
|
147280
|
+
fixId47 = "removeUnnecessaryAwait";
|
|
147281
|
+
errorCodes59 = [
|
|
147019
147282
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
147020
147283
|
];
|
|
147021
147284
|
registerCodeFix({
|
|
147022
|
-
errorCodes:
|
|
147285
|
+
errorCodes: errorCodes59,
|
|
147023
147286
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
147024
147287
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
147025
147288
|
if (changes.length > 0) {
|
|
147026
|
-
return [createCodeFixAction(
|
|
147289
|
+
return [createCodeFixAction(fixId47, changes, Diagnostics.Remove_unnecessary_await, fixId47, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
147027
147290
|
}
|
|
147028
147291
|
},
|
|
147029
|
-
fixIds: [
|
|
147292
|
+
fixIds: [fixId47],
|
|
147030
147293
|
getAllCodeActions: (context) => {
|
|
147031
|
-
return codeFixAll(context,
|
|
147294
|
+
return codeFixAll(context, errorCodes59, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
147032
147295
|
}
|
|
147033
147296
|
});
|
|
147034
147297
|
}
|
|
@@ -147070,26 +147333,26 @@ ${lanes.join("\n")}
|
|
|
147070
147333
|
importDeclaration.assertClause
|
|
147071
147334
|
));
|
|
147072
147335
|
}
|
|
147073
|
-
var
|
|
147336
|
+
var errorCodes60, fixId48;
|
|
147074
147337
|
var init_splitTypeOnlyImport = __esm({
|
|
147075
147338
|
"src/services/codefixes/splitTypeOnlyImport.ts"() {
|
|
147076
147339
|
"use strict";
|
|
147077
147340
|
init_ts4();
|
|
147078
147341
|
init_ts_codefix();
|
|
147079
|
-
|
|
147080
|
-
|
|
147342
|
+
errorCodes60 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
147343
|
+
fixId48 = "splitTypeOnlyImport";
|
|
147081
147344
|
registerCodeFix({
|
|
147082
|
-
errorCodes:
|
|
147083
|
-
fixIds: [
|
|
147345
|
+
errorCodes: errorCodes60,
|
|
147346
|
+
fixIds: [fixId48],
|
|
147084
147347
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
147085
147348
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
147086
147349
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
147087
147350
|
});
|
|
147088
147351
|
if (changes.length) {
|
|
147089
|
-
return [createCodeFixAction(
|
|
147352
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId48, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
147090
147353
|
}
|
|
147091
147354
|
},
|
|
147092
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147355
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, error) => {
|
|
147093
147356
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error), context);
|
|
147094
147357
|
})
|
|
147095
147358
|
});
|
|
@@ -147111,43 +147374,43 @@ ${lanes.join("\n")}
|
|
|
147111
147374
|
return;
|
|
147112
147375
|
return { symbol, token: constToken };
|
|
147113
147376
|
}
|
|
147114
|
-
function
|
|
147377
|
+
function doChange32(changes, sourceFile, token) {
|
|
147115
147378
|
changes.replaceNode(sourceFile, token, factory.createToken(119 /* LetKeyword */));
|
|
147116
147379
|
}
|
|
147117
|
-
var
|
|
147380
|
+
var fixId49, errorCodes61;
|
|
147118
147381
|
var init_convertConstToLet = __esm({
|
|
147119
147382
|
"src/services/codefixes/convertConstToLet.ts"() {
|
|
147120
147383
|
"use strict";
|
|
147121
147384
|
init_ts4();
|
|
147122
147385
|
init_ts_codefix();
|
|
147123
|
-
|
|
147124
|
-
|
|
147386
|
+
fixId49 = "fixConvertConstToLet";
|
|
147387
|
+
errorCodes61 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
147125
147388
|
registerCodeFix({
|
|
147126
|
-
errorCodes:
|
|
147389
|
+
errorCodes: errorCodes61,
|
|
147127
147390
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
147128
147391
|
const { sourceFile, span, program } = context;
|
|
147129
147392
|
const info = getInfo17(sourceFile, span.start, program);
|
|
147130
147393
|
if (info === void 0)
|
|
147131
147394
|
return;
|
|
147132
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147133
|
-
return [createCodeFixActionMaybeFixAll(
|
|
147395
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange32(t, sourceFile, info.token));
|
|
147396
|
+
return [createCodeFixActionMaybeFixAll(fixId49, changes, Diagnostics.Convert_const_to_let, fixId49, Diagnostics.Convert_all_const_to_let)];
|
|
147134
147397
|
},
|
|
147135
147398
|
getAllCodeActions: (context) => {
|
|
147136
147399
|
const { program } = context;
|
|
147137
147400
|
const seen = /* @__PURE__ */ new Map();
|
|
147138
147401
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
147139
|
-
eachDiagnostic(context,
|
|
147402
|
+
eachDiagnostic(context, errorCodes61, (diag2) => {
|
|
147140
147403
|
const info = getInfo17(diag2.file, diag2.start, program);
|
|
147141
147404
|
if (info) {
|
|
147142
147405
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
147143
|
-
return
|
|
147406
|
+
return doChange32(changes, diag2.file, info.token);
|
|
147144
147407
|
}
|
|
147145
147408
|
}
|
|
147146
147409
|
return void 0;
|
|
147147
147410
|
});
|
|
147148
147411
|
}));
|
|
147149
147412
|
},
|
|
147150
|
-
fixIds: [
|
|
147413
|
+
fixIds: [fixId49]
|
|
147151
147414
|
});
|
|
147152
147415
|
}
|
|
147153
147416
|
});
|
|
@@ -147157,40 +147420,40 @@ ${lanes.join("\n")}
|
|
|
147157
147420
|
const node = getTokenAtPosition(sourceFile, pos);
|
|
147158
147421
|
return node.kind === 26 /* SemicolonToken */ && node.parent && (isObjectLiteralExpression(node.parent) || isArrayLiteralExpression(node.parent)) ? { node } : void 0;
|
|
147159
147422
|
}
|
|
147160
|
-
function
|
|
147423
|
+
function doChange33(changes, sourceFile, { node }) {
|
|
147161
147424
|
const newNode = factory.createToken(27 /* CommaToken */);
|
|
147162
147425
|
changes.replaceNode(sourceFile, node, newNode);
|
|
147163
147426
|
}
|
|
147164
|
-
var
|
|
147427
|
+
var fixId50, expectedErrorCode, errorCodes62;
|
|
147165
147428
|
var init_fixExpectedComma = __esm({
|
|
147166
147429
|
"src/services/codefixes/fixExpectedComma.ts"() {
|
|
147167
147430
|
"use strict";
|
|
147168
147431
|
init_ts4();
|
|
147169
147432
|
init_ts_codefix();
|
|
147170
|
-
|
|
147433
|
+
fixId50 = "fixExpectedComma";
|
|
147171
147434
|
expectedErrorCode = Diagnostics._0_expected.code;
|
|
147172
|
-
|
|
147435
|
+
errorCodes62 = [expectedErrorCode];
|
|
147173
147436
|
registerCodeFix({
|
|
147174
|
-
errorCodes:
|
|
147437
|
+
errorCodes: errorCodes62,
|
|
147175
147438
|
getCodeActions(context) {
|
|
147176
147439
|
const { sourceFile } = context;
|
|
147177
147440
|
const info = getInfo18(sourceFile, context.span.start, context.errorCode);
|
|
147178
147441
|
if (!info)
|
|
147179
147442
|
return void 0;
|
|
147180
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
147443
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange33(t, sourceFile, info));
|
|
147181
147444
|
return [createCodeFixAction(
|
|
147182
|
-
|
|
147445
|
+
fixId50,
|
|
147183
147446
|
changes,
|
|
147184
147447
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
147185
|
-
|
|
147448
|
+
fixId50,
|
|
147186
147449
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
147187
147450
|
)];
|
|
147188
147451
|
},
|
|
147189
|
-
fixIds: [
|
|
147190
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
147452
|
+
fixIds: [fixId50],
|
|
147453
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, diag2) => {
|
|
147191
147454
|
const info = getInfo18(diag2.file, diag2.start, diag2.code);
|
|
147192
147455
|
if (info)
|
|
147193
|
-
|
|
147456
|
+
doChange33(changes, context.sourceFile, info);
|
|
147194
147457
|
})
|
|
147195
147458
|
});
|
|
147196
147459
|
}
|
|
@@ -147246,29 +147509,29 @@ ${lanes.join("\n")}
|
|
|
147246
147509
|
return node.typeArguments;
|
|
147247
147510
|
}
|
|
147248
147511
|
}
|
|
147249
|
-
var fixName7,
|
|
147512
|
+
var fixName7, fixId51, errorCodes63;
|
|
147250
147513
|
var init_fixAddVoidToPromise = __esm({
|
|
147251
147514
|
"src/services/codefixes/fixAddVoidToPromise.ts"() {
|
|
147252
147515
|
"use strict";
|
|
147253
147516
|
init_ts4();
|
|
147254
147517
|
init_ts_codefix();
|
|
147255
147518
|
fixName7 = "addVoidToPromise";
|
|
147256
|
-
|
|
147257
|
-
|
|
147519
|
+
fixId51 = "addVoidToPromise";
|
|
147520
|
+
errorCodes63 = [
|
|
147258
147521
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
147259
147522
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
147260
147523
|
];
|
|
147261
147524
|
registerCodeFix({
|
|
147262
|
-
errorCodes:
|
|
147263
|
-
fixIds: [
|
|
147525
|
+
errorCodes: errorCodes63,
|
|
147526
|
+
fixIds: [fixId51],
|
|
147264
147527
|
getCodeActions(context) {
|
|
147265
147528
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span, context.program));
|
|
147266
147529
|
if (changes.length > 0) {
|
|
147267
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
147530
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId51, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
147268
147531
|
}
|
|
147269
147532
|
},
|
|
147270
147533
|
getAllCodeActions(context) {
|
|
147271
|
-
return codeFixAll(context,
|
|
147534
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange11(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
147272
147535
|
}
|
|
147273
147536
|
});
|
|
147274
147537
|
}
|
|
@@ -147303,6 +147566,7 @@ ${lanes.join("\n")}
|
|
|
147303
147566
|
getFixes: () => getFixes,
|
|
147304
147567
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
147305
147568
|
getImportKind: () => getImportKind,
|
|
147569
|
+
getJSDocTypedefNode: () => getJSDocTypedefNode,
|
|
147306
147570
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
147307
147571
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
147308
147572
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -147337,6 +147601,7 @@ ${lanes.join("\n")}
|
|
|
147337
147601
|
init_correctQualifiedNameToIndexedAccessType();
|
|
147338
147602
|
init_convertToTypeOnlyExport();
|
|
147339
147603
|
init_convertToTypeOnlyImport();
|
|
147604
|
+
init_convertTypedefToType();
|
|
147340
147605
|
init_convertLiteralTypeToMappedType();
|
|
147341
147606
|
init_fixClassIncorrectlyImplementsInterface();
|
|
147342
147607
|
init_importFixes();
|
|
@@ -149153,7 +149418,8 @@ ${lanes.join("\n")}
|
|
|
149153
149418
|
}
|
|
149154
149419
|
log("getCompletionData: Semantic work: " + (timestamp() - semanticStart));
|
|
149155
149420
|
const contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker);
|
|
149156
|
-
const
|
|
149421
|
+
const isLiteralExpected = !tryCast(previousToken, isStringLiteralLike) && !isJsxIdentifierExpected;
|
|
149422
|
+
const literals = !isLiteralExpected ? [] : mapDefined(
|
|
149157
149423
|
contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]),
|
|
149158
149424
|
(t) => t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : void 0
|
|
149159
149425
|
);
|
|
@@ -155765,8 +156031,7 @@ ${lanes.join("\n")}
|
|
|
155765
156031
|
function compareModuleSpecifiersWorker(m1, m2, comparer) {
|
|
155766
156032
|
const name1 = m1 === void 0 ? void 0 : getExternalModuleName2(m1);
|
|
155767
156033
|
const name2 = m2 === void 0 ? void 0 : getExternalModuleName2(m2);
|
|
155768
|
-
return compareBooleans(name1 === void 0, name2 === void 0) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) ||
|
|
155769
|
-
comparer(name1, name2);
|
|
156034
|
+
return compareBooleans(name1 === void 0, name2 === void 0) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) || comparer(name1, name2);
|
|
155770
156035
|
}
|
|
155771
156036
|
function getModuleSpecifierExpression(declaration) {
|
|
155772
156037
|
var _a2;
|
|
@@ -156486,7 +156751,7 @@ ${lanes.join("\n")}
|
|
|
156486
156751
|
return void 0;
|
|
156487
156752
|
}
|
|
156488
156753
|
}
|
|
156489
|
-
function
|
|
156754
|
+
function doChange34(exportingSourceFile, program, info, changes, cancellationToken) {
|
|
156490
156755
|
changeExport(exportingSourceFile, info, changes, program.getTypeChecker());
|
|
156491
156756
|
changeImports(program, info, changes, cancellationToken);
|
|
156492
156757
|
}
|
|
@@ -156682,7 +156947,7 @@ ${lanes.join("\n")}
|
|
|
156682
156947
|
Debug.assert(actionName2 === defaultToNamedAction.name || actionName2 === namedToDefaultAction.name, "Unexpected action name");
|
|
156683
156948
|
const info = getInfo19(context);
|
|
156684
156949
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156685
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
156950
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(context.file, context.program, info, t, context.cancellationToken));
|
|
156686
156951
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
156687
156952
|
}
|
|
156688
156953
|
});
|
|
@@ -156717,7 +156982,7 @@ ${lanes.join("\n")}
|
|
|
156717
156982
|
function getShouldUseDefault(program, importClause) {
|
|
156718
156983
|
return getAllowSyntheticDefaultImports(program.getCompilerOptions()) && isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
156719
156984
|
}
|
|
156720
|
-
function
|
|
156985
|
+
function doChange35(sourceFile, program, changes, info) {
|
|
156721
156986
|
const checker = program.getTypeChecker();
|
|
156722
156987
|
if (info.convertTo === 0 /* Named */) {
|
|
156723
156988
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
@@ -156909,7 +157174,7 @@ ${lanes.join("\n")}
|
|
|
156909
157174
|
Debug.assert(some(getOwnValues(actions), (action) => action.name === actionName2), "Unexpected action name");
|
|
156910
157175
|
const info = getImportConversionInfo(context);
|
|
156911
157176
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
156912
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157177
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(context.file, context.program, t, info));
|
|
156913
157178
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
156914
157179
|
}
|
|
156915
157180
|
});
|
|
@@ -157251,7 +157516,7 @@ ${lanes.join("\n")}
|
|
|
157251
157516
|
afterLast: afterEndNodeIndex === -1 ? void 0 : statements[afterEndNodeIndex]
|
|
157252
157517
|
};
|
|
157253
157518
|
}
|
|
157254
|
-
function
|
|
157519
|
+
function doChange36(oldFile, program, toMove, changes, host, preferences) {
|
|
157255
157520
|
const checker = program.getTypeChecker();
|
|
157256
157521
|
const usage = getUsageInfo(oldFile, toMove.all, checker);
|
|
157257
157522
|
const currentDirectory = getDirectoryPath(oldFile.fileName);
|
|
@@ -158021,7 +158286,7 @@ ${lanes.join("\n")}
|
|
|
158021
158286
|
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName2) {
|
|
158022
158287
|
Debug.assert(actionName2 === refactorName4, "Wrong refactor invoked");
|
|
158023
158288
|
const statements = Debug.checkDefined(getStatementsToMove(context));
|
|
158024
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158289
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(context.file, context.program, statements, t, context.host, context.preferences));
|
|
158025
158290
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
158026
158291
|
}
|
|
158027
158292
|
});
|
|
@@ -158683,12 +158948,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
158683
158948
|
return void 0;
|
|
158684
158949
|
const groupedReferences = getGroupedReferences(functionDeclaration, program, cancellationToken);
|
|
158685
158950
|
if (groupedReferences.valid) {
|
|
158686
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
158951
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(file, program, host, t, functionDeclaration, groupedReferences));
|
|
158687
158952
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
158688
158953
|
}
|
|
158689
158954
|
return { edits: [] };
|
|
158690
158955
|
}
|
|
158691
|
-
function
|
|
158956
|
+
function doChange37(sourceFile, program, host, changes, functionDeclaration, groupedReferences) {
|
|
158692
158957
|
const signature = groupedReferences.signature;
|
|
158693
158958
|
const newFunctionDeclarationParams = map(createNewParameters(functionDeclaration, program, host), (param) => getSynthesizedDeepClone(param));
|
|
158694
158959
|
if (signature) {
|
|
@@ -159481,7 +159746,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
159481
159746
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
159482
159747
|
const edits = ts_textChanges_exports.ChangeTracker.with(
|
|
159483
159748
|
context,
|
|
159484
|
-
(t) =>
|
|
159749
|
+
(t) => doChange38(context.file, context.program.getTypeChecker(), t, info, actionName2)
|
|
159485
159750
|
);
|
|
159486
159751
|
return { edits, renameFilename: void 0, renameLocation: void 0 };
|
|
159487
159752
|
}
|
|
@@ -159637,7 +159902,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
159637
159902
|
}
|
|
159638
159903
|
return toConvert;
|
|
159639
159904
|
}
|
|
159640
|
-
function
|
|
159905
|
+
function doChange38(sourceFile, checker, changes, info, _actionName) {
|
|
159641
159906
|
const { finalExpression, occurrences, expression } = info;
|
|
159642
159907
|
const firstOccurrence = occurrences[occurrences.length - 1];
|
|
159643
159908
|
const convertedChain = convertOccurrences(checker, finalExpression, occurrences);
|
|
@@ -161373,7 +161638,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161373
161638
|
function getRefactorEditsToInferReturnType(context) {
|
|
161374
161639
|
const info = getInfo21(context);
|
|
161375
161640
|
if (info && !isRefactorErrorInfo(info)) {
|
|
161376
|
-
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
161641
|
+
const edits = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(context.file, t, info.declaration, info.returnTypeNode));
|
|
161377
161642
|
return { renameFilename: void 0, renameLocation: void 0, edits };
|
|
161378
161643
|
}
|
|
161379
161644
|
return void 0;
|
|
@@ -161398,7 +161663,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
161398
161663
|
}
|
|
161399
161664
|
return emptyArray;
|
|
161400
161665
|
}
|
|
161401
|
-
function
|
|
161666
|
+
function doChange39(sourceFile, changes, declaration, typeNode) {
|
|
161402
161667
|
const closeParen = findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile);
|
|
161403
161668
|
const needParens = isArrowFunction(declaration) && closeParen === void 0;
|
|
161404
161669
|
const endNode2 = needParens ? first(declaration.parameters) : closeParen;
|
|
@@ -167665,7 +167930,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167665
167930
|
CommandTypes2["NavtoFull"] = "navto-full";
|
|
167666
167931
|
CommandTypes2["NavTree"] = "navtree";
|
|
167667
167932
|
CommandTypes2["NavTreeFull"] = "navtree-full";
|
|
167668
|
-
CommandTypes2["Occurrences"] = "occurrences";
|
|
167669
167933
|
CommandTypes2["DocumentHighlights"] = "documentHighlights";
|
|
167670
167934
|
CommandTypes2["DocumentHighlightsFull"] = "documentHighlights-full";
|
|
167671
167935
|
CommandTypes2["Open"] = "open";
|
|
@@ -167922,17 +168186,14 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167922
168186
|
* True when reloading contents of file from the disk is pending
|
|
167923
168187
|
*/
|
|
167924
168188
|
this.pendingReloadFromDisk = false;
|
|
167925
|
-
this.version = initialVersion ||
|
|
168189
|
+
this.version = initialVersion || 0;
|
|
167926
168190
|
}
|
|
167927
168191
|
getVersion() {
|
|
167928
|
-
return this.svc ? `SVC-${this.version
|
|
168192
|
+
return this.svc ? `SVC-${this.version}-${this.svc.getSnapshotVersion()}` : `Text-${this.version}`;
|
|
167929
168193
|
}
|
|
167930
168194
|
hasScriptVersionCache_TestOnly() {
|
|
167931
168195
|
return this.svc !== void 0;
|
|
167932
168196
|
}
|
|
167933
|
-
useScriptVersionCache_TestOnly() {
|
|
167934
|
-
this.switchToScriptVersionCache();
|
|
167935
|
-
}
|
|
167936
168197
|
resetSourceMapInfo() {
|
|
167937
168198
|
this.info.sourceFileLike = void 0;
|
|
167938
168199
|
this.info.closeSourceMapFileWatcher();
|
|
@@ -167945,15 +168206,17 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167945
168206
|
useText(newText) {
|
|
167946
168207
|
this.svc = void 0;
|
|
167947
168208
|
this.text = newText;
|
|
168209
|
+
this.textSnapshot = void 0;
|
|
167948
168210
|
this.lineMap = void 0;
|
|
167949
168211
|
this.fileSize = void 0;
|
|
167950
168212
|
this.resetSourceMapInfo();
|
|
167951
|
-
this.version
|
|
168213
|
+
this.version++;
|
|
167952
168214
|
}
|
|
167953
168215
|
edit(start, end, newText) {
|
|
167954
168216
|
this.switchToScriptVersionCache().edit(start, end - start, newText);
|
|
167955
168217
|
this.ownFileText = false;
|
|
167956
168218
|
this.text = void 0;
|
|
168219
|
+
this.textSnapshot = void 0;
|
|
167957
168220
|
this.lineMap = void 0;
|
|
167958
168221
|
this.fileSize = void 0;
|
|
167959
168222
|
this.resetSourceMapInfo();
|
|
@@ -167965,6 +168228,9 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167965
168228
|
reload(newText) {
|
|
167966
168229
|
Debug.assert(newText !== void 0);
|
|
167967
168230
|
this.pendingReloadFromDisk = false;
|
|
168231
|
+
if (!this.text && this.svc) {
|
|
168232
|
+
this.text = getSnapshotText(this.svc.getSnapshot());
|
|
168233
|
+
}
|
|
167968
168234
|
if (this.text !== newText) {
|
|
167969
168235
|
this.useText(newText);
|
|
167970
168236
|
this.ownFileText = false;
|
|
@@ -167977,21 +168243,18 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
167977
168243
|
* returns true if text changed
|
|
167978
168244
|
*/
|
|
167979
168245
|
reloadWithFileText(tempFileName) {
|
|
167980
|
-
const { text: newText, fileSize } = this.getFileTextAndSize(tempFileName);
|
|
168246
|
+
const { text: newText, fileSize } = tempFileName || !this.info.isDynamicOrHasMixedContent() ? this.getFileTextAndSize(tempFileName) : { text: "", fileSize: void 0 };
|
|
167981
168247
|
const reloaded = this.reload(newText);
|
|
167982
168248
|
this.fileSize = fileSize;
|
|
167983
168249
|
this.ownFileText = !tempFileName || tempFileName === this.info.fileName;
|
|
167984
168250
|
return reloaded;
|
|
167985
168251
|
}
|
|
167986
168252
|
/**
|
|
167987
|
-
*
|
|
167988
|
-
* returns true
|
|
168253
|
+
* Schedule reload from the disk if its not already scheduled and its not own text
|
|
168254
|
+
* returns true when scheduling reload
|
|
167989
168255
|
*/
|
|
167990
|
-
|
|
167991
|
-
|
|
167992
|
-
return this.reloadWithFileText();
|
|
167993
|
-
}
|
|
167994
|
-
return false;
|
|
168256
|
+
scheduleReloadIfNeeded() {
|
|
168257
|
+
return !this.pendingReloadFromDisk && !this.ownFileText ? this.pendingReloadFromDisk = true : false;
|
|
167995
168258
|
}
|
|
167996
168259
|
delayReloadFromFileIntoText() {
|
|
167997
168260
|
this.pendingReloadFromDisk = true;
|
|
@@ -168007,39 +168270,48 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168007
168270
|
return !!this.fileSize ? this.fileSize : !!this.text ? this.text.length : !!this.svc ? this.svc.getSnapshot().getLength() : this.getSnapshot().getLength();
|
|
168008
168271
|
}
|
|
168009
168272
|
getSnapshot() {
|
|
168010
|
-
|
|
168273
|
+
var _a2, _b;
|
|
168274
|
+
return ((_a2 = this.tryUseScriptVersionCache()) == null ? void 0 : _a2.getSnapshot()) || ((_b = this.textSnapshot) != null ? _b : this.textSnapshot = ScriptSnapshot.fromString(Debug.checkDefined(this.text)));
|
|
168011
168275
|
}
|
|
168012
|
-
getAbsolutePositionAndLineText(
|
|
168013
|
-
|
|
168276
|
+
getAbsolutePositionAndLineText(oneBasedLine) {
|
|
168277
|
+
const svc = this.tryUseScriptVersionCache();
|
|
168278
|
+
if (svc)
|
|
168279
|
+
return svc.getAbsolutePositionAndLineText(oneBasedLine);
|
|
168280
|
+
const lineMap = this.getLineMap();
|
|
168281
|
+
return oneBasedLine <= lineMap.length ? {
|
|
168282
|
+
absolutePosition: lineMap[oneBasedLine - 1],
|
|
168283
|
+
lineText: this.text.substring(lineMap[oneBasedLine - 1], lineMap[oneBasedLine])
|
|
168284
|
+
} : {
|
|
168285
|
+
absolutePosition: this.text.length,
|
|
168286
|
+
lineText: void 0
|
|
168287
|
+
};
|
|
168014
168288
|
}
|
|
168015
168289
|
/**
|
|
168016
168290
|
* @param line 0 based index
|
|
168017
168291
|
*/
|
|
168018
168292
|
lineToTextSpan(line) {
|
|
168019
|
-
|
|
168020
|
-
|
|
168021
|
-
|
|
168022
|
-
|
|
168023
|
-
|
|
168024
|
-
|
|
168025
|
-
return
|
|
168293
|
+
const svc = this.tryUseScriptVersionCache();
|
|
168294
|
+
if (svc)
|
|
168295
|
+
return svc.lineToTextSpan(line);
|
|
168296
|
+
const lineMap = this.getLineMap();
|
|
168297
|
+
const start = lineMap[line];
|
|
168298
|
+
const end = line + 1 < lineMap.length ? lineMap[line + 1] : this.text.length;
|
|
168299
|
+
return createTextSpanFromBounds(start, end);
|
|
168026
168300
|
}
|
|
168027
168301
|
/**
|
|
168028
168302
|
* @param line 1 based index
|
|
168029
168303
|
* @param offset 1 based index
|
|
168030
168304
|
*/
|
|
168031
168305
|
lineOffsetToPosition(line, offset, allowEdits) {
|
|
168032
|
-
|
|
168033
|
-
|
|
168034
|
-
}
|
|
168035
|
-
return this.svc.lineOffsetToPosition(line, offset);
|
|
168306
|
+
const svc = this.tryUseScriptVersionCache();
|
|
168307
|
+
return svc ? svc.lineOffsetToPosition(line, offset) : computePositionOfLineAndCharacter(this.getLineMap(), line - 1, offset - 1, this.text, allowEdits);
|
|
168036
168308
|
}
|
|
168037
168309
|
positionToLineOffset(position) {
|
|
168038
|
-
|
|
168039
|
-
|
|
168040
|
-
return
|
|
168041
|
-
}
|
|
168042
|
-
return
|
|
168310
|
+
const svc = this.tryUseScriptVersionCache();
|
|
168311
|
+
if (svc)
|
|
168312
|
+
return svc.positionToLineOffset(position);
|
|
168313
|
+
const { line, character } = computeLineAndCharacterOfPosition(this.getLineMap(), position);
|
|
168314
|
+
return { line: line + 1, offset: character + 1 };
|
|
168043
168315
|
}
|
|
168044
168316
|
getFileTextAndSize(tempFileName) {
|
|
168045
168317
|
let text;
|
|
@@ -168057,19 +168329,25 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168057
168329
|
}
|
|
168058
168330
|
return { text: getText() };
|
|
168059
168331
|
}
|
|
168332
|
+
/** @internal */
|
|
168060
168333
|
switchToScriptVersionCache() {
|
|
168061
168334
|
if (!this.svc || this.pendingReloadFromDisk) {
|
|
168062
168335
|
this.svc = ScriptVersionCache.fromString(this.getOrLoadText());
|
|
168063
|
-
this.
|
|
168336
|
+
this.textSnapshot = void 0;
|
|
168337
|
+
this.version++;
|
|
168064
168338
|
}
|
|
168065
168339
|
return this.svc;
|
|
168066
168340
|
}
|
|
168067
|
-
|
|
168068
|
-
if (this.
|
|
168069
|
-
|
|
168341
|
+
tryUseScriptVersionCache() {
|
|
168342
|
+
if (!this.svc || this.pendingReloadFromDisk) {
|
|
168343
|
+
this.getOrLoadText();
|
|
168070
168344
|
}
|
|
168071
|
-
if (this.
|
|
168072
|
-
this.
|
|
168345
|
+
if (this.isOpen) {
|
|
168346
|
+
if (!this.svc && !this.textSnapshot) {
|
|
168347
|
+
this.svc = ScriptVersionCache.fromString(Debug.checkDefined(this.text));
|
|
168348
|
+
this.textSnapshot = void 0;
|
|
168349
|
+
}
|
|
168350
|
+
return this.svc;
|
|
168073
168351
|
}
|
|
168074
168352
|
return this.svc;
|
|
168075
168353
|
}
|
|
@@ -168082,13 +168360,14 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168082
168360
|
}
|
|
168083
168361
|
getLineMap() {
|
|
168084
168362
|
Debug.assert(!this.svc, "ScriptVersionCache should not be set");
|
|
168085
|
-
return this.lineMap || (this.lineMap = computeLineStarts(this.
|
|
168363
|
+
return this.lineMap || (this.lineMap = computeLineStarts(Debug.checkDefined(this.text)));
|
|
168086
168364
|
}
|
|
168087
168365
|
getLineInfo() {
|
|
168088
|
-
|
|
168366
|
+
const svc = this.tryUseScriptVersionCache();
|
|
168367
|
+
if (svc) {
|
|
168089
168368
|
return {
|
|
168090
|
-
getLineCount: () =>
|
|
168091
|
-
getLineText: (line) =>
|
|
168369
|
+
getLineCount: () => svc.getLineCount(),
|
|
168370
|
+
getLineText: (line) => svc.getAbsolutePositionAndLineText(line + 1).lineText
|
|
168092
168371
|
};
|
|
168093
168372
|
}
|
|
168094
168373
|
const lineMap = this.getLineMap();
|
|
@@ -168109,20 +168388,11 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168109
168388
|
this.isDynamic = isDynamicFileName(fileName);
|
|
168110
168389
|
this.textStorage = new TextStorage(host, this, initialVersion);
|
|
168111
168390
|
if (hasMixedContent || this.isDynamic) {
|
|
168112
|
-
this.textStorage.reload("");
|
|
168113
168391
|
this.realpath = this.path;
|
|
168114
168392
|
}
|
|
168115
168393
|
this.scriptKind = scriptKind ? scriptKind : getScriptKindFromFileName(fileName);
|
|
168116
168394
|
}
|
|
168117
168395
|
/** @internal */
|
|
168118
|
-
getVersion() {
|
|
168119
|
-
return this.textStorage.version;
|
|
168120
|
-
}
|
|
168121
|
-
/** @internal */
|
|
168122
|
-
getTelemetryFileSize() {
|
|
168123
|
-
return this.textStorage.getTelemetryFileSize();
|
|
168124
|
-
}
|
|
168125
|
-
/** @internal */
|
|
168126
168396
|
isDynamicOrHasMixedContent() {
|
|
168127
168397
|
return this.hasMixedContent || this.isDynamic;
|
|
168128
168398
|
}
|
|
@@ -168137,11 +168407,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168137
168407
|
}
|
|
168138
168408
|
close(fileExists = true) {
|
|
168139
168409
|
this.textStorage.isOpen = false;
|
|
168140
|
-
if (this.
|
|
168141
|
-
if (this.textStorage.reload("")) {
|
|
168142
|
-
this.markContainingProjectsAsDirty();
|
|
168143
|
-
}
|
|
168144
|
-
} else if (this.textStorage.reloadFromDisk()) {
|
|
168410
|
+
if (fileExists && this.textStorage.scheduleReloadIfNeeded()) {
|
|
168145
168411
|
this.markContainingProjectsAsDirty();
|
|
168146
168412
|
}
|
|
168147
168413
|
}
|
|
@@ -168321,22 +168587,12 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168321
168587
|
this.markContainingProjectsAsDirty();
|
|
168322
168588
|
}
|
|
168323
168589
|
reloadFromFile(tempFileName) {
|
|
168324
|
-
if (this.
|
|
168325
|
-
this.textStorage.reload("");
|
|
168590
|
+
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
168326
168591
|
this.markContainingProjectsAsDirty();
|
|
168327
168592
|
return true;
|
|
168328
|
-
} else {
|
|
168329
|
-
if (this.textStorage.reloadWithFileText(tempFileName)) {
|
|
168330
|
-
this.markContainingProjectsAsDirty();
|
|
168331
|
-
return true;
|
|
168332
|
-
}
|
|
168333
168593
|
}
|
|
168334
168594
|
return false;
|
|
168335
168595
|
}
|
|
168336
|
-
/** @internal */
|
|
168337
|
-
getAbsolutePositionAndLineText(line) {
|
|
168338
|
-
return this.textStorage.getAbsolutePositionAndLineText(line);
|
|
168339
|
-
}
|
|
168340
168596
|
editContent(start, end, newText) {
|
|
168341
168597
|
this.textStorage.edit(start, end, newText);
|
|
168342
168598
|
this.markContainingProjectsAsDirty();
|
|
@@ -168376,10 +168632,6 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168376
168632
|
return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */;
|
|
168377
168633
|
}
|
|
168378
168634
|
/** @internal */
|
|
168379
|
-
getLineInfo() {
|
|
168380
|
-
return this.textStorage.getLineInfo();
|
|
168381
|
-
}
|
|
168382
|
-
/** @internal */
|
|
168383
168635
|
closeSourceMapFileWatcher() {
|
|
168384
168636
|
if (this.sourceMapFilePath && !isString(this.sourceMapFilePath)) {
|
|
168385
168637
|
closeFileWatcherOf(this.sourceMapFilePath);
|
|
@@ -168510,7 +168762,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
168510
168762
|
deferredSize: 0
|
|
168511
168763
|
};
|
|
168512
168764
|
for (const info of infos) {
|
|
168513
|
-
const fileSize = includeSizes ? info.getTelemetryFileSize() : 0;
|
|
168765
|
+
const fileSize = includeSizes ? info.textStorage.getTelemetryFileSize() : 0;
|
|
168514
168766
|
switch (info.scriptKind) {
|
|
168515
168767
|
case 1 /* JS */:
|
|
168516
168768
|
result.js += 1;
|
|
@@ -169540,10 +169792,26 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169540
169792
|
const elapsed = timestamp() - start;
|
|
169541
169793
|
this.sendPerformanceEvent("UpdateGraph", elapsed);
|
|
169542
169794
|
this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram}${this.program ? ` structureIsReused:: ${StructureIsReused[this.program.structureIsReused]}` : ""} Elapsed: ${elapsed}ms`);
|
|
169543
|
-
if (this.
|
|
169795
|
+
if (this.projectService.logger.isTestLogger) {
|
|
169796
|
+
if (this.program !== oldProgram) {
|
|
169797
|
+
this.print(
|
|
169798
|
+
/*writeProjectFileNames*/
|
|
169799
|
+
true,
|
|
169800
|
+
this.hasAddedorRemovedFiles,
|
|
169801
|
+
/*writeFileVersionAndText*/
|
|
169802
|
+
true
|
|
169803
|
+
);
|
|
169804
|
+
} else {
|
|
169805
|
+
this.writeLog(`Same program as before`);
|
|
169806
|
+
}
|
|
169807
|
+
} else if (this.hasAddedorRemovedFiles) {
|
|
169544
169808
|
this.print(
|
|
169545
169809
|
/*writeProjectFileNames*/
|
|
169546
|
-
true
|
|
169810
|
+
true,
|
|
169811
|
+
/*writeFileExplaination*/
|
|
169812
|
+
true,
|
|
169813
|
+
/*writeFileVersionAndText*/
|
|
169814
|
+
false
|
|
169547
169815
|
);
|
|
169548
169816
|
} else if (this.program !== oldProgram) {
|
|
169549
169817
|
this.writeLog(`Different program with same set of files`);
|
|
@@ -169653,6 +169921,16 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169653
169921
|
return this.projectService.getScriptInfo(uncheckedFileName);
|
|
169654
169922
|
}
|
|
169655
169923
|
filesToString(writeProjectFileNames) {
|
|
169924
|
+
return this.filesToStringWorker(
|
|
169925
|
+
writeProjectFileNames,
|
|
169926
|
+
/*writeFileExplaination*/
|
|
169927
|
+
true,
|
|
169928
|
+
/*writeFileVersionAndText*/
|
|
169929
|
+
false
|
|
169930
|
+
);
|
|
169931
|
+
}
|
|
169932
|
+
/** @internal */
|
|
169933
|
+
filesToStringWorker(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
169656
169934
|
if (this.isInitialLoadPending())
|
|
169657
169935
|
return " Files (0) InitialLoadPending\n";
|
|
169658
169936
|
if (!this.program)
|
|
@@ -169662,23 +169940,33 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
169662
169940
|
`;
|
|
169663
169941
|
if (writeProjectFileNames) {
|
|
169664
169942
|
for (const file of sourceFiles) {
|
|
169665
|
-
strBuilder += ` ${file.fileName}
|
|
169943
|
+
strBuilder += ` ${file.fileName}${writeFileVersionAndText ? ` ${file.version} ${JSON.stringify(file.text)}` : ""}
|
|
169666
169944
|
`;
|
|
169667
169945
|
}
|
|
169668
|
-
|
|
169669
|
-
|
|
169946
|
+
if (writeFileExplaination) {
|
|
169947
|
+
strBuilder += "\n\n";
|
|
169948
|
+
explainFiles(this.program, (s) => strBuilder += ` ${s}
|
|
169670
169949
|
`);
|
|
169950
|
+
}
|
|
169671
169951
|
}
|
|
169672
169952
|
return strBuilder;
|
|
169673
169953
|
}
|
|
169674
169954
|
/** @internal */
|
|
169675
|
-
print(writeProjectFileNames) {
|
|
169955
|
+
print(writeProjectFileNames, writeFileExplaination, writeFileVersionAndText) {
|
|
169676
169956
|
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
|
|
169677
|
-
this.writeLog(this.
|
|
169957
|
+
this.writeLog(this.filesToStringWorker(
|
|
169958
|
+
writeProjectFileNames && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
169959
|
+
writeFileExplaination && this.projectService.logger.hasLevel(3 /* verbose */),
|
|
169960
|
+
writeFileVersionAndText && this.projectService.logger.hasLevel(3 /* verbose */)
|
|
169961
|
+
));
|
|
169678
169962
|
this.writeLog("-----------------------------------------------");
|
|
169679
169963
|
if (this.autoImportProviderHost) {
|
|
169680
169964
|
this.autoImportProviderHost.print(
|
|
169681
169965
|
/*writeProjectFileNames*/
|
|
169966
|
+
false,
|
|
169967
|
+
/*writeFileExplaination*/
|
|
169968
|
+
false,
|
|
169969
|
+
/*writeFileVersionAndText*/
|
|
169682
169970
|
false
|
|
169683
169971
|
);
|
|
169684
169972
|
}
|
|
@@ -170680,7 +170968,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
170680
170968
|
return !!this.externalProjectRefCount;
|
|
170681
170969
|
}
|
|
170682
170970
|
getEffectiveTypeRoots() {
|
|
170683
|
-
return getEffectiveTypeRoots(this.getCompilationSettings(), this
|
|
170971
|
+
return getEffectiveTypeRoots(this.getCompilationSettings(), this) || [];
|
|
170684
170972
|
}
|
|
170685
170973
|
/** @internal */
|
|
170686
170974
|
updateErrorOnNoInputFiles(fileNames) {
|
|
@@ -170929,6 +171217,10 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
170929
171217
|
function printProjectWithoutFileNames(project) {
|
|
170930
171218
|
project.print(
|
|
170931
171219
|
/*writeProjectFileNames*/
|
|
171220
|
+
false,
|
|
171221
|
+
/*writeFileExplaination*/
|
|
171222
|
+
false,
|
|
171223
|
+
/*writeFileVersionAndText*/
|
|
170932
171224
|
false
|
|
170933
171225
|
);
|
|
170934
171226
|
}
|
|
@@ -171633,7 +171925,11 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
171633
171925
|
this.logger.info("`remove Project::");
|
|
171634
171926
|
project.print(
|
|
171635
171927
|
/*writeProjectFileNames*/
|
|
171636
|
-
true
|
|
171928
|
+
true,
|
|
171929
|
+
/*writeFileExplaination*/
|
|
171930
|
+
true,
|
|
171931
|
+
/*writeFileVersionAndText*/
|
|
171932
|
+
false
|
|
171637
171933
|
);
|
|
171638
171934
|
project.close();
|
|
171639
171935
|
if (Debug.shouldAssert(1 /* Normal */)) {
|
|
@@ -171772,7 +172068,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
171772
172068
|
}
|
|
171773
172069
|
deleteScriptInfo(info) {
|
|
171774
172070
|
this.filenameToScriptInfo.delete(info.path);
|
|
171775
|
-
this.filenameToScriptInfoVersion.set(info.path, info.
|
|
172071
|
+
this.filenameToScriptInfoVersion.set(info.path, info.textStorage.version);
|
|
171776
172072
|
const realpath = info.getRealpathIfDifferent();
|
|
171777
172073
|
if (realpath) {
|
|
171778
172074
|
this.realpathToScriptInfos.remove(realpath, info);
|
|
@@ -172856,7 +173152,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
172856
173152
|
const documentPositionMapper = getDocumentPositionMapper(
|
|
172857
173153
|
{ getCanonicalFileName: this.toCanonicalFileName, log: (s) => this.logger.info(s), getSourceFileLike: (f) => this.getSourceFileLike(f, projectName, declarationInfo) },
|
|
172858
173154
|
declarationInfo.fileName,
|
|
172859
|
-
declarationInfo.getLineInfo(),
|
|
173155
|
+
declarationInfo.textStorage.getLineInfo(),
|
|
172860
173156
|
readMapFile
|
|
172861
173157
|
);
|
|
172862
173158
|
readMapFile = void 0;
|
|
@@ -174685,7 +174981,6 @@ ${json}${newLine}`;
|
|
|
174685
174981
|
"signatureHelp-full" /* SignatureHelpFull */,
|
|
174686
174982
|
"navto" /* Navto */,
|
|
174687
174983
|
"navto-full" /* NavtoFull */,
|
|
174688
|
-
"occurrences" /* Occurrences */,
|
|
174689
174984
|
"documentHighlights" /* DocumentHighlights */,
|
|
174690
174985
|
"documentHighlights-full" /* DocumentHighlightsFull */
|
|
174691
174986
|
];
|
|
@@ -175118,9 +175413,6 @@ ${json}${newLine}`;
|
|
|
175118
175413
|
false
|
|
175119
175414
|
));
|
|
175120
175415
|
},
|
|
175121
|
-
["occurrences" /* Occurrences */]: (request) => {
|
|
175122
|
-
return this.requiredResponse(this.getOccurrences(request.arguments));
|
|
175123
|
-
},
|
|
175124
175416
|
["documentHighlights" /* DocumentHighlights */]: (request) => {
|
|
175125
175417
|
return this.requiredResponse(this.getDocumentHighlights(
|
|
175126
175418
|
request.arguments,
|
|
@@ -176083,21 +176375,6 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
176083
176375
|
const implementations = this.mapImplementationLocations(project.getLanguageService().getImplementationAtPosition(file, position) || emptyArray2, project);
|
|
176084
176376
|
return simplifiedResult ? implementations.map(({ fileName, textSpan, contextSpan }) => this.toFileSpanWithContext(fileName, textSpan, contextSpan, project)) : implementations.map(Session3.mapToOriginalLocation);
|
|
176085
176377
|
}
|
|
176086
|
-
getOccurrences(args) {
|
|
176087
|
-
const { file, project } = this.getFileAndProject(args);
|
|
176088
|
-
const position = this.getPositionInFile(args, file);
|
|
176089
|
-
const occurrences = project.getLanguageService().getOccurrencesAtPosition(file, position);
|
|
176090
|
-
return occurrences ? occurrences.map((occurrence) => {
|
|
176091
|
-
const { fileName, isWriteAccess: isWriteAccess2, textSpan, isInString: isInString2, contextSpan } = occurrence;
|
|
176092
|
-
const scriptInfo = project.getScriptInfo(fileName);
|
|
176093
|
-
return {
|
|
176094
|
-
...toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo),
|
|
176095
|
-
file: fileName,
|
|
176096
|
-
isWriteAccess: isWriteAccess2,
|
|
176097
|
-
...isInString2 ? { isInString: isInString2 } : void 0
|
|
176098
|
-
};
|
|
176099
|
-
}) : emptyArray2;
|
|
176100
|
-
}
|
|
176101
176378
|
getSyntacticDiagnosticsSync(args) {
|
|
176102
176379
|
const { configFile } = this.getConfigFileAndProject(args);
|
|
176103
176380
|
if (configFile) {
|
|
@@ -176508,7 +176785,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
176508
176785
|
formatOptions
|
|
176509
176786
|
);
|
|
176510
176787
|
if (args.key === "\n" && (!edits || edits.length === 0 || allEditsBeforePos(edits, position))) {
|
|
176511
|
-
const { lineText, absolutePosition } = scriptInfo.getAbsolutePositionAndLineText(args.line);
|
|
176788
|
+
const { lineText, absolutePosition } = scriptInfo.textStorage.getAbsolutePositionAndLineText(args.line);
|
|
176512
176789
|
if (lineText && lineText.search("\\S") < 0) {
|
|
176513
176790
|
const preferredIndent = languageService.getIndentationAtPosition(file, position, formatOptions);
|
|
176514
176791
|
let hasIndent = 0;
|
|
@@ -176733,6 +177010,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
176733
177010
|
change(args) {
|
|
176734
177011
|
const scriptInfo = this.projectService.getScriptInfo(args.file);
|
|
176735
177012
|
Debug.assert(!!scriptInfo);
|
|
177013
|
+
scriptInfo.textStorage.switchToScriptVersionCache();
|
|
176736
177014
|
const start = scriptInfo.lineOffsetToPosition(args.line, args.offset);
|
|
176737
177015
|
const end = scriptInfo.lineOffsetToPosition(args.endLine, args.endOffset);
|
|
176738
177016
|
if (start >= 0) {
|
|
@@ -177025,10 +177303,10 @@ ${e.message}`;
|
|
|
177025
177303
|
}
|
|
177026
177304
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
177027
177305
|
}
|
|
177028
|
-
getCombinedCodeFix({ scope, fixId:
|
|
177306
|
+
getCombinedCodeFix({ scope, fixId: fixId52 }, simplifiedResult) {
|
|
177029
177307
|
Debug.assert(scope.type === "file");
|
|
177030
177308
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
177031
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
177309
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId52, this.getFormatOptions(file), this.getPreferences(file));
|
|
177032
177310
|
if (simplifiedResult) {
|
|
177033
177311
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
177034
177312
|
} else {
|
|
@@ -177067,8 +177345,8 @@ ${e.message}`;
|
|
|
177067
177345
|
mapCodeAction({ description: description2, changes, commands }) {
|
|
177068
177346
|
return { description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
177069
177347
|
}
|
|
177070
|
-
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId:
|
|
177071
|
-
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
177348
|
+
mapCodeFixAction({ fixName: fixName8, description: description2, changes, commands, fixId: fixId52, fixAllDescription }) {
|
|
177349
|
+
return { fixName: fixName8, description: description2, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId52, fixAllDescription };
|
|
177072
177350
|
}
|
|
177073
177351
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
177074
177352
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -178688,7 +178966,6 @@ ${e.message}`;
|
|
|
178688
178966
|
createTypeChecker: () => createTypeChecker,
|
|
178689
178967
|
createTypeReferenceDirectiveResolutionCache: () => createTypeReferenceDirectiveResolutionCache,
|
|
178690
178968
|
createTypeReferenceResolutionLoader: () => createTypeReferenceResolutionLoader,
|
|
178691
|
-
createUnderscoreEscapedMultiMap: () => createUnderscoreEscapedMultiMap,
|
|
178692
178969
|
createUnparsedSourceFile: () => createUnparsedSourceFile,
|
|
178693
178970
|
createWatchCompilerHost: () => createWatchCompilerHost2,
|
|
178694
178971
|
createWatchCompilerHostOfConfigFile: () => createWatchCompilerHostOfConfigFile,
|
|
@@ -180099,7 +180376,6 @@ ${e.message}`;
|
|
|
180099
180376
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
180100
180377
|
noop: () => noop,
|
|
180101
180378
|
noopFileWatcher: () => noopFileWatcher,
|
|
180102
|
-
noopPush: () => noopPush,
|
|
180103
180379
|
normalizePath: () => normalizePath,
|
|
180104
180380
|
normalizeSlashes: () => normalizeSlashes,
|
|
180105
180381
|
not: () => not,
|
|
@@ -181048,7 +181324,6 @@ ${e.message}`;
|
|
|
181048
181324
|
createTypeChecker: () => createTypeChecker,
|
|
181049
181325
|
createTypeReferenceDirectiveResolutionCache: () => createTypeReferenceDirectiveResolutionCache,
|
|
181050
181326
|
createTypeReferenceResolutionLoader: () => createTypeReferenceResolutionLoader,
|
|
181051
|
-
createUnderscoreEscapedMultiMap: () => createUnderscoreEscapedMultiMap,
|
|
181052
181327
|
createUnparsedSourceFile: () => createUnparsedSourceFile,
|
|
181053
181328
|
createWatchCompilerHost: () => createWatchCompilerHost2,
|
|
181054
181329
|
createWatchCompilerHostOfConfigFile: () => createWatchCompilerHostOfConfigFile,
|
|
@@ -182459,7 +182734,6 @@ ${e.message}`;
|
|
|
182459
182734
|
nodeToDisplayParts: () => nodeToDisplayParts,
|
|
182460
182735
|
noop: () => noop,
|
|
182461
182736
|
noopFileWatcher: () => noopFileWatcher,
|
|
182462
|
-
noopPush: () => noopPush,
|
|
182463
182737
|
normalizePath: () => normalizePath,
|
|
182464
182738
|
normalizeSlashes: () => normalizeSlashes,
|
|
182465
182739
|
not: () => not,
|