typescript 5.7.0-dev.20240822 → 5.7.0-dev.20240824
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +10 -9
- package/lib/typescript.js +470 -388
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -2265,7 +2265,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2265
2265
|
|
|
2266
2266
|
// src/compiler/corePublic.ts
|
|
2267
2267
|
var versionMajorMinor = "5.7";
|
|
2268
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2268
|
+
var version = `${versionMajorMinor}.0-dev.20240824`;
|
|
2269
2269
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2270
2270
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2271
2271
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9539,6 +9539,8 @@ var Diagnostics = {
|
|
|
9539
9539
|
/*reportsDeprecated*/
|
|
9540
9540
|
true
|
|
9541
9541
|
),
|
|
9542
|
+
Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute: diag(1541, 1 /* Error */, "Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribut_1541", "Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute."),
|
|
9543
|
+
Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute: diag(1542, 1 /* Error */, "Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute_1542", "Type import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute."),
|
|
9542
9544
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
9543
9545
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
9544
9546
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -11246,6 +11248,8 @@ var Diagnostics = {
|
|
|
11246
11248
|
Add_all_optional_parameters: diag(95193, 3 /* Message */, "Add_all_optional_parameters_95193", "Add all optional parameters"),
|
|
11247
11249
|
Wrap_in_parentheses: diag(95194, 3 /* Message */, "Wrap_in_parentheses_95194", "Wrap in parentheses"),
|
|
11248
11250
|
Wrap_all_invalid_decorator_expressions_in_parentheses: diag(95195, 3 /* Message */, "Wrap_all_invalid_decorator_expressions_in_parentheses_95195", "Wrap all invalid decorator expressions in parentheses"),
|
|
11251
|
+
Add_resolution_mode_import_attribute: diag(95196, 3 /* Message */, "Add_resolution_mode_import_attribute_95196", "Add 'resolution-mode' import attribute"),
|
|
11252
|
+
Add_resolution_mode_import_attribute_to_all_type_only_imports_that_need_it: diag(95197, 3 /* Message */, "Add_resolution_mode_import_attribute_to_all_type_only_imports_that_need_it_95197", "Add 'resolution-mode' import attribute to all type-only imports that need it"),
|
|
11249
11253
|
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."),
|
|
11250
11254
|
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'."),
|
|
11251
11255
|
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?"),
|
|
@@ -49162,7 +49166,7 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
|
|
49162
49166
|
cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, result.kind, modulePaths, result.moduleSpecifiers);
|
|
49163
49167
|
return result;
|
|
49164
49168
|
}
|
|
49165
|
-
function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName, compilerOptions, host, options = {}) {
|
|
49169
|
+
function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName, compilerOptions, host, preferences, options = {}) {
|
|
49166
49170
|
const info = getInfo(importingFile.fileName, host);
|
|
49167
49171
|
const importMode = options.overrideImportMode ?? importingFile.impliedNodeFormat;
|
|
49168
49172
|
return getLocalModuleSpecifier(
|
|
@@ -49171,7 +49175,7 @@ function getLocalModuleSpecifierBetweenFileNames(importingFile, targetFileName,
|
|
|
49171
49175
|
compilerOptions,
|
|
49172
49176
|
host,
|
|
49173
49177
|
importMode,
|
|
49174
|
-
getModuleSpecifierPreferences(
|
|
49178
|
+
getModuleSpecifierPreferences(preferences, host, compilerOptions, importingFile)
|
|
49175
49179
|
);
|
|
49176
49180
|
}
|
|
49177
49181
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
@@ -53077,7 +53081,7 @@ function createTypeChecker(host) {
|
|
|
53077
53081
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, !ignoreErrors ? moduleReferenceExpression : void 0, isForAugmentation) : void 0;
|
|
53078
53082
|
}
|
|
53079
53083
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
53080
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
53084
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
53081
53085
|
if (errorNode && startsWith(moduleReference, "@types/")) {
|
|
53082
53086
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
53083
53087
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -53146,14 +53150,11 @@ function createTypeChecker(host) {
|
|
|
53146
53150
|
if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
|
|
53147
53151
|
diagnosticDetails = createModeMismatchDetails(currentSourceFile);
|
|
53148
53152
|
}
|
|
53153
|
+
const message = (overrideHost == null ? void 0 : overrideHost.kind) === 272 /* ImportDeclaration */ && ((_j = overrideHost.importClause) == null ? void 0 : _j.isTypeOnly) ? Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : (overrideHost == null ? void 0 : overrideHost.kind) === 205 /* ImportType */ ? Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead;
|
|
53149
53154
|
diagnostics.add(createDiagnosticForNodeFromMessageChain(
|
|
53150
53155
|
getSourceFileOfNode(errorNode),
|
|
53151
53156
|
errorNode,
|
|
53152
|
-
chainDiagnosticMessages(
|
|
53153
|
-
diagnosticDetails,
|
|
53154
|
-
Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead,
|
|
53155
|
-
moduleReference
|
|
53156
|
-
)
|
|
53157
|
+
chainDiagnosticMessages(diagnosticDetails, message, moduleReference)
|
|
53157
53158
|
));
|
|
53158
53159
|
}
|
|
53159
53160
|
}
|
|
@@ -53212,14 +53213,14 @@ function createTypeChecker(host) {
|
|
|
53212
53213
|
error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
53213
53214
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
53214
53215
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
53215
|
-
const suggestedExt = (
|
|
53216
|
+
const suggestedExt = (_k = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _k[1];
|
|
53216
53217
|
if (suggestedExt) {
|
|
53217
53218
|
error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
|
|
53218
53219
|
} else {
|
|
53219
53220
|
error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
|
|
53220
53221
|
}
|
|
53221
53222
|
} else {
|
|
53222
|
-
if ((
|
|
53223
|
+
if ((_l = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _l.alternateResult) {
|
|
53223
53224
|
const errorInfo = createModuleNotFoundChain(currentSourceFile, host, moduleReference, mode, moduleReference);
|
|
53224
53225
|
errorOrSuggestion(
|
|
53225
53226
|
/*isError*/
|
|
@@ -150578,22 +150579,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
150578
150579
|
}
|
|
150579
150580
|
return [];
|
|
150580
150581
|
}
|
|
150581
|
-
function getCodeFixesAtPosition(fileName, start, end,
|
|
150582
|
+
function getCodeFixesAtPosition(fileName, start, end, errorCodes68, formatOptions, preferences = emptyOptions) {
|
|
150582
150583
|
synchronizeHostData();
|
|
150583
150584
|
const sourceFile = getValidSourceFile(fileName);
|
|
150584
150585
|
const span = createTextSpanFromBounds(start, end);
|
|
150585
150586
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
150586
|
-
return flatMap(deduplicate(
|
|
150587
|
+
return flatMap(deduplicate(errorCodes68, equateValues, compareValues), (errorCode) => {
|
|
150587
150588
|
cancellationToken.throwIfCancellationRequested();
|
|
150588
150589
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
150589
150590
|
});
|
|
150590
150591
|
}
|
|
150591
|
-
function getCombinedCodeFix(scope,
|
|
150592
|
+
function getCombinedCodeFix(scope, fixId56, formatOptions, preferences = emptyOptions) {
|
|
150592
150593
|
synchronizeHostData();
|
|
150593
150594
|
Debug.assert(scope.type === "file");
|
|
150594
150595
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
150595
150596
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
150596
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
150597
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId56, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
150597
150598
|
}
|
|
150598
150599
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
150599
150600
|
synchronizeHostData();
|
|
@@ -152265,14 +152266,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
|
|
|
152265
152266
|
void 0
|
|
152266
152267
|
);
|
|
152267
152268
|
}
|
|
152268
|
-
function createCodeFixAction(fixName8, changes, description3,
|
|
152269
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
152269
|
+
function createCodeFixAction(fixName8, changes, description3, fixId56, fixAllDescription, command) {
|
|
152270
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId56, diagnosticToString(fixAllDescription), command);
|
|
152270
152271
|
}
|
|
152271
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description3,
|
|
152272
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
152272
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId56, fixAllDescription, command) {
|
|
152273
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId56, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
152273
152274
|
}
|
|
152274
|
-
function createCodeFixActionWorker(fixName8, description3, changes,
|
|
152275
|
-
return { fixName: fixName8, description: description3, changes, fixId:
|
|
152275
|
+
function createCodeFixActionWorker(fixName8, description3, changes, fixId56, fixAllDescription, command) {
|
|
152276
|
+
return { fixName: fixName8, description: description3, changes, fixId: fixId56, fixAllDescription, commands: command ? [command] : void 0 };
|
|
152276
152277
|
}
|
|
152277
152278
|
function registerCodeFix(reg) {
|
|
152278
152279
|
for (const error2 of reg.errorCodes) {
|
|
@@ -152280,9 +152281,9 @@ function registerCodeFix(reg) {
|
|
|
152280
152281
|
errorCodeToFixes.add(String(error2), reg);
|
|
152281
152282
|
}
|
|
152282
152283
|
if (reg.fixIds) {
|
|
152283
|
-
for (const
|
|
152284
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
152285
|
-
fixIdToRegistration.set(
|
|
152284
|
+
for (const fixId56 of reg.fixIds) {
|
|
152285
|
+
Debug.assert(!fixIdToRegistration.has(fixId56));
|
|
152286
|
+
fixIdToRegistration.set(fixId56, reg);
|
|
152286
152287
|
}
|
|
152287
152288
|
}
|
|
152288
152289
|
}
|
|
@@ -152291,15 +152292,15 @@ function getSupportedErrorCodes() {
|
|
|
152291
152292
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
152292
152293
|
}
|
|
152293
152294
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
152294
|
-
const { errorCodes:
|
|
152295
|
+
const { errorCodes: errorCodes68 } = registration;
|
|
152295
152296
|
let maybeFixableDiagnostics = 0;
|
|
152296
152297
|
for (const diag2 of diagnostics) {
|
|
152297
|
-
if (contains(
|
|
152298
|
+
if (contains(errorCodes68, diag2.code)) maybeFixableDiagnostics++;
|
|
152298
152299
|
if (maybeFixableDiagnostics > 1) break;
|
|
152299
152300
|
}
|
|
152300
152301
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
152301
|
-
return ({ fixId:
|
|
152302
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
152302
|
+
return ({ fixId: fixId56, fixAllDescription, ...action }) => {
|
|
152303
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId56, fixAllDescription };
|
|
152303
152304
|
};
|
|
152304
152305
|
}
|
|
152305
152306
|
function getFixes(context) {
|
|
@@ -152316,14 +152317,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
152316
152317
|
function createFileTextChanges(fileName, textChanges2) {
|
|
152317
152318
|
return { fileName, textChanges: textChanges2 };
|
|
152318
152319
|
}
|
|
152319
|
-
function codeFixAll(context,
|
|
152320
|
+
function codeFixAll(context, errorCodes68, use) {
|
|
152320
152321
|
const commands = [];
|
|
152321
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
152322
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes68, (diag2) => use(t, diag2, commands)));
|
|
152322
152323
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
152323
152324
|
}
|
|
152324
|
-
function eachDiagnostic(context,
|
|
152325
|
+
function eachDiagnostic(context, errorCodes68, cb) {
|
|
152325
152326
|
for (const diag2 of getDiagnostics(context)) {
|
|
152326
|
-
if (contains(
|
|
152327
|
+
if (contains(errorCodes68, diag2.code)) {
|
|
152327
152328
|
cb(diag2);
|
|
152328
152329
|
}
|
|
152329
152330
|
}
|
|
@@ -152837,19 +152838,99 @@ function makeChange6(changeTracker, sourceFile, pos) {
|
|
|
152837
152838
|
changeTracker.replaceNode(sourceFile, decorator.expression, replacement);
|
|
152838
152839
|
}
|
|
152839
152840
|
|
|
152840
|
-
// src/services/codefixes/
|
|
152841
|
-
var fixId7 = "
|
|
152842
|
-
var errorCodes7 = [
|
|
152841
|
+
// src/services/codefixes/addMissingResolutionModeImportAttribute.ts
|
|
152842
|
+
var fixId7 = "addMissingResolutionModeImportAttribute";
|
|
152843
|
+
var errorCodes7 = [
|
|
152844
|
+
Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code,
|
|
152845
|
+
Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute.code
|
|
152846
|
+
];
|
|
152843
152847
|
registerCodeFix({
|
|
152844
152848
|
errorCodes: errorCodes7,
|
|
152845
|
-
getCodeActions: function
|
|
152846
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange7(t, context.sourceFile, context.span.start));
|
|
152847
|
-
return [createCodeFixAction(fixId7, changes, Diagnostics.
|
|
152849
|
+
getCodeActions: function getCodeActionsToAddMissingResolutionModeImportAttribute(context) {
|
|
152850
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange7(t, context.sourceFile, context.span.start, context.program, context.host, context.preferences));
|
|
152851
|
+
return [createCodeFixAction(fixId7, changes, Diagnostics.Add_resolution_mode_import_attribute, fixId7, Diagnostics.Add_resolution_mode_import_attribute_to_all_type_only_imports_that_need_it)];
|
|
152848
152852
|
},
|
|
152849
152853
|
fixIds: [fixId7],
|
|
152850
|
-
getAllCodeActions: (context) => codeFixAll(context, errorCodes7, (changes, diag2) => makeChange7(changes, diag2.file, diag2.start))
|
|
152854
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes7, (changes, diag2) => makeChange7(changes, diag2.file, diag2.start, context.program, context.host, context.preferences))
|
|
152851
152855
|
});
|
|
152852
|
-
function makeChange7(changeTracker, sourceFile,
|
|
152856
|
+
function makeChange7(changeTracker, sourceFile, pos, program, host, preferences) {
|
|
152857
|
+
var _a, _b, _c;
|
|
152858
|
+
const token = getTokenAtPosition(sourceFile, pos);
|
|
152859
|
+
const importNode = findAncestor(token, or(isImportDeclaration, isImportTypeNode));
|
|
152860
|
+
Debug.assert(!!importNode, "Expected position to be owned by an ImportDeclaration or ImportType.");
|
|
152861
|
+
const useSingleQuotes = getQuotePreference(sourceFile, preferences) === 0 /* Single */;
|
|
152862
|
+
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importNode);
|
|
152863
|
+
const canUseImportMode = !moduleSpecifier || ((_a = resolveModuleName(
|
|
152864
|
+
moduleSpecifier.text,
|
|
152865
|
+
sourceFile.fileName,
|
|
152866
|
+
program.getCompilerOptions(),
|
|
152867
|
+
host,
|
|
152868
|
+
program.getModuleResolutionCache(),
|
|
152869
|
+
/*redirectedReference*/
|
|
152870
|
+
void 0,
|
|
152871
|
+
99 /* ESNext */
|
|
152872
|
+
).resolvedModule) == null ? void 0 : _a.resolvedFileName) === ((_c = (_b = program.getResolvedModuleFromModuleSpecifier(
|
|
152873
|
+
moduleSpecifier,
|
|
152874
|
+
sourceFile
|
|
152875
|
+
)) == null ? void 0 : _b.resolvedModule) == null ? void 0 : _c.resolvedFileName);
|
|
152876
|
+
const attributes = importNode.attributes ? factory.updateImportAttributes(
|
|
152877
|
+
importNode.attributes,
|
|
152878
|
+
factory.createNodeArray([
|
|
152879
|
+
...importNode.attributes.elements,
|
|
152880
|
+
factory.createImportAttribute(
|
|
152881
|
+
factory.createStringLiteral("resolution-mode", useSingleQuotes),
|
|
152882
|
+
factory.createStringLiteral(canUseImportMode ? "import" : "require", useSingleQuotes)
|
|
152883
|
+
)
|
|
152884
|
+
], importNode.attributes.elements.hasTrailingComma),
|
|
152885
|
+
importNode.attributes.multiLine
|
|
152886
|
+
) : factory.createImportAttributes(
|
|
152887
|
+
factory.createNodeArray([
|
|
152888
|
+
factory.createImportAttribute(
|
|
152889
|
+
factory.createStringLiteral("resolution-mode", useSingleQuotes),
|
|
152890
|
+
factory.createStringLiteral(canUseImportMode ? "import" : "require", useSingleQuotes)
|
|
152891
|
+
)
|
|
152892
|
+
])
|
|
152893
|
+
);
|
|
152894
|
+
if (importNode.kind === 272 /* ImportDeclaration */) {
|
|
152895
|
+
changeTracker.replaceNode(
|
|
152896
|
+
sourceFile,
|
|
152897
|
+
importNode,
|
|
152898
|
+
factory.updateImportDeclaration(
|
|
152899
|
+
importNode,
|
|
152900
|
+
importNode.modifiers,
|
|
152901
|
+
importNode.importClause,
|
|
152902
|
+
importNode.moduleSpecifier,
|
|
152903
|
+
attributes
|
|
152904
|
+
)
|
|
152905
|
+
);
|
|
152906
|
+
} else {
|
|
152907
|
+
changeTracker.replaceNode(
|
|
152908
|
+
sourceFile,
|
|
152909
|
+
importNode,
|
|
152910
|
+
factory.updateImportTypeNode(
|
|
152911
|
+
importNode,
|
|
152912
|
+
importNode.argument,
|
|
152913
|
+
attributes,
|
|
152914
|
+
importNode.qualifier,
|
|
152915
|
+
importNode.typeArguments
|
|
152916
|
+
)
|
|
152917
|
+
);
|
|
152918
|
+
}
|
|
152919
|
+
}
|
|
152920
|
+
|
|
152921
|
+
// src/services/codefixes/addNameToNamelessParameter.ts
|
|
152922
|
+
var fixId8 = "addNameToNamelessParameter";
|
|
152923
|
+
var errorCodes8 = [Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1.code];
|
|
152924
|
+
registerCodeFix({
|
|
152925
|
+
errorCodes: errorCodes8,
|
|
152926
|
+
getCodeActions: function getCodeActionsToAddNameToNamelessParameter(context) {
|
|
152927
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange8(t, context.sourceFile, context.span.start));
|
|
152928
|
+
return [createCodeFixAction(fixId8, changes, Diagnostics.Add_parameter_name, fixId8, Diagnostics.Add_names_to_all_parameters_without_names)];
|
|
152929
|
+
},
|
|
152930
|
+
fixIds: [fixId8],
|
|
152931
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes8, (changes, diag2) => makeChange8(changes, diag2.file, diag2.start))
|
|
152932
|
+
});
|
|
152933
|
+
function makeChange8(changeTracker, sourceFile, start) {
|
|
152853
152934
|
const token = getTokenAtPosition(sourceFile, start);
|
|
152854
152935
|
const param = token.parent;
|
|
152855
152936
|
if (!isParameter(param)) {
|
|
@@ -152890,13 +152971,13 @@ function tryGetNextParam(sourceFile, param) {
|
|
|
152890
152971
|
|
|
152891
152972
|
// src/services/codefixes/addOptionalPropertyUndefined.ts
|
|
152892
152973
|
var addOptionalPropertyUndefined = "addOptionalPropertyUndefined";
|
|
152893
|
-
var
|
|
152974
|
+
var errorCodes9 = [
|
|
152894
152975
|
Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target.code,
|
|
152895
152976
|
Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
152896
152977
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code
|
|
152897
152978
|
];
|
|
152898
152979
|
registerCodeFix({
|
|
152899
|
-
errorCodes:
|
|
152980
|
+
errorCodes: errorCodes9,
|
|
152900
152981
|
getCodeActions(context) {
|
|
152901
152982
|
const typeChecker = context.program.getTypeChecker();
|
|
152902
152983
|
const toAdd = getPropertiesToAdd(context.sourceFile, context.span, typeChecker);
|
|
@@ -152967,18 +153048,18 @@ function addUndefinedToOptionalProperty(changes, toAdd) {
|
|
|
152967
153048
|
}
|
|
152968
153049
|
|
|
152969
153050
|
// src/services/codefixes/annotateWithTypeFromJSDoc.ts
|
|
152970
|
-
var
|
|
152971
|
-
var
|
|
153051
|
+
var fixId9 = "annotateWithTypeFromJSDoc";
|
|
153052
|
+
var errorCodes10 = [Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types.code];
|
|
152972
153053
|
registerCodeFix({
|
|
152973
|
-
errorCodes:
|
|
153054
|
+
errorCodes: errorCodes10,
|
|
152974
153055
|
getCodeActions(context) {
|
|
152975
153056
|
const decl = getDeclaration(context.sourceFile, context.span.start);
|
|
152976
153057
|
if (!decl) return;
|
|
152977
153058
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange8(t, context.sourceFile, decl));
|
|
152978
|
-
return [createCodeFixAction(
|
|
153059
|
+
return [createCodeFixAction(fixId9, changes, Diagnostics.Annotate_with_type_from_JSDoc, fixId9, Diagnostics.Annotate_everything_with_types_from_JSDoc)];
|
|
152979
153060
|
},
|
|
152980
|
-
fixIds: [
|
|
152981
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
153061
|
+
fixIds: [fixId9],
|
|
153062
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes10, (changes, diag2) => {
|
|
152982
153063
|
const decl = getDeclaration(diag2.file, diag2.start);
|
|
152983
153064
|
if (decl) doChange8(changes, diag2.file, decl);
|
|
152984
153065
|
})
|
|
@@ -153135,16 +153216,16 @@ function transformJSDocIndexSignature(node) {
|
|
|
153135
153216
|
}
|
|
153136
153217
|
|
|
153137
153218
|
// src/services/codefixes/convertFunctionToEs6Class.ts
|
|
153138
|
-
var
|
|
153139
|
-
var
|
|
153219
|
+
var fixId10 = "convertFunctionToEs6Class";
|
|
153220
|
+
var errorCodes11 = [Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration.code];
|
|
153140
153221
|
registerCodeFix({
|
|
153141
|
-
errorCodes:
|
|
153222
|
+
errorCodes: errorCodes11,
|
|
153142
153223
|
getCodeActions(context) {
|
|
153143
153224
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange9(t, context.sourceFile, context.span.start, context.program.getTypeChecker(), context.preferences, context.program.getCompilerOptions()));
|
|
153144
|
-
return [createCodeFixAction(
|
|
153225
|
+
return [createCodeFixAction(fixId10, changes, Diagnostics.Convert_function_to_an_ES2015_class, fixId10, Diagnostics.Convert_all_constructor_functions_to_classes)];
|
|
153145
153226
|
},
|
|
153146
|
-
fixIds: [
|
|
153147
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
153227
|
+
fixIds: [fixId10],
|
|
153228
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes11, (changes, err) => doChange9(changes, err.file, err.start, context.program.getTypeChecker(), context.preferences, context.program.getCompilerOptions()))
|
|
153148
153229
|
});
|
|
153149
153230
|
function doChange9(changes, sourceFile, position, checker, preferences, compilerOptions) {
|
|
153150
153231
|
const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position));
|
|
@@ -153416,18 +153497,18 @@ function tryGetPropertyName(node, compilerOptions, quotePreference) {
|
|
|
153416
153497
|
}
|
|
153417
153498
|
|
|
153418
153499
|
// src/services/codefixes/convertToAsyncFunction.ts
|
|
153419
|
-
var
|
|
153420
|
-
var
|
|
153500
|
+
var fixId11 = "convertToAsyncFunction";
|
|
153501
|
+
var errorCodes12 = [Diagnostics.This_may_be_converted_to_an_async_function.code];
|
|
153421
153502
|
var codeActionSucceeded = true;
|
|
153422
153503
|
registerCodeFix({
|
|
153423
|
-
errorCodes:
|
|
153504
|
+
errorCodes: errorCodes12,
|
|
153424
153505
|
getCodeActions(context) {
|
|
153425
153506
|
codeActionSucceeded = true;
|
|
153426
153507
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => convertToAsyncFunction(t, context.sourceFile, context.span.start, context.program.getTypeChecker()));
|
|
153427
|
-
return codeActionSucceeded ? [createCodeFixAction(
|
|
153508
|
+
return codeActionSucceeded ? [createCodeFixAction(fixId11, changes, Diagnostics.Convert_to_async_function, fixId11, Diagnostics.Convert_all_to_async_functions)] : [];
|
|
153428
153509
|
},
|
|
153429
|
-
fixIds: [
|
|
153430
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
153510
|
+
fixIds: [fixId11],
|
|
153511
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes12, (changes, err) => convertToAsyncFunction(changes, err.file, err.start, context.program.getTypeChecker()))
|
|
153431
153512
|
});
|
|
153432
153513
|
function convertToAsyncFunction(changes, sourceFile, position, checker) {
|
|
153433
153514
|
const tokenAtPosition = getTokenAtPosition(sourceFile, position);
|
|
@@ -154627,19 +154708,19 @@ function convertedImports(newImports, useSitesToUnqualify) {
|
|
|
154627
154708
|
}
|
|
154628
154709
|
|
|
154629
154710
|
// src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts
|
|
154630
|
-
var
|
|
154631
|
-
var
|
|
154711
|
+
var fixId12 = "correctQualifiedNameToIndexedAccessType";
|
|
154712
|
+
var errorCodes13 = [Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1.code];
|
|
154632
154713
|
registerCodeFix({
|
|
154633
|
-
errorCodes:
|
|
154714
|
+
errorCodes: errorCodes13,
|
|
154634
154715
|
getCodeActions(context) {
|
|
154635
154716
|
const qualifiedName = getQualifiedName(context.sourceFile, context.span.start);
|
|
154636
154717
|
if (!qualifiedName) return void 0;
|
|
154637
154718
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange10(t, context.sourceFile, qualifiedName));
|
|
154638
154719
|
const newText = `${qualifiedName.left.text}["${qualifiedName.right.text}"]`;
|
|
154639
|
-
return [createCodeFixAction(
|
|
154720
|
+
return [createCodeFixAction(fixId12, changes, [Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId12, Diagnostics.Rewrite_all_as_indexed_access_types)];
|
|
154640
154721
|
},
|
|
154641
|
-
fixIds: [
|
|
154642
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
154722
|
+
fixIds: [fixId12],
|
|
154723
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes13, (changes, diag2) => {
|
|
154643
154724
|
const q = getQualifiedName(diag2.file, diag2.start);
|
|
154644
154725
|
if (q) {
|
|
154645
154726
|
doChange10(changes, diag2.file, q);
|
|
@@ -154665,20 +154746,20 @@ function doChange10(changeTracker, sourceFile, qualifiedName) {
|
|
|
154665
154746
|
}
|
|
154666
154747
|
|
|
154667
154748
|
// src/services/codefixes/convertToTypeOnlyExport.ts
|
|
154668
|
-
var
|
|
154669
|
-
var
|
|
154749
|
+
var errorCodes14 = [Diagnostics.Re_exporting_a_type_when_0_is_enabled_requires_using_export_type.code];
|
|
154750
|
+
var fixId13 = "convertToTypeOnlyExport";
|
|
154670
154751
|
registerCodeFix({
|
|
154671
|
-
errorCodes:
|
|
154752
|
+
errorCodes: errorCodes14,
|
|
154672
154753
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyExport(context) {
|
|
154673
154754
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => fixSingleExportDeclaration(t, getExportSpecifierForDiagnosticSpan(context.span, context.sourceFile), context));
|
|
154674
154755
|
if (changes.length) {
|
|
154675
|
-
return [createCodeFixAction(
|
|
154756
|
+
return [createCodeFixAction(fixId13, changes, Diagnostics.Convert_to_type_only_export, fixId13, Diagnostics.Convert_all_re_exported_types_to_type_only_exports)];
|
|
154676
154757
|
}
|
|
154677
154758
|
},
|
|
154678
|
-
fixIds: [
|
|
154759
|
+
fixIds: [fixId13],
|
|
154679
154760
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyExport(context) {
|
|
154680
154761
|
const fixedExportDeclarations = /* @__PURE__ */ new Map();
|
|
154681
|
-
return codeFixAll(context,
|
|
154762
|
+
return codeFixAll(context, errorCodes14, (changes, diag2) => {
|
|
154682
154763
|
const exportSpecifier = getExportSpecifierForDiagnosticSpan(diag2, context.sourceFile);
|
|
154683
154764
|
if (exportSpecifier && addToSeen(fixedExportDeclarations, getNodeId(exportSpecifier.parent.parent))) {
|
|
154684
154765
|
fixSingleExportDeclaration(changes, exportSpecifier, context);
|
|
@@ -154737,18 +154818,18 @@ function getTypeExportSpecifiers(originExportSpecifier, context) {
|
|
|
154737
154818
|
);
|
|
154738
154819
|
return filter(exportClause.elements, (element) => {
|
|
154739
154820
|
var _a;
|
|
154740
|
-
return element === originExportSpecifier || ((_a = findDiagnosticForNode(element, diagnostics)) == null ? void 0 : _a.code) ===
|
|
154821
|
+
return element === originExportSpecifier || ((_a = findDiagnosticForNode(element, diagnostics)) == null ? void 0 : _a.code) === errorCodes14[0];
|
|
154741
154822
|
});
|
|
154742
154823
|
}
|
|
154743
154824
|
|
|
154744
154825
|
// src/services/codefixes/convertToTypeOnlyImport.ts
|
|
154745
|
-
var
|
|
154826
|
+
var errorCodes15 = [
|
|
154746
154827
|
Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code,
|
|
154747
154828
|
Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_verbatimModuleSyntax_is_enabled.code
|
|
154748
154829
|
];
|
|
154749
|
-
var
|
|
154830
|
+
var fixId14 = "convertToTypeOnlyImport";
|
|
154750
154831
|
registerCodeFix({
|
|
154751
|
-
errorCodes:
|
|
154832
|
+
errorCodes: errorCodes15,
|
|
154752
154833
|
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
|
|
154753
154834
|
var _a;
|
|
154754
154835
|
const declaration = getDeclaration2(context.sourceFile, context.span.start);
|
|
@@ -154756,15 +154837,15 @@ registerCodeFix({
|
|
|
154756
154837
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration));
|
|
154757
154838
|
const importDeclarationChanges = declaration.kind === 276 /* ImportSpecifier */ && isImportDeclaration(declaration.parent.parent.parent) && canConvertImportDeclarationForSpecifier(declaration, context.sourceFile, context.program) ? ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange11(t, context.sourceFile, declaration.parent.parent.parent)) : void 0;
|
|
154758
154839
|
const mainAction = createCodeFixAction(
|
|
154759
|
-
|
|
154840
|
+
fixId14,
|
|
154760
154841
|
changes,
|
|
154761
154842
|
declaration.kind === 276 /* ImportSpecifier */ ? [Diagnostics.Use_type_0, ((_a = declaration.propertyName) == null ? void 0 : _a.text) ?? declaration.name.text] : Diagnostics.Use_import_type,
|
|
154762
|
-
|
|
154843
|
+
fixId14,
|
|
154763
154844
|
Diagnostics.Fix_all_with_type_only_imports
|
|
154764
154845
|
);
|
|
154765
154846
|
if (some(importDeclarationChanges)) {
|
|
154766
154847
|
return [
|
|
154767
|
-
createCodeFixActionWithoutFixAll(
|
|
154848
|
+
createCodeFixActionWithoutFixAll(fixId14, importDeclarationChanges, Diagnostics.Use_import_type),
|
|
154768
154849
|
mainAction
|
|
154769
154850
|
];
|
|
154770
154851
|
}
|
|
@@ -154772,10 +154853,10 @@ registerCodeFix({
|
|
|
154772
154853
|
}
|
|
154773
154854
|
return void 0;
|
|
154774
154855
|
},
|
|
154775
|
-
fixIds: [
|
|
154856
|
+
fixIds: [fixId14],
|
|
154776
154857
|
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
|
|
154777
154858
|
const fixedImportDeclarations = /* @__PURE__ */ new Set();
|
|
154778
|
-
return codeFixAll(context,
|
|
154859
|
+
return codeFixAll(context, errorCodes15, (changes, diag2) => {
|
|
154779
154860
|
const errorDeclaration = getDeclaration2(diag2.file, diag2.start);
|
|
154780
154861
|
if ((errorDeclaration == null ? void 0 : errorDeclaration.kind) === 272 /* ImportDeclaration */ && !fixedImportDeclarations.has(errorDeclaration)) {
|
|
154781
154862
|
doChange11(changes, diag2.file, errorDeclaration);
|
|
@@ -154908,11 +154989,11 @@ function doChange11(changes, sourceFile, declaration) {
|
|
|
154908
154989
|
}
|
|
154909
154990
|
|
|
154910
154991
|
// src/services/codefixes/convertTypedefToType.ts
|
|
154911
|
-
var
|
|
154912
|
-
var
|
|
154992
|
+
var fixId15 = "convertTypedefToType";
|
|
154993
|
+
var errorCodes16 = [Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type.code];
|
|
154913
154994
|
registerCodeFix({
|
|
154914
|
-
fixIds: [
|
|
154915
|
-
errorCodes:
|
|
154995
|
+
fixIds: [fixId15],
|
|
154996
|
+
errorCodes: errorCodes16,
|
|
154916
154997
|
getCodeActions(context) {
|
|
154917
154998
|
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
154918
154999
|
const node = getTokenAtPosition(
|
|
@@ -154924,10 +155005,10 @@ registerCodeFix({
|
|
|
154924
155005
|
if (changes.length > 0) {
|
|
154925
155006
|
return [
|
|
154926
155007
|
createCodeFixAction(
|
|
154927
|
-
|
|
155008
|
+
fixId15,
|
|
154928
155009
|
changes,
|
|
154929
155010
|
Diagnostics.Convert_typedef_to_TypeScript_type,
|
|
154930
|
-
|
|
155011
|
+
fixId15,
|
|
154931
155012
|
Diagnostics.Convert_all_typedef_to_TypeScript_types
|
|
154932
155013
|
)
|
|
154933
155014
|
];
|
|
@@ -154935,7 +155016,7 @@ registerCodeFix({
|
|
|
154935
155016
|
},
|
|
154936
155017
|
getAllCodeActions: (context) => codeFixAll(
|
|
154937
155018
|
context,
|
|
154938
|
-
|
|
155019
|
+
errorCodes16,
|
|
154939
155020
|
(changes, diag2) => {
|
|
154940
155021
|
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
154941
155022
|
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
@@ -155078,10 +155159,10 @@ function getJSDocTypedefNodes(node) {
|
|
|
155078
155159
|
}
|
|
155079
155160
|
|
|
155080
155161
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
155081
|
-
var
|
|
155082
|
-
var
|
|
155162
|
+
var fixId16 = "convertLiteralTypeToMappedType";
|
|
155163
|
+
var errorCodes17 = [Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0.code];
|
|
155083
155164
|
registerCodeFix({
|
|
155084
|
-
errorCodes:
|
|
155165
|
+
errorCodes: errorCodes17,
|
|
155085
155166
|
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
|
|
155086
155167
|
const { sourceFile, span } = context;
|
|
155087
155168
|
const info = getInfo5(sourceFile, span.start);
|
|
@@ -155090,10 +155171,10 @@ registerCodeFix({
|
|
|
155090
155171
|
}
|
|
155091
155172
|
const { name, constraint } = info;
|
|
155092
155173
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange13(t, sourceFile, info));
|
|
155093
|
-
return [createCodeFixAction(
|
|
155174
|
+
return [createCodeFixAction(fixId16, changes, [Diagnostics.Convert_0_to_1_in_0, constraint, name], fixId16, Diagnostics.Convert_all_type_literals_to_mapped_type)];
|
|
155094
155175
|
},
|
|
155095
|
-
fixIds: [
|
|
155096
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
155176
|
+
fixIds: [fixId16],
|
|
155177
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes17, (changes, diag2) => {
|
|
155097
155178
|
const info = getInfo5(diag2.file, diag2.start);
|
|
155098
155179
|
if (info) {
|
|
155099
155180
|
doChange13(changes, diag2.file, info);
|
|
@@ -155139,25 +155220,25 @@ function doChange13(changes, sourceFile, { container, typeNode, constraint, name
|
|
|
155139
155220
|
}
|
|
155140
155221
|
|
|
155141
155222
|
// src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts
|
|
155142
|
-
var
|
|
155223
|
+
var errorCodes18 = [
|
|
155143
155224
|
Diagnostics.Class_0_incorrectly_implements_interface_1.code,
|
|
155144
155225
|
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code
|
|
155145
155226
|
];
|
|
155146
|
-
var
|
|
155227
|
+
var fixId17 = "fixClassIncorrectlyImplementsInterface";
|
|
155147
155228
|
registerCodeFix({
|
|
155148
|
-
errorCodes:
|
|
155229
|
+
errorCodes: errorCodes18,
|
|
155149
155230
|
getCodeActions(context) {
|
|
155150
155231
|
const { sourceFile, span } = context;
|
|
155151
155232
|
const classDeclaration = getClass(sourceFile, span.start);
|
|
155152
155233
|
return mapDefined(getEffectiveImplementsTypeNodes(classDeclaration), (implementedTypeNode) => {
|
|
155153
155234
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences));
|
|
155154
|
-
return changes.length === 0 ? void 0 : createCodeFixAction(
|
|
155235
|
+
return changes.length === 0 ? void 0 : createCodeFixAction(fixId17, changes, [Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId17, Diagnostics.Implement_all_unimplemented_interfaces);
|
|
155155
155236
|
});
|
|
155156
155237
|
},
|
|
155157
|
-
fixIds: [
|
|
155238
|
+
fixIds: [fixId17],
|
|
155158
155239
|
getAllCodeActions(context) {
|
|
155159
155240
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
155160
|
-
return codeFixAll(context,
|
|
155241
|
+
return codeFixAll(context, errorCodes18, (changes, diag2) => {
|
|
155161
155242
|
const classDeclaration = getClass(diag2.file, diag2.start);
|
|
155162
155243
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
155163
155244
|
for (const implementedTypeNode of getEffectiveImplementsTypeNodes(classDeclaration)) {
|
|
@@ -155223,7 +155304,7 @@ function getHeritageClauseSymbolTable(classDeclaration, checker) {
|
|
|
155223
155304
|
// src/services/codefixes/importFixes.ts
|
|
155224
155305
|
var importFixName = "import";
|
|
155225
155306
|
var importFixId = "fixMissingImport";
|
|
155226
|
-
var
|
|
155307
|
+
var errorCodes19 = [
|
|
155227
155308
|
Diagnostics.Cannot_find_name_0.code,
|
|
155228
155309
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
155229
155310
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
@@ -155245,7 +155326,7 @@ var errorCodes18 = [
|
|
|
155245
155326
|
Diagnostics.Cannot_find_namespace_0_Did_you_mean_1.code
|
|
155246
155327
|
];
|
|
155247
155328
|
registerCodeFix({
|
|
155248
|
-
errorCodes:
|
|
155329
|
+
errorCodes: errorCodes19,
|
|
155249
155330
|
getCodeActions(context) {
|
|
155250
155331
|
const { errorCode, preferences, sourceFile, span, program } = context;
|
|
155251
155332
|
const info = getFixInfos(
|
|
@@ -155281,7 +155362,7 @@ registerCodeFix({
|
|
|
155281
155362
|
host,
|
|
155282
155363
|
cancellationToken
|
|
155283
155364
|
);
|
|
155284
|
-
eachDiagnostic(context,
|
|
155365
|
+
eachDiagnostic(context, errorCodes19, (diag2) => importAdder.addImportFromDiagnostic(diag2, context));
|
|
155285
155366
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, importAdder.writeFixes));
|
|
155286
155367
|
}
|
|
155287
155368
|
});
|
|
@@ -155390,7 +155471,8 @@ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, pre
|
|
|
155390
155471
|
sourceFile,
|
|
155391
155472
|
exportingFileName,
|
|
155392
155473
|
compilerOptions,
|
|
155393
|
-
createModuleSpecifierResolutionHost(program, host)
|
|
155474
|
+
createModuleSpecifierResolutionHost(program, host),
|
|
155475
|
+
preferences
|
|
155394
155476
|
);
|
|
155395
155477
|
const importKind = getImportKind(futureExportingSourceFile, exportKind, program);
|
|
155396
155478
|
const addAsTypeOnly = getAddAsTypeOnly(
|
|
@@ -156755,8 +156837,8 @@ function getEmitModuleFormatOfFile(file, program) {
|
|
|
156755
156837
|
}
|
|
156756
156838
|
|
|
156757
156839
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
156758
|
-
var
|
|
156759
|
-
var
|
|
156840
|
+
var fixId18 = "addMissingConstraint";
|
|
156841
|
+
var errorCodes20 = [
|
|
156760
156842
|
// We want errors this could be attached to:
|
|
156761
156843
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
156762
156844
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -156769,20 +156851,20 @@ var errorCodes19 = [
|
|
|
156769
156851
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
156770
156852
|
];
|
|
156771
156853
|
registerCodeFix({
|
|
156772
|
-
errorCodes:
|
|
156854
|
+
errorCodes: errorCodes20,
|
|
156773
156855
|
getCodeActions(context) {
|
|
156774
156856
|
const { sourceFile, span, program, preferences, host } = context;
|
|
156775
156857
|
const info = getInfo6(program, sourceFile, span);
|
|
156776
156858
|
if (info === void 0) return;
|
|
156777
156859
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
156778
|
-
return [createCodeFixAction(
|
|
156860
|
+
return [createCodeFixAction(fixId18, changes, Diagnostics.Add_extends_constraint, fixId18, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
156779
156861
|
},
|
|
156780
|
-
fixIds: [
|
|
156862
|
+
fixIds: [fixId18],
|
|
156781
156863
|
getAllCodeActions: (context) => {
|
|
156782
156864
|
const { program, preferences, host } = context;
|
|
156783
156865
|
const seen = /* @__PURE__ */ new Map();
|
|
156784
156866
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
156785
|
-
eachDiagnostic(context,
|
|
156867
|
+
eachDiagnostic(context, errorCodes20, (diag2) => {
|
|
156786
156868
|
const info = getInfo6(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
156787
156869
|
if (info) {
|
|
156788
156870
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -156864,7 +156946,7 @@ function tryGetConstraintType(checker, node) {
|
|
|
156864
156946
|
var fixName = "fixOverrideModifier";
|
|
156865
156947
|
var fixAddOverrideId = "fixAddOverrideModifier";
|
|
156866
156948
|
var fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
156867
|
-
var
|
|
156949
|
+
var errorCodes21 = [
|
|
156868
156950
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
156869
156951
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
156870
156952
|
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
|
@@ -156928,19 +157010,19 @@ var errorCodeFixIdMap = {
|
|
|
156928
157010
|
}
|
|
156929
157011
|
};
|
|
156930
157012
|
registerCodeFix({
|
|
156931
|
-
errorCodes:
|
|
157013
|
+
errorCodes: errorCodes21,
|
|
156932
157014
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
156933
157015
|
const { errorCode, span } = context;
|
|
156934
157016
|
const info = errorCodeFixIdMap[errorCode];
|
|
156935
157017
|
if (!info) return emptyArray;
|
|
156936
|
-
const { descriptions, fixId:
|
|
157018
|
+
const { descriptions, fixId: fixId56, fixAllDescriptions } = info;
|
|
156937
157019
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
156938
157020
|
return [
|
|
156939
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
157021
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId56, fixAllDescriptions)
|
|
156940
157022
|
];
|
|
156941
157023
|
},
|
|
156942
157024
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
156943
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157025
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => {
|
|
156944
157026
|
const { code, start } = diag2;
|
|
156945
157027
|
const info = errorCodeFixIdMap[code];
|
|
156946
157028
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -157016,20 +157098,20 @@ function findContainerClassElementLike(sourceFile, pos) {
|
|
|
157016
157098
|
}
|
|
157017
157099
|
|
|
157018
157100
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
157019
|
-
var
|
|
157020
|
-
var
|
|
157101
|
+
var fixId19 = "fixNoPropertyAccessFromIndexSignature";
|
|
157102
|
+
var errorCodes22 = [
|
|
157021
157103
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
157022
157104
|
];
|
|
157023
157105
|
registerCodeFix({
|
|
157024
|
-
errorCodes:
|
|
157025
|
-
fixIds: [
|
|
157106
|
+
errorCodes: errorCodes22,
|
|
157107
|
+
fixIds: [fixId19],
|
|
157026
157108
|
getCodeActions(context) {
|
|
157027
157109
|
const { sourceFile, span, preferences } = context;
|
|
157028
157110
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
157029
157111
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange14(t, context.sourceFile, property, preferences));
|
|
157030
|
-
return [createCodeFixAction(
|
|
157112
|
+
return [createCodeFixAction(fixId19, changes, [Diagnostics.Use_element_access_for_0, property.name.text], fixId19, Diagnostics.Use_element_access_for_all_undeclared_properties)];
|
|
157031
157113
|
},
|
|
157032
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157114
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => doChange14(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
157033
157115
|
});
|
|
157034
157116
|
function doChange14(changes, sourceFile, node, preferences) {
|
|
157035
157117
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
@@ -157045,20 +157127,20 @@ function getPropertyAccessExpression(sourceFile, pos) {
|
|
|
157045
157127
|
}
|
|
157046
157128
|
|
|
157047
157129
|
// src/services/codefixes/fixImplicitThis.ts
|
|
157048
|
-
var
|
|
157049
|
-
var
|
|
157130
|
+
var fixId20 = "fixImplicitThis";
|
|
157131
|
+
var errorCodes23 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
157050
157132
|
registerCodeFix({
|
|
157051
|
-
errorCodes:
|
|
157133
|
+
errorCodes: errorCodes23,
|
|
157052
157134
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
157053
157135
|
const { sourceFile, program, span } = context;
|
|
157054
157136
|
let diagnostic;
|
|
157055
157137
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157056
157138
|
diagnostic = doChange15(t, sourceFile, span.start, program.getTypeChecker());
|
|
157057
157139
|
});
|
|
157058
|
-
return diagnostic ? [createCodeFixAction(
|
|
157140
|
+
return diagnostic ? [createCodeFixAction(fixId20, changes, diagnostic, fixId20, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
157059
157141
|
},
|
|
157060
|
-
fixIds: [
|
|
157061
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157142
|
+
fixIds: [fixId20],
|
|
157143
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes23, (changes, diag2) => {
|
|
157062
157144
|
doChange15(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
157063
157145
|
})
|
|
157064
157146
|
});
|
|
@@ -157103,25 +157185,25 @@ function doChange15(changes, sourceFile, pos, checker) {
|
|
|
157103
157185
|
}
|
|
157104
157186
|
|
|
157105
157187
|
// src/services/codefixes/fixImportNonExportedMember.ts
|
|
157106
|
-
var
|
|
157107
|
-
var
|
|
157188
|
+
var fixId21 = "fixImportNonExportedMember";
|
|
157189
|
+
var errorCodes24 = [
|
|
157108
157190
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
157109
157191
|
];
|
|
157110
157192
|
registerCodeFix({
|
|
157111
|
-
errorCodes:
|
|
157112
|
-
fixIds: [
|
|
157193
|
+
errorCodes: errorCodes24,
|
|
157194
|
+
fixIds: [fixId21],
|
|
157113
157195
|
getCodeActions(context) {
|
|
157114
157196
|
const { sourceFile, span, program } = context;
|
|
157115
157197
|
const info = getInfo7(sourceFile, span.start, program);
|
|
157116
157198
|
if (info === void 0) return void 0;
|
|
157117
157199
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, program, info));
|
|
157118
|
-
return [createCodeFixAction(
|
|
157200
|
+
return [createCodeFixAction(fixId21, changes, [Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId21, Diagnostics.Export_all_referenced_locals)];
|
|
157119
157201
|
},
|
|
157120
157202
|
getAllCodeActions(context) {
|
|
157121
157203
|
const { program } = context;
|
|
157122
157204
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157123
157205
|
const exports2 = /* @__PURE__ */ new Map();
|
|
157124
|
-
eachDiagnostic(context,
|
|
157206
|
+
eachDiagnostic(context, errorCodes24, (diag2) => {
|
|
157125
157207
|
const info = getInfo7(diag2.file, diag2.start, program);
|
|
157126
157208
|
if (info === void 0) return void 0;
|
|
157127
157209
|
const { exportName, node, moduleSourceFile } = info;
|
|
@@ -157261,20 +157343,20 @@ function getNodeOfSymbol(symbol) {
|
|
|
157261
157343
|
}
|
|
157262
157344
|
|
|
157263
157345
|
// src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
|
|
157264
|
-
var
|
|
157265
|
-
var
|
|
157346
|
+
var fixId22 = "fixIncorrectNamedTupleSyntax";
|
|
157347
|
+
var errorCodes25 = [
|
|
157266
157348
|
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,
|
|
157267
157349
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
157268
157350
|
];
|
|
157269
157351
|
registerCodeFix({
|
|
157270
|
-
errorCodes:
|
|
157352
|
+
errorCodes: errorCodes25,
|
|
157271
157353
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
157272
157354
|
const { sourceFile, span } = context;
|
|
157273
157355
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
157274
157356
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, namedTupleMember));
|
|
157275
|
-
return [createCodeFixAction(
|
|
157357
|
+
return [createCodeFixAction(fixId22, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId22, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
157276
157358
|
},
|
|
157277
|
-
fixIds: [
|
|
157359
|
+
fixIds: [fixId22]
|
|
157278
157360
|
});
|
|
157279
157361
|
function getNamedTupleMember(sourceFile, pos) {
|
|
157280
157362
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -157309,8 +157391,8 @@ function doChange17(changes, sourceFile, namedTupleMember) {
|
|
|
157309
157391
|
}
|
|
157310
157392
|
|
|
157311
157393
|
// src/services/codefixes/fixSpelling.ts
|
|
157312
|
-
var
|
|
157313
|
-
var
|
|
157394
|
+
var fixId23 = "fixSpelling";
|
|
157395
|
+
var errorCodes26 = [
|
|
157314
157396
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157315
157397
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157316
157398
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -157327,7 +157409,7 @@ var errorCodes25 = [
|
|
|
157327
157409
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
157328
157410
|
];
|
|
157329
157411
|
registerCodeFix({
|
|
157330
|
-
errorCodes:
|
|
157412
|
+
errorCodes: errorCodes26,
|
|
157331
157413
|
getCodeActions(context) {
|
|
157332
157414
|
const { sourceFile, errorCode } = context;
|
|
157333
157415
|
const info = getInfo8(sourceFile, context.span.start, context, errorCode);
|
|
@@ -157335,10 +157417,10 @@ registerCodeFix({
|
|
|
157335
157417
|
const { node, suggestedSymbol } = info;
|
|
157336
157418
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
157337
157419
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(t, sourceFile, node, suggestedSymbol, target));
|
|
157338
|
-
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)],
|
|
157420
|
+
return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId23, Diagnostics.Fix_all_detected_spelling_errors)];
|
|
157339
157421
|
},
|
|
157340
|
-
fixIds: [
|
|
157341
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157422
|
+
fixIds: [fixId23],
|
|
157423
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
157342
157424
|
const info = getInfo8(diag2.file, diag2.start, context, diag2.code);
|
|
157343
157425
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
157344
157426
|
if (info) doChange18(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
@@ -157427,17 +157509,17 @@ function getResolvedSourceFileFromImportDeclaration(context, importDeclaration,
|
|
|
157427
157509
|
}
|
|
157428
157510
|
|
|
157429
157511
|
// src/services/codefixes/returnValueCorrect.ts
|
|
157430
|
-
var
|
|
157512
|
+
var fixId24 = "returnValueCorrect";
|
|
157431
157513
|
var fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
157432
157514
|
var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
157433
157515
|
var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
157434
|
-
var
|
|
157516
|
+
var errorCodes27 = [
|
|
157435
157517
|
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
|
157436
157518
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
157437
157519
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
157438
157520
|
];
|
|
157439
157521
|
registerCodeFix({
|
|
157440
|
-
errorCodes:
|
|
157522
|
+
errorCodes: errorCodes27,
|
|
157441
157523
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
157442
157524
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
157443
157525
|
const { program, sourceFile, span: { start }, errorCode } = context;
|
|
@@ -157452,7 +157534,7 @@ registerCodeFix({
|
|
|
157452
157534
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
157453
157535
|
}
|
|
157454
157536
|
},
|
|
157455
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157537
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes27, (changes, diag2) => {
|
|
157456
157538
|
const info = getInfo9(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
157457
157539
|
if (!info) return void 0;
|
|
157458
157540
|
switch (context.fixId) {
|
|
@@ -157651,7 +157733,7 @@ function wrapBlockWithParen(changes, sourceFile, declaration, expression) {
|
|
|
157651
157733
|
}
|
|
157652
157734
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
157653
157735
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
157654
|
-
return createCodeFixAction(
|
|
157736
|
+
return createCodeFixAction(fixId24, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
157655
157737
|
}
|
|
157656
157738
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
157657
157739
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -157663,11 +157745,11 @@ function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration,
|
|
|
157663
157745
|
/*withParen*/
|
|
157664
157746
|
false
|
|
157665
157747
|
));
|
|
157666
|
-
return createCodeFixAction(
|
|
157748
|
+
return createCodeFixAction(fixId24, changes, Diagnostics.Remove_braces_from_arrow_function_body, fixRemoveBracesFromArrowFunctionBody, Diagnostics.Remove_braces_from_all_arrow_function_bodies_with_relevant_issues);
|
|
157667
157749
|
}
|
|
157668
157750
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
157669
157751
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
157670
|
-
return createCodeFixAction(
|
|
157752
|
+
return createCodeFixAction(fixId24, changes, Diagnostics.Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal, fixIdWrapTheBlockWithParen, Diagnostics.Wrap_all_object_literal_with_parentheses);
|
|
157671
157753
|
}
|
|
157672
157754
|
|
|
157673
157755
|
// src/services/codefixes/fixAddMissingMember.ts
|
|
@@ -157675,7 +157757,7 @@ var fixMissingMember = "fixMissingMember";
|
|
|
157675
157757
|
var fixMissingProperties = "fixMissingProperties";
|
|
157676
157758
|
var fixMissingAttributes = "fixMissingAttributes";
|
|
157677
157759
|
var fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
157678
|
-
var
|
|
157760
|
+
var errorCodes28 = [
|
|
157679
157761
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
157680
157762
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157681
157763
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -157685,7 +157767,7 @@ var errorCodes27 = [
|
|
|
157685
157767
|
Diagnostics.Cannot_find_name_0.code
|
|
157686
157768
|
];
|
|
157687
157769
|
registerCodeFix({
|
|
157688
|
-
errorCodes:
|
|
157770
|
+
errorCodes: errorCodes28,
|
|
157689
157771
|
getCodeActions(context) {
|
|
157690
157772
|
const typeChecker = context.program.getTypeChecker();
|
|
157691
157773
|
const info = getInfo10(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -157712,21 +157794,21 @@ registerCodeFix({
|
|
|
157712
157794
|
},
|
|
157713
157795
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
157714
157796
|
getAllCodeActions: (context) => {
|
|
157715
|
-
const { program, fixId:
|
|
157797
|
+
const { program, fixId: fixId56 } = context;
|
|
157716
157798
|
const checker = program.getTypeChecker();
|
|
157717
157799
|
const seen = /* @__PURE__ */ new Map();
|
|
157718
157800
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
157719
157801
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157720
|
-
eachDiagnostic(context,
|
|
157802
|
+
eachDiagnostic(context, errorCodes28, (diag2) => {
|
|
157721
157803
|
const info = getInfo10(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
157722
157804
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
|
|
157723
157805
|
return;
|
|
157724
157806
|
}
|
|
157725
|
-
if (
|
|
157807
|
+
if (fixId56 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
157726
157808
|
addFunctionDeclaration(changes, context, info);
|
|
157727
|
-
} else if (
|
|
157809
|
+
} else if (fixId56 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
157728
157810
|
addObjectLiteralProperties(changes, context, info);
|
|
157729
|
-
} else if (
|
|
157811
|
+
} else if (fixId56 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
157730
157812
|
addJsxAttributes(changes, context, info);
|
|
157731
157813
|
} else {
|
|
157732
157814
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -158295,17 +158377,17 @@ function findScope(node) {
|
|
|
158295
158377
|
}
|
|
158296
158378
|
|
|
158297
158379
|
// src/services/codefixes/fixAddMissingNewOperator.ts
|
|
158298
|
-
var
|
|
158299
|
-
var
|
|
158380
|
+
var fixId25 = "addMissingNewOperator";
|
|
158381
|
+
var errorCodes29 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
158300
158382
|
registerCodeFix({
|
|
158301
|
-
errorCodes:
|
|
158383
|
+
errorCodes: errorCodes29,
|
|
158302
158384
|
getCodeActions(context) {
|
|
158303
158385
|
const { sourceFile, span } = context;
|
|
158304
158386
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
158305
|
-
return [createCodeFixAction(
|
|
158387
|
+
return [createCodeFixAction(fixId25, changes, Diagnostics.Add_missing_new_operator_to_call, fixId25, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
158306
158388
|
},
|
|
158307
|
-
fixIds: [
|
|
158308
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158389
|
+
fixIds: [fixId25],
|
|
158390
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes29, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
158309
158391
|
});
|
|
158310
158392
|
function addMissingNewOperator(changes, sourceFile, span) {
|
|
158311
158393
|
const call = cast(findAncestorMatchingSpan2(sourceFile, span), isCallExpression);
|
|
@@ -158324,9 +158406,9 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
158324
158406
|
// src/services/codefixes/fixAddMissingParam.ts
|
|
158325
158407
|
var addMissingParamFixId = "addMissingParam";
|
|
158326
158408
|
var addOptionalParamFixId = "addOptionalParam";
|
|
158327
|
-
var
|
|
158409
|
+
var errorCodes30 = [Diagnostics.Expected_0_arguments_but_got_1.code];
|
|
158328
158410
|
registerCodeFix({
|
|
158329
|
-
errorCodes:
|
|
158411
|
+
errorCodes: errorCodes30,
|
|
158330
158412
|
fixIds: [addMissingParamFixId, addOptionalParamFixId],
|
|
158331
158413
|
getCodeActions(context) {
|
|
158332
158414
|
const info = getInfo11(context.sourceFile, context.program, context.span.start);
|
|
@@ -158359,7 +158441,7 @@ registerCodeFix({
|
|
|
158359
158441
|
}
|
|
158360
158442
|
return actions2;
|
|
158361
158443
|
},
|
|
158362
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158444
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
158363
158445
|
const info = getInfo11(context.sourceFile, context.program, diag2.start);
|
|
158364
158446
|
if (info) {
|
|
158365
158447
|
const { declarations, newParameters, newOptionalParameters } = info;
|
|
@@ -158562,12 +158644,12 @@ function getParameterType(importAdder, typeNode, scriptTarget) {
|
|
|
158562
158644
|
var fixName2 = "fixCannotFindModule";
|
|
158563
158645
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
158564
158646
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
158565
|
-
var
|
|
158647
|
+
var errorCodes31 = [
|
|
158566
158648
|
errorCodeCannotFindModule,
|
|
158567
158649
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
158568
158650
|
];
|
|
158569
158651
|
registerCodeFix({
|
|
158570
|
-
errorCodes:
|
|
158652
|
+
errorCodes: errorCodes31,
|
|
158571
158653
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
158572
158654
|
const { host, sourceFile, span: { start } } = context;
|
|
158573
158655
|
const packageName = tryGetImportedPackageName(sourceFile, start);
|
|
@@ -158585,7 +158667,7 @@ registerCodeFix({
|
|
|
158585
158667
|
},
|
|
158586
158668
|
fixIds: [fixIdInstallTypesPackage],
|
|
158587
158669
|
getAllCodeActions: (context) => {
|
|
158588
|
-
return codeFixAll(context,
|
|
158670
|
+
return codeFixAll(context, errorCodes31, (_changes, diag2, commands) => {
|
|
158589
158671
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
158590
158672
|
if (packageName === void 0) return void 0;
|
|
158591
158673
|
switch (context.fixId) {
|
|
@@ -158618,7 +158700,7 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
158618
158700
|
}
|
|
158619
158701
|
|
|
158620
158702
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
158621
|
-
var
|
|
158703
|
+
var errorCodes32 = [
|
|
158622
158704
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
158623
158705
|
Diagnostics.Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2.code,
|
|
158624
158706
|
Diagnostics.Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_and_3_more.code,
|
|
@@ -158626,18 +158708,18 @@ var errorCodes31 = [
|
|
|
158626
158708
|
Diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1.code,
|
|
158627
158709
|
Diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_and_2_more.code
|
|
158628
158710
|
];
|
|
158629
|
-
var
|
|
158711
|
+
var fixId26 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
158630
158712
|
registerCodeFix({
|
|
158631
|
-
errorCodes:
|
|
158713
|
+
errorCodes: errorCodes32,
|
|
158632
158714
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
158633
158715
|
const { sourceFile, span } = context;
|
|
158634
158716
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
158635
|
-
return changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
158717
|
+
return changes.length === 0 ? void 0 : [createCodeFixAction(fixId26, changes, Diagnostics.Implement_inherited_abstract_class, fixId26, Diagnostics.Implement_all_inherited_abstract_classes)];
|
|
158636
158718
|
},
|
|
158637
|
-
fixIds: [
|
|
158719
|
+
fixIds: [fixId26],
|
|
158638
158720
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
158639
158721
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
158640
|
-
return codeFixAll(context,
|
|
158722
|
+
return codeFixAll(context, errorCodes32, (changes, diag2) => {
|
|
158641
158723
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
158642
158724
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
158643
158725
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -158664,23 +158746,23 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
158664
158746
|
}
|
|
158665
158747
|
|
|
158666
158748
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
158667
|
-
var
|
|
158668
|
-
var
|
|
158749
|
+
var fixId27 = "classSuperMustPrecedeThisAccess";
|
|
158750
|
+
var errorCodes33 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
158669
158751
|
registerCodeFix({
|
|
158670
|
-
errorCodes:
|
|
158752
|
+
errorCodes: errorCodes33,
|
|
158671
158753
|
getCodeActions(context) {
|
|
158672
158754
|
const { sourceFile, span } = context;
|
|
158673
158755
|
const nodes = getNodes(sourceFile, span.start);
|
|
158674
158756
|
if (!nodes) return void 0;
|
|
158675
158757
|
const { constructor, superCall } = nodes;
|
|
158676
158758
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, sourceFile, constructor, superCall));
|
|
158677
|
-
return [createCodeFixAction(
|
|
158759
|
+
return [createCodeFixAction(fixId27, changes, Diagnostics.Make_super_call_the_first_statement_in_the_constructor, fixId27, Diagnostics.Make_all_super_calls_the_first_statement_in_their_constructor)];
|
|
158678
158760
|
},
|
|
158679
|
-
fixIds: [
|
|
158761
|
+
fixIds: [fixId27],
|
|
158680
158762
|
getAllCodeActions(context) {
|
|
158681
158763
|
const { sourceFile } = context;
|
|
158682
158764
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
158683
|
-
return codeFixAll(context,
|
|
158765
|
+
return codeFixAll(context, errorCodes33, (changes, diag2) => {
|
|
158684
158766
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
158685
158767
|
if (!nodes) return;
|
|
158686
158768
|
const { constructor, superCall } = nodes;
|
|
@@ -158706,18 +158788,18 @@ function findSuperCall(n) {
|
|
|
158706
158788
|
}
|
|
158707
158789
|
|
|
158708
158790
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
158709
|
-
var
|
|
158710
|
-
var
|
|
158791
|
+
var fixId28 = "constructorForDerivedNeedSuperCall";
|
|
158792
|
+
var errorCodes34 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
158711
158793
|
registerCodeFix({
|
|
158712
|
-
errorCodes:
|
|
158794
|
+
errorCodes: errorCodes34,
|
|
158713
158795
|
getCodeActions(context) {
|
|
158714
158796
|
const { sourceFile, span } = context;
|
|
158715
158797
|
const ctr = getNode(sourceFile, span.start);
|
|
158716
158798
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, ctr));
|
|
158717
|
-
return [createCodeFixAction(
|
|
158799
|
+
return [createCodeFixAction(fixId28, changes, Diagnostics.Add_missing_super_call, fixId28, Diagnostics.Add_all_missing_super_calls)];
|
|
158718
158800
|
},
|
|
158719
|
-
fixIds: [
|
|
158720
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158801
|
+
fixIds: [fixId28],
|
|
158802
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes34, (changes, diag2) => doChange21(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
158721
158803
|
});
|
|
158722
158804
|
function getNode(sourceFile, pos) {
|
|
158723
158805
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -158737,9 +158819,9 @@ function doChange21(changes, sourceFile, ctr) {
|
|
|
158737
158819
|
|
|
158738
158820
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
158739
158821
|
var fixID = "fixEnableJsxFlag";
|
|
158740
|
-
var
|
|
158822
|
+
var errorCodes35 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
158741
158823
|
registerCodeFix({
|
|
158742
|
-
errorCodes:
|
|
158824
|
+
errorCodes: errorCodes35,
|
|
158743
158825
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
158744
158826
|
const { configFile } = context.program.getCompilerOptions();
|
|
158745
158827
|
if (configFile === void 0) {
|
|
@@ -158751,7 +158833,7 @@ registerCodeFix({
|
|
|
158751
158833
|
];
|
|
158752
158834
|
},
|
|
158753
158835
|
fixIds: [fixID],
|
|
158754
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158836
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes) => {
|
|
158755
158837
|
const { configFile } = context.program.getCompilerOptions();
|
|
158756
158838
|
if (configFile === void 0) {
|
|
158757
158839
|
return void 0;
|
|
@@ -158764,23 +158846,23 @@ function doChange22(changeTracker, configFile) {
|
|
|
158764
158846
|
}
|
|
158765
158847
|
|
|
158766
158848
|
// src/services/codefixes/fixNaNEquality.ts
|
|
158767
|
-
var
|
|
158768
|
-
var
|
|
158849
|
+
var fixId29 = "fixNaNEquality";
|
|
158850
|
+
var errorCodes36 = [
|
|
158769
158851
|
Diagnostics.This_condition_will_always_return_0.code
|
|
158770
158852
|
];
|
|
158771
158853
|
registerCodeFix({
|
|
158772
|
-
errorCodes:
|
|
158854
|
+
errorCodes: errorCodes36,
|
|
158773
158855
|
getCodeActions(context) {
|
|
158774
158856
|
const { sourceFile, span, program } = context;
|
|
158775
158857
|
const info = getInfo12(program, sourceFile, span);
|
|
158776
158858
|
if (info === void 0) return;
|
|
158777
158859
|
const { suggestion, expression, arg } = info;
|
|
158778
158860
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, arg, expression));
|
|
158779
|
-
return [createCodeFixAction(
|
|
158861
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Use_0, suggestion], fixId29, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
158780
158862
|
},
|
|
158781
|
-
fixIds: [
|
|
158863
|
+
fixIds: [fixId29],
|
|
158782
158864
|
getAllCodeActions: (context) => {
|
|
158783
|
-
return codeFixAll(context,
|
|
158865
|
+
return codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
158784
158866
|
const info = getInfo12(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
158785
158867
|
if (info) {
|
|
158786
158868
|
doChange23(changes, diag2.file, info.arg, info.expression);
|
|
@@ -158860,20 +158942,20 @@ registerCodeFix({
|
|
|
158860
158942
|
});
|
|
158861
158943
|
|
|
158862
158944
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
158863
|
-
var
|
|
158864
|
-
var
|
|
158945
|
+
var fixId30 = "fixPropertyAssignment";
|
|
158946
|
+
var errorCodes37 = [
|
|
158865
158947
|
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
|
|
158866
158948
|
];
|
|
158867
158949
|
registerCodeFix({
|
|
158868
|
-
errorCodes:
|
|
158869
|
-
fixIds: [
|
|
158950
|
+
errorCodes: errorCodes37,
|
|
158951
|
+
fixIds: [fixId30],
|
|
158870
158952
|
getCodeActions(context) {
|
|
158871
158953
|
const { sourceFile, span } = context;
|
|
158872
158954
|
const property = getProperty2(sourceFile, span.start);
|
|
158873
158955
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange24(t, context.sourceFile, property));
|
|
158874
|
-
return [createCodeFixAction(
|
|
158956
|
+
return [createCodeFixAction(fixId30, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId30, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
158875
158957
|
},
|
|
158876
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158958
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => doChange24(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
158877
158959
|
});
|
|
158878
158960
|
function doChange24(changes, sourceFile, node) {
|
|
158879
158961
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
@@ -158883,20 +158965,20 @@ function getProperty2(sourceFile, pos) {
|
|
|
158883
158965
|
}
|
|
158884
158966
|
|
|
158885
158967
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
158886
|
-
var
|
|
158887
|
-
var
|
|
158968
|
+
var fixId31 = "extendsInterfaceBecomesImplements";
|
|
158969
|
+
var errorCodes38 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
158888
158970
|
registerCodeFix({
|
|
158889
|
-
errorCodes:
|
|
158971
|
+
errorCodes: errorCodes38,
|
|
158890
158972
|
getCodeActions(context) {
|
|
158891
158973
|
const { sourceFile } = context;
|
|
158892
158974
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
158893
158975
|
if (!nodes) return void 0;
|
|
158894
158976
|
const { extendsToken, heritageClauses } = nodes;
|
|
158895
158977
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
158896
|
-
return [createCodeFixAction(
|
|
158978
|
+
return [createCodeFixAction(fixId31, changes, Diagnostics.Change_extends_to_implements, fixId31, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
158897
158979
|
},
|
|
158898
|
-
fixIds: [
|
|
158899
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158980
|
+
fixIds: [fixId31],
|
|
158981
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes38, (changes, diag2) => {
|
|
158900
158982
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
158901
158983
|
if (nodes) doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
158902
158984
|
})
|
|
@@ -158923,15 +159005,15 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
158923
159005
|
}
|
|
158924
159006
|
|
|
158925
159007
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
158926
|
-
var
|
|
159008
|
+
var fixId32 = "forgottenThisPropertyAccess";
|
|
158927
159009
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
158928
|
-
var
|
|
159010
|
+
var errorCodes39 = [
|
|
158929
159011
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
158930
159012
|
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,
|
|
158931
159013
|
didYouMeanStaticMemberCode
|
|
158932
159014
|
];
|
|
158933
159015
|
registerCodeFix({
|
|
158934
|
-
errorCodes:
|
|
159016
|
+
errorCodes: errorCodes39,
|
|
158935
159017
|
getCodeActions(context) {
|
|
158936
159018
|
const { sourceFile } = context;
|
|
158937
159019
|
const info = getInfo13(sourceFile, context.span.start, context.errorCode);
|
|
@@ -158939,10 +159021,10 @@ registerCodeFix({
|
|
|
158939
159021
|
return void 0;
|
|
158940
159022
|
}
|
|
158941
159023
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange25(t, sourceFile, info));
|
|
158942
|
-
return [createCodeFixAction(
|
|
159024
|
+
return [createCodeFixAction(fixId32, changes, [Diagnostics.Add_0_to_unresolved_variable, info.className || "this"], fixId32, Diagnostics.Add_qualifier_to_all_unresolved_variables_matching_a_member_name)];
|
|
158943
159025
|
},
|
|
158944
|
-
fixIds: [
|
|
158945
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159026
|
+
fixIds: [fixId32],
|
|
159027
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes39, (changes, diag2) => {
|
|
158946
159028
|
const info = getInfo13(diag2.file, diag2.start, diag2.code);
|
|
158947
159029
|
if (info) doChange25(changes, context.sourceFile, info);
|
|
158948
159030
|
})
|
|
@@ -158961,12 +159043,12 @@ function doChange25(changes, sourceFile, { node, className }) {
|
|
|
158961
159043
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
158962
159044
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
158963
159045
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
158964
|
-
var
|
|
159046
|
+
var errorCodes40 = [
|
|
158965
159047
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
158966
159048
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
158967
159049
|
];
|
|
158968
159050
|
registerCodeFix({
|
|
158969
|
-
errorCodes:
|
|
159051
|
+
errorCodes: errorCodes40,
|
|
158970
159052
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
158971
159053
|
getCodeActions(context) {
|
|
158972
159054
|
const { sourceFile, preferences, span } = context;
|
|
@@ -158992,7 +159074,7 @@ registerCodeFix({
|
|
|
158992
159074
|
];
|
|
158993
159075
|
},
|
|
158994
159076
|
getAllCodeActions(context) {
|
|
158995
|
-
return codeFixAll(context,
|
|
159077
|
+
return codeFixAll(context, errorCodes40, (changes, diagnostic) => doChange26(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
158996
159078
|
}
|
|
158997
159079
|
});
|
|
158998
159080
|
var htmlEntity = {
|
|
@@ -159014,12 +159096,12 @@ function doChange26(changes, preferences, sourceFile, start, useHtmlEntity) {
|
|
|
159014
159096
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
159015
159097
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
159016
159098
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
159017
|
-
var
|
|
159099
|
+
var errorCodes41 = [
|
|
159018
159100
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
159019
159101
|
];
|
|
159020
159102
|
registerCodeFix({
|
|
159021
159103
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
159022
|
-
errorCodes:
|
|
159104
|
+
errorCodes: errorCodes41,
|
|
159023
159105
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
159024
159106
|
const { sourceFile, span } = context;
|
|
159025
159107
|
const actions2 = [];
|
|
@@ -159034,7 +159116,7 @@ registerCodeFix({
|
|
|
159034
159116
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
159035
159117
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
159036
159118
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
159037
|
-
eachDiagnostic(context,
|
|
159119
|
+
eachDiagnostic(context, errorCodes41, ({ file, start }) => {
|
|
159038
159120
|
const info = getInfo14(file, start);
|
|
159039
159121
|
if (info) {
|
|
159040
159122
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -159097,10 +159179,10 @@ function getInfo14(sourceFile, pos) {
|
|
|
159097
159179
|
}
|
|
159098
159180
|
|
|
159099
159181
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
159100
|
-
var
|
|
159101
|
-
var
|
|
159182
|
+
var fixId33 = "fixUnreferenceableDecoratorMetadata";
|
|
159183
|
+
var errorCodes42 = [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];
|
|
159102
159184
|
registerCodeFix({
|
|
159103
|
-
errorCodes:
|
|
159185
|
+
errorCodes: errorCodes42,
|
|
159104
159186
|
getCodeActions: (context) => {
|
|
159105
159187
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
159106
159188
|
if (!importDeclaration) return;
|
|
@@ -159108,14 +159190,14 @@ registerCodeFix({
|
|
|
159108
159190
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
159109
159191
|
let actions2;
|
|
159110
159192
|
if (namespaceChanges.length) {
|
|
159111
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
159193
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId33, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
159112
159194
|
}
|
|
159113
159195
|
if (typeOnlyChanges.length) {
|
|
159114
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
159196
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId33, typeOnlyChanges, Diagnostics.Use_import_type));
|
|
159115
159197
|
}
|
|
159116
159198
|
return actions2;
|
|
159117
159199
|
},
|
|
159118
|
-
fixIds: [
|
|
159200
|
+
fixIds: [fixId33]
|
|
159119
159201
|
});
|
|
159120
159202
|
function getImportDeclaration(sourceFile, program, start) {
|
|
159121
159203
|
const identifier = tryCast(getTokenAtPosition(sourceFile, start), isIdentifier);
|
|
@@ -159152,7 +159234,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
159152
159234
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
159153
159235
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
159154
159236
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
159155
|
-
var
|
|
159237
|
+
var errorCodes43 = [
|
|
159156
159238
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
159157
159239
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
159158
159240
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -159162,7 +159244,7 @@ var errorCodes42 = [
|
|
|
159162
159244
|
Diagnostics.All_type_parameters_are_unused.code
|
|
159163
159245
|
];
|
|
159164
159246
|
registerCodeFix({
|
|
159165
|
-
errorCodes:
|
|
159247
|
+
errorCodes: errorCodes43,
|
|
159166
159248
|
getCodeActions(context) {
|
|
159167
159249
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
159168
159250
|
const checker = program.getTypeChecker();
|
|
@@ -159251,7 +159333,7 @@ registerCodeFix({
|
|
|
159251
159333
|
const { sourceFile, program, cancellationToken } = context;
|
|
159252
159334
|
const checker = program.getTypeChecker();
|
|
159253
159335
|
const sourceFiles = program.getSourceFiles();
|
|
159254
|
-
return codeFixAll(context,
|
|
159336
|
+
return codeFixAll(context, errorCodes43, (changes, diag2) => {
|
|
159255
159337
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
159256
159338
|
switch (context.fixId) {
|
|
159257
159339
|
case fixIdPrefix:
|
|
@@ -159491,18 +159573,18 @@ function deleteFunctionLikeDeclaration(changes, sourceFile, node) {
|
|
|
159491
159573
|
}
|
|
159492
159574
|
|
|
159493
159575
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
159494
|
-
var
|
|
159495
|
-
var
|
|
159576
|
+
var fixId34 = "fixUnreachableCode";
|
|
159577
|
+
var errorCodes44 = [Diagnostics.Unreachable_code_detected.code];
|
|
159496
159578
|
registerCodeFix({
|
|
159497
|
-
errorCodes:
|
|
159579
|
+
errorCodes: errorCodes44,
|
|
159498
159580
|
getCodeActions(context) {
|
|
159499
159581
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
159500
159582
|
if (syntacticDiagnostics.length) return;
|
|
159501
159583
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
159502
|
-
return [createCodeFixAction(
|
|
159584
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unreachable_code, fixId34, Diagnostics.Remove_all_unreachable_code)];
|
|
159503
159585
|
},
|
|
159504
|
-
fixIds: [
|
|
159505
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159586
|
+
fixIds: [fixId34],
|
|
159587
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes44, (changes, diag2) => doChange27(changes, diag2.file, diag2.start, diag2.length, diag2.code))
|
|
159506
159588
|
});
|
|
159507
159589
|
function doChange27(changes, sourceFile, start, length2, errorCode) {
|
|
159508
159590
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -159553,16 +159635,16 @@ function lastWhere(a, pred) {
|
|
|
159553
159635
|
}
|
|
159554
159636
|
|
|
159555
159637
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
159556
|
-
var
|
|
159557
|
-
var
|
|
159638
|
+
var fixId35 = "fixUnusedLabel";
|
|
159639
|
+
var errorCodes45 = [Diagnostics.Unused_label.code];
|
|
159558
159640
|
registerCodeFix({
|
|
159559
|
-
errorCodes:
|
|
159641
|
+
errorCodes: errorCodes45,
|
|
159560
159642
|
getCodeActions(context) {
|
|
159561
159643
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, context.sourceFile, context.span.start));
|
|
159562
|
-
return [createCodeFixAction(
|
|
159644
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Remove_unused_label, fixId35, Diagnostics.Remove_all_unused_labels)];
|
|
159563
159645
|
},
|
|
159564
|
-
fixIds: [
|
|
159565
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159646
|
+
fixIds: [fixId35],
|
|
159647
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => doChange28(changes, diag2.file, diag2.start))
|
|
159566
159648
|
});
|
|
159567
159649
|
function doChange28(changes, sourceFile, start) {
|
|
159568
159650
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -159581,13 +159663,13 @@ function doChange28(changes, sourceFile, start) {
|
|
|
159581
159663
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
159582
159664
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
159583
159665
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
159584
|
-
var
|
|
159666
|
+
var errorCodes46 = [
|
|
159585
159667
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
159586
159668
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
159587
159669
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
159588
159670
|
];
|
|
159589
159671
|
registerCodeFix({
|
|
159590
|
-
errorCodes:
|
|
159672
|
+
errorCodes: errorCodes46,
|
|
159591
159673
|
getCodeActions(context) {
|
|
159592
159674
|
const { sourceFile } = context;
|
|
159593
159675
|
const checker = context.program.getTypeChecker();
|
|
@@ -159600,20 +159682,20 @@ registerCodeFix({
|
|
|
159600
159682
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
159601
159683
|
}
|
|
159602
159684
|
return actions2;
|
|
159603
|
-
function fix(type2,
|
|
159685
|
+
function fix(type2, fixId56, fixAllDescription) {
|
|
159604
159686
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
159605
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
159687
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId56, fixAllDescription);
|
|
159606
159688
|
}
|
|
159607
159689
|
},
|
|
159608
159690
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
159609
159691
|
getAllCodeActions(context) {
|
|
159610
|
-
const { fixId:
|
|
159692
|
+
const { fixId: fixId56, program, sourceFile } = context;
|
|
159611
159693
|
const checker = program.getTypeChecker();
|
|
159612
|
-
return codeFixAll(context,
|
|
159694
|
+
return codeFixAll(context, errorCodes46, (changes, err) => {
|
|
159613
159695
|
const info = getInfo15(err.file, err.start, checker);
|
|
159614
159696
|
if (!info) return;
|
|
159615
159697
|
const { typeNode, type } = info;
|
|
159616
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ &&
|
|
159698
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
159617
159699
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
159618
159700
|
});
|
|
159619
159701
|
}
|
|
@@ -159669,21 +159751,21 @@ function getType(checker, node) {
|
|
|
159669
159751
|
}
|
|
159670
159752
|
|
|
159671
159753
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
159672
|
-
var
|
|
159673
|
-
var
|
|
159754
|
+
var fixId36 = "fixMissingCallParentheses";
|
|
159755
|
+
var errorCodes47 = [
|
|
159674
159756
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
159675
159757
|
];
|
|
159676
159758
|
registerCodeFix({
|
|
159677
|
-
errorCodes:
|
|
159678
|
-
fixIds: [
|
|
159759
|
+
errorCodes: errorCodes47,
|
|
159760
|
+
fixIds: [fixId36],
|
|
159679
159761
|
getCodeActions(context) {
|
|
159680
159762
|
const { sourceFile, span } = context;
|
|
159681
159763
|
const callName = getCallName(sourceFile, span.start);
|
|
159682
159764
|
if (!callName) return;
|
|
159683
159765
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, context.sourceFile, callName));
|
|
159684
|
-
return [createCodeFixAction(
|
|
159766
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_missing_call_parentheses, fixId36, Diagnostics.Add_all_missing_call_parentheses)];
|
|
159685
159767
|
},
|
|
159686
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159768
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
159687
159769
|
const callName = getCallName(diag2.file, diag2.start);
|
|
159688
159770
|
if (callName) doChange30(changes, diag2.file, callName);
|
|
159689
159771
|
})
|
|
@@ -159707,11 +159789,11 @@ function getCallName(sourceFile, start) {
|
|
|
159707
159789
|
}
|
|
159708
159790
|
|
|
159709
159791
|
// src/services/codefixes/fixMissingTypeAnnotationOnExports.ts
|
|
159710
|
-
var
|
|
159792
|
+
var fixId37 = "fixMissingTypeAnnotationOnExports";
|
|
159711
159793
|
var addAnnotationFix = "add-annotation";
|
|
159712
159794
|
var addInlineTypeAssertion = "add-type-assertion";
|
|
159713
159795
|
var extractExpression = "extract-expression";
|
|
159714
|
-
var
|
|
159796
|
+
var errorCodes48 = [
|
|
159715
159797
|
Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
159716
159798
|
Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
159717
159799
|
Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
@@ -159751,8 +159833,8 @@ var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
|
|
|
159751
159833
|
var declarationEmitNodeBuilderFlags2 = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */;
|
|
159752
159834
|
var declarationEmitInternalNodeBuilderFlags2 = 1 /* WriteComputedProps */;
|
|
159753
159835
|
registerCodeFix({
|
|
159754
|
-
errorCodes:
|
|
159755
|
-
fixIds: [
|
|
159836
|
+
errorCodes: errorCodes48,
|
|
159837
|
+
fixIds: [fixId37],
|
|
159756
159838
|
getCodeActions(context) {
|
|
159757
159839
|
const fixes = [];
|
|
159758
159840
|
addCodeAction(addAnnotationFix, fixes, context, 0 /* Full */, (f) => f.addTypeAnnotation(context.span));
|
|
@@ -159766,7 +159848,7 @@ registerCodeFix({
|
|
|
159766
159848
|
},
|
|
159767
159849
|
getAllCodeActions: (context) => {
|
|
159768
159850
|
const changes = withContext(context, 0 /* Full */, (f) => {
|
|
159769
|
-
eachDiagnostic(context,
|
|
159851
|
+
eachDiagnostic(context, errorCodes48, (diag2) => {
|
|
159770
159852
|
f.addTypeAnnotation(diag2);
|
|
159771
159853
|
});
|
|
159772
159854
|
});
|
|
@@ -159780,7 +159862,7 @@ function addCodeAction(fixName8, fixes, context, typePrintMode, cb) {
|
|
|
159780
159862
|
fixName8,
|
|
159781
159863
|
changes.textChanges,
|
|
159782
159864
|
changes.result,
|
|
159783
|
-
|
|
159865
|
+
fixId37,
|
|
159784
159866
|
Diagnostics.Add_all_missing_type_annotations
|
|
159785
159867
|
));
|
|
159786
159868
|
}
|
|
@@ -160600,26 +160682,26 @@ function withContext(context, typePrintMode, cb) {
|
|
|
160600
160682
|
}
|
|
160601
160683
|
|
|
160602
160684
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
160603
|
-
var
|
|
160604
|
-
var
|
|
160685
|
+
var fixId38 = "fixAwaitInSyncFunction";
|
|
160686
|
+
var errorCodes49 = [
|
|
160605
160687
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160606
160688
|
Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160607
160689
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160608
160690
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
160609
160691
|
];
|
|
160610
160692
|
registerCodeFix({
|
|
160611
|
-
errorCodes:
|
|
160693
|
+
errorCodes: errorCodes49,
|
|
160612
160694
|
getCodeActions(context) {
|
|
160613
160695
|
const { sourceFile, span } = context;
|
|
160614
160696
|
const nodes = getNodes3(sourceFile, span.start);
|
|
160615
160697
|
if (!nodes) return void 0;
|
|
160616
160698
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
|
|
160617
|
-
return [createCodeFixAction(
|
|
160699
|
+
return [createCodeFixAction(fixId38, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId38, Diagnostics.Add_all_missing_async_modifiers)];
|
|
160618
160700
|
},
|
|
160619
|
-
fixIds: [
|
|
160701
|
+
fixIds: [fixId38],
|
|
160620
160702
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
160621
160703
|
const seen = /* @__PURE__ */ new Map();
|
|
160622
|
-
return codeFixAll(context,
|
|
160704
|
+
return codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
160623
160705
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
160624
160706
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
|
160625
160707
|
doChange31(changes, context.sourceFile, nodes);
|
|
@@ -160672,21 +160754,21 @@ function doChange31(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
160672
160754
|
}
|
|
160673
160755
|
|
|
160674
160756
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
160675
|
-
var
|
|
160757
|
+
var errorCodes50 = [
|
|
160676
160758
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
160677
160759
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
160678
160760
|
];
|
|
160679
|
-
var
|
|
160761
|
+
var fixId39 = "fixPropertyOverrideAccessor";
|
|
160680
160762
|
registerCodeFix({
|
|
160681
|
-
errorCodes:
|
|
160763
|
+
errorCodes: errorCodes50,
|
|
160682
160764
|
getCodeActions(context) {
|
|
160683
160765
|
const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
160684
160766
|
if (edits) {
|
|
160685
|
-
return [createCodeFixAction(
|
|
160767
|
+
return [createCodeFixAction(fixId39, edits, Diagnostics.Generate_get_and_set_accessors, fixId39, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
160686
160768
|
}
|
|
160687
160769
|
},
|
|
160688
|
-
fixIds: [
|
|
160689
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
160770
|
+
fixIds: [fixId39],
|
|
160771
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
160690
160772
|
const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
160691
160773
|
if (edits) {
|
|
160692
160774
|
for (const edit of edits) {
|
|
@@ -160722,8 +160804,8 @@ function doChange32(file, start, length2, code, context) {
|
|
|
160722
160804
|
}
|
|
160723
160805
|
|
|
160724
160806
|
// src/services/codefixes/inferFromUsage.ts
|
|
160725
|
-
var
|
|
160726
|
-
var
|
|
160807
|
+
var fixId40 = "inferFromUsage";
|
|
160808
|
+
var errorCodes51 = [
|
|
160727
160809
|
// Variable declarations
|
|
160728
160810
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
160729
160811
|
// Variable uses
|
|
@@ -160757,7 +160839,7 @@ var errorCodes50 = [
|
|
|
160757
160839
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
160758
160840
|
];
|
|
160759
160841
|
registerCodeFix({
|
|
160760
|
-
errorCodes:
|
|
160842
|
+
errorCodes: errorCodes51,
|
|
160761
160843
|
getCodeActions(context) {
|
|
160762
160844
|
const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
|
|
160763
160845
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -160777,13 +160859,13 @@ registerCodeFix({
|
|
|
160777
160859
|
);
|
|
160778
160860
|
});
|
|
160779
160861
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
160780
|
-
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(
|
|
160862
|
+
return !name || changes.length === 0 ? void 0 : [createCodeFixAction(fixId40, changes, [getDiagnostic(errorCode, token), getTextOfNode(name)], fixId40, Diagnostics.Infer_all_types_from_usage)];
|
|
160781
160863
|
},
|
|
160782
|
-
fixIds: [
|
|
160864
|
+
fixIds: [fixId40],
|
|
160783
160865
|
getAllCodeActions(context) {
|
|
160784
160866
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
160785
160867
|
const markSeen = nodeSeenTracker();
|
|
160786
|
-
return codeFixAll(context,
|
|
160868
|
+
return codeFixAll(context, errorCodes51, (changes, err) => {
|
|
160787
160869
|
doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
160788
160870
|
});
|
|
160789
160871
|
}
|
|
@@ -161714,13 +161796,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
161714
161796
|
}
|
|
161715
161797
|
|
|
161716
161798
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
161717
|
-
var
|
|
161718
|
-
var
|
|
161799
|
+
var fixId41 = "fixReturnTypeInAsyncFunction";
|
|
161800
|
+
var errorCodes52 = [
|
|
161719
161801
|
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
|
|
161720
161802
|
];
|
|
161721
161803
|
registerCodeFix({
|
|
161722
|
-
errorCodes:
|
|
161723
|
-
fixIds: [
|
|
161804
|
+
errorCodes: errorCodes52,
|
|
161805
|
+
fixIds: [fixId41],
|
|
161724
161806
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
161725
161807
|
const { sourceFile, program, span } = context;
|
|
161726
161808
|
const checker = program.getTypeChecker();
|
|
@@ -161731,14 +161813,14 @@ registerCodeFix({
|
|
|
161731
161813
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
161732
161814
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
161733
161815
|
return [createCodeFixAction(
|
|
161734
|
-
|
|
161816
|
+
fixId41,
|
|
161735
161817
|
changes,
|
|
161736
161818
|
[Diagnostics.Replace_0_with_Promise_1, checker.typeToString(returnType), checker.typeToString(promisedType)],
|
|
161737
|
-
|
|
161819
|
+
fixId41,
|
|
161738
161820
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
161739
161821
|
)];
|
|
161740
161822
|
},
|
|
161741
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
161823
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
161742
161824
|
const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
161743
161825
|
if (info) {
|
|
161744
161826
|
doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
@@ -161774,13 +161856,13 @@ function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
|
161774
161856
|
|
|
161775
161857
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
161776
161858
|
var fixName4 = "disableJsDiagnostics";
|
|
161777
|
-
var
|
|
161778
|
-
var
|
|
161859
|
+
var fixId42 = "disableJsDiagnostics";
|
|
161860
|
+
var errorCodes53 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
161779
161861
|
const diag2 = Diagnostics[key];
|
|
161780
161862
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
161781
161863
|
});
|
|
161782
161864
|
registerCodeFix({
|
|
161783
|
-
errorCodes:
|
|
161865
|
+
errorCodes: errorCodes53,
|
|
161784
161866
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
161785
161867
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
161786
161868
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -161801,21 +161883,21 @@ registerCodeFix({
|
|
|
161801
161883
|
)
|
|
161802
161884
|
];
|
|
161803
161885
|
if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
|
|
161804
|
-
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
161886
|
+
fixes.unshift(createCodeFixAction(fixName4, ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange9(t, sourceFile, span.start)), Diagnostics.Ignore_this_error_message, fixId42, Diagnostics.Add_ts_ignore_to_all_error_messages));
|
|
161805
161887
|
}
|
|
161806
161888
|
return fixes;
|
|
161807
161889
|
},
|
|
161808
|
-
fixIds: [
|
|
161890
|
+
fixIds: [fixId42],
|
|
161809
161891
|
getAllCodeActions: (context) => {
|
|
161810
161892
|
const seenLines = /* @__PURE__ */ new Set();
|
|
161811
|
-
return codeFixAll(context,
|
|
161893
|
+
return codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
161812
161894
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
161813
|
-
|
|
161895
|
+
makeChange9(changes, diag2.file, diag2.start, seenLines);
|
|
161814
161896
|
}
|
|
161815
161897
|
});
|
|
161816
161898
|
}
|
|
161817
161899
|
});
|
|
161818
|
-
function
|
|
161900
|
+
function makeChange9(changes, sourceFile, position, seenLines) {
|
|
161819
161901
|
const { line: lineNumber } = getLineAndCharacterOfPosition(sourceFile, position);
|
|
161820
161902
|
if (!seenLines || tryAddToSet(seenLines, lineNumber)) {
|
|
161821
161903
|
changes.insertCommentBeforeLine(sourceFile, lineNumber, position, " @ts-ignore");
|
|
@@ -162828,9 +162910,9 @@ var fixName6 = "strictClassInitialization";
|
|
|
162828
162910
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
162829
162911
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
162830
162912
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
162831
|
-
var
|
|
162913
|
+
var errorCodes54 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
162832
162914
|
registerCodeFix({
|
|
162833
|
-
errorCodes:
|
|
162915
|
+
errorCodes: errorCodes54,
|
|
162834
162916
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
162835
162917
|
const info = getInfo17(context.sourceFile, context.span.start);
|
|
162836
162918
|
if (!info) return;
|
|
@@ -162842,7 +162924,7 @@ registerCodeFix({
|
|
|
162842
162924
|
},
|
|
162843
162925
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
162844
162926
|
getAllCodeActions: (context) => {
|
|
162845
|
-
return codeFixAll(context,
|
|
162927
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => {
|
|
162846
162928
|
const info = getInfo17(diag2.file, diag2.start);
|
|
162847
162929
|
if (!info) return;
|
|
162848
162930
|
switch (context.fixId) {
|
|
@@ -162965,20 +163047,20 @@ function getDefaultValueFromType(checker, type) {
|
|
|
162965
163047
|
}
|
|
162966
163048
|
|
|
162967
163049
|
// src/services/codefixes/requireInTs.ts
|
|
162968
|
-
var
|
|
162969
|
-
var
|
|
163050
|
+
var fixId43 = "requireInTs";
|
|
163051
|
+
var errorCodes55 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
162970
163052
|
registerCodeFix({
|
|
162971
|
-
errorCodes:
|
|
163053
|
+
errorCodes: errorCodes55,
|
|
162972
163054
|
getCodeActions(context) {
|
|
162973
163055
|
const info = getInfo18(context.sourceFile, context.program, context.span.start, context.preferences);
|
|
162974
163056
|
if (!info) {
|
|
162975
163057
|
return void 0;
|
|
162976
163058
|
}
|
|
162977
163059
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
|
|
162978
|
-
return [createCodeFixAction(
|
|
163060
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_require_to_import, fixId43, Diagnostics.Convert_all_require_to_import)];
|
|
162979
163061
|
},
|
|
162980
|
-
fixIds: [
|
|
162981
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163062
|
+
fixIds: [fixId43],
|
|
163063
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => {
|
|
162982
163064
|
const info = getInfo18(diag2.file, context.program, diag2.start, context.preferences);
|
|
162983
163065
|
if (info) {
|
|
162984
163066
|
doChange35(changes, context.sourceFile, info);
|
|
@@ -163055,19 +163137,19 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
163055
163137
|
}
|
|
163056
163138
|
|
|
163057
163139
|
// src/services/codefixes/useDefaultImport.ts
|
|
163058
|
-
var
|
|
163059
|
-
var
|
|
163140
|
+
var fixId44 = "useDefaultImport";
|
|
163141
|
+
var errorCodes56 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
163060
163142
|
registerCodeFix({
|
|
163061
|
-
errorCodes:
|
|
163143
|
+
errorCodes: errorCodes56,
|
|
163062
163144
|
getCodeActions(context) {
|
|
163063
163145
|
const { sourceFile, span: { start } } = context;
|
|
163064
163146
|
const info = getInfo19(sourceFile, start);
|
|
163065
163147
|
if (!info) return void 0;
|
|
163066
163148
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(t, sourceFile, info, context.preferences));
|
|
163067
|
-
return [createCodeFixAction(
|
|
163149
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Convert_to_default_import, fixId44, Diagnostics.Convert_all_to_default_imports)];
|
|
163068
163150
|
},
|
|
163069
|
-
fixIds: [
|
|
163070
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163151
|
+
fixIds: [fixId44],
|
|
163152
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
163071
163153
|
const info = getInfo19(diag2.file, diag2.start);
|
|
163072
163154
|
if (info) doChange36(changes, diag2.file, info, context.preferences);
|
|
163073
163155
|
})
|
|
@@ -163094,24 +163176,24 @@ function doChange36(changes, sourceFile, info, preferences) {
|
|
|
163094
163176
|
}
|
|
163095
163177
|
|
|
163096
163178
|
// src/services/codefixes/useBigintLiteral.ts
|
|
163097
|
-
var
|
|
163098
|
-
var
|
|
163179
|
+
var fixId45 = "useBigintLiteral";
|
|
163180
|
+
var errorCodes57 = [
|
|
163099
163181
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
163100
163182
|
];
|
|
163101
163183
|
registerCodeFix({
|
|
163102
|
-
errorCodes:
|
|
163184
|
+
errorCodes: errorCodes57,
|
|
163103
163185
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
163104
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
163186
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span));
|
|
163105
163187
|
if (changes.length > 0) {
|
|
163106
|
-
return [createCodeFixAction(
|
|
163188
|
+
return [createCodeFixAction(fixId45, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId45, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
163107
163189
|
}
|
|
163108
163190
|
},
|
|
163109
|
-
fixIds: [
|
|
163191
|
+
fixIds: [fixId45],
|
|
163110
163192
|
getAllCodeActions: (context) => {
|
|
163111
|
-
return codeFixAll(context,
|
|
163193
|
+
return codeFixAll(context, errorCodes57, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
163112
163194
|
}
|
|
163113
163195
|
});
|
|
163114
|
-
function
|
|
163196
|
+
function makeChange10(changeTracker, sourceFile, span) {
|
|
163115
163197
|
const numericLiteral = tryCast(getTokenAtPosition(sourceFile, span.start), isNumericLiteral);
|
|
163116
163198
|
if (!numericLiteral) {
|
|
163117
163199
|
return;
|
|
@@ -163122,18 +163204,18 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
163122
163204
|
|
|
163123
163205
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
163124
163206
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
163125
|
-
var
|
|
163126
|
-
var
|
|
163207
|
+
var fixId46 = fixIdAddMissingTypeof;
|
|
163208
|
+
var errorCodes58 = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
|
|
163127
163209
|
registerCodeFix({
|
|
163128
|
-
errorCodes:
|
|
163210
|
+
errorCodes: errorCodes58,
|
|
163129
163211
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
163130
163212
|
const { sourceFile, span } = context;
|
|
163131
163213
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
163132
163214
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
|
|
163133
|
-
return [createCodeFixAction(
|
|
163215
|
+
return [createCodeFixAction(fixId46, changes, Diagnostics.Add_missing_typeof, fixId46, Diagnostics.Add_missing_typeof)];
|
|
163134
163216
|
},
|
|
163135
|
-
fixIds: [
|
|
163136
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163217
|
+
fixIds: [fixId46],
|
|
163218
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
163137
163219
|
});
|
|
163138
163220
|
function getImportTypeNode(sourceFile, pos) {
|
|
163139
163221
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -163156,9 +163238,9 @@ function doChange37(changes, sourceFile, importType) {
|
|
|
163156
163238
|
|
|
163157
163239
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
163158
163240
|
var fixID2 = "wrapJsxInFragment";
|
|
163159
|
-
var
|
|
163241
|
+
var errorCodes59 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
163160
163242
|
registerCodeFix({
|
|
163161
|
-
errorCodes:
|
|
163243
|
+
errorCodes: errorCodes59,
|
|
163162
163244
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
163163
163245
|
const { sourceFile, span } = context;
|
|
163164
163246
|
const node = findNodeToFix(sourceFile, span.start);
|
|
@@ -163167,7 +163249,7 @@ registerCodeFix({
|
|
|
163167
163249
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
163168
163250
|
},
|
|
163169
163251
|
fixIds: [fixID2],
|
|
163170
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163252
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
|
|
163171
163253
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
163172
163254
|
if (!node) return void 0;
|
|
163173
163255
|
doChange38(changes, context.sourceFile, node);
|
|
@@ -163206,18 +163288,18 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
163206
163288
|
}
|
|
163207
163289
|
|
|
163208
163290
|
// src/services/codefixes/wrapDecoratorInParentheses.ts
|
|
163209
|
-
var
|
|
163210
|
-
var
|
|
163291
|
+
var fixId47 = "wrapDecoratorInParentheses";
|
|
163292
|
+
var errorCodes60 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
|
|
163211
163293
|
registerCodeFix({
|
|
163212
|
-
errorCodes:
|
|
163294
|
+
errorCodes: errorCodes60,
|
|
163213
163295
|
getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
|
|
163214
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
163215
|
-
return [createCodeFixAction(
|
|
163296
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span.start));
|
|
163297
|
+
return [createCodeFixAction(fixId47, changes, Diagnostics.Wrap_in_parentheses, fixId47, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
|
|
163216
163298
|
},
|
|
163217
|
-
fixIds: [
|
|
163218
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163299
|
+
fixIds: [fixId47],
|
|
163300
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, diag2) => makeChange11(changes, diag2.file, diag2.start))
|
|
163219
163301
|
});
|
|
163220
|
-
function
|
|
163302
|
+
function makeChange11(changeTracker, sourceFile, pos) {
|
|
163221
163303
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
163222
163304
|
const decorator = findAncestor(token, isDecorator);
|
|
163223
163305
|
Debug.assert(!!decorator, "Expected position to be owned by a decorator.");
|
|
@@ -163226,20 +163308,20 @@ function makeChange10(changeTracker, sourceFile, pos) {
|
|
|
163226
163308
|
}
|
|
163227
163309
|
|
|
163228
163310
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
163229
|
-
var
|
|
163230
|
-
var
|
|
163311
|
+
var fixId48 = "fixConvertToMappedObjectType";
|
|
163312
|
+
var errorCodes61 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
163231
163313
|
registerCodeFix({
|
|
163232
|
-
errorCodes:
|
|
163314
|
+
errorCodes: errorCodes61,
|
|
163233
163315
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
163234
163316
|
const { sourceFile, span } = context;
|
|
163235
163317
|
const info = getInfo20(sourceFile, span.start);
|
|
163236
163318
|
if (!info) return void 0;
|
|
163237
163319
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
163238
163320
|
const name = idText(info.container.name);
|
|
163239
|
-
return [createCodeFixAction(
|
|
163321
|
+
return [createCodeFixAction(fixId48, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId48, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
163240
163322
|
},
|
|
163241
|
-
fixIds: [
|
|
163242
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163323
|
+
fixIds: [fixId48],
|
|
163324
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes61, (changes, diag2) => {
|
|
163243
163325
|
const info = getInfo20(diag2.file, diag2.start);
|
|
163244
163326
|
if (info) doChange39(changes, diag2.file, info);
|
|
163245
163327
|
})
|
|
@@ -163284,12 +163366,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
|
163284
163366
|
}
|
|
163285
163367
|
|
|
163286
163368
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
163287
|
-
var
|
|
163288
|
-
var
|
|
163369
|
+
var fixId49 = "removeAccidentalCallParentheses";
|
|
163370
|
+
var errorCodes62 = [
|
|
163289
163371
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
163290
163372
|
];
|
|
163291
163373
|
registerCodeFix({
|
|
163292
|
-
errorCodes:
|
|
163374
|
+
errorCodes: errorCodes62,
|
|
163293
163375
|
getCodeActions(context) {
|
|
163294
163376
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
163295
163377
|
if (!callExpression) {
|
|
@@ -163298,30 +163380,30 @@ registerCodeFix({
|
|
|
163298
163380
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
163299
163381
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
163300
163382
|
});
|
|
163301
|
-
return [createCodeFixActionWithoutFixAll(
|
|
163383
|
+
return [createCodeFixActionWithoutFixAll(fixId49, changes, Diagnostics.Remove_parentheses)];
|
|
163302
163384
|
},
|
|
163303
|
-
fixIds: [
|
|
163385
|
+
fixIds: [fixId49]
|
|
163304
163386
|
});
|
|
163305
163387
|
|
|
163306
163388
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
163307
|
-
var
|
|
163308
|
-
var
|
|
163389
|
+
var fixId50 = "removeUnnecessaryAwait";
|
|
163390
|
+
var errorCodes63 = [
|
|
163309
163391
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
163310
163392
|
];
|
|
163311
163393
|
registerCodeFix({
|
|
163312
|
-
errorCodes:
|
|
163394
|
+
errorCodes: errorCodes63,
|
|
163313
163395
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
163314
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
163396
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange12(t, context.sourceFile, context.span));
|
|
163315
163397
|
if (changes.length > 0) {
|
|
163316
|
-
return [createCodeFixAction(
|
|
163398
|
+
return [createCodeFixAction(fixId50, changes, Diagnostics.Remove_unnecessary_await, fixId50, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
163317
163399
|
}
|
|
163318
163400
|
},
|
|
163319
|
-
fixIds: [
|
|
163401
|
+
fixIds: [fixId50],
|
|
163320
163402
|
getAllCodeActions: (context) => {
|
|
163321
|
-
return codeFixAll(context,
|
|
163403
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange12(changes, diag2.file, diag2));
|
|
163322
163404
|
}
|
|
163323
163405
|
});
|
|
163324
|
-
function
|
|
163406
|
+
function makeChange12(changeTracker, sourceFile, span) {
|
|
163325
163407
|
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === 135 /* AwaitKeyword */);
|
|
163326
163408
|
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
163327
163409
|
if (!awaitExpression) {
|
|
@@ -163346,20 +163428,20 @@ function makeChange11(changeTracker, sourceFile, span) {
|
|
|
163346
163428
|
}
|
|
163347
163429
|
|
|
163348
163430
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
163349
|
-
var
|
|
163350
|
-
var
|
|
163431
|
+
var errorCodes64 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
163432
|
+
var fixId51 = "splitTypeOnlyImport";
|
|
163351
163433
|
registerCodeFix({
|
|
163352
|
-
errorCodes:
|
|
163353
|
-
fixIds: [
|
|
163434
|
+
errorCodes: errorCodes64,
|
|
163435
|
+
fixIds: [fixId51],
|
|
163354
163436
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
163355
163437
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
163356
163438
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
163357
163439
|
});
|
|
163358
163440
|
if (changes.length) {
|
|
163359
|
-
return [createCodeFixAction(
|
|
163441
|
+
return [createCodeFixAction(fixId51, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId51, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
163360
163442
|
}
|
|
163361
163443
|
},
|
|
163362
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163444
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, error2) => {
|
|
163363
163445
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
163364
163446
|
})
|
|
163365
163447
|
});
|
|
@@ -163408,22 +163490,22 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
163408
163490
|
}
|
|
163409
163491
|
|
|
163410
163492
|
// src/services/codefixes/convertConstToLet.ts
|
|
163411
|
-
var
|
|
163412
|
-
var
|
|
163493
|
+
var fixId52 = "fixConvertConstToLet";
|
|
163494
|
+
var errorCodes65 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
163413
163495
|
registerCodeFix({
|
|
163414
|
-
errorCodes:
|
|
163496
|
+
errorCodes: errorCodes65,
|
|
163415
163497
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
163416
163498
|
const { sourceFile, span, program } = context;
|
|
163417
163499
|
const info = getInfo21(sourceFile, span.start, program);
|
|
163418
163500
|
if (info === void 0) return;
|
|
163419
163501
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
163420
|
-
return [createCodeFixActionMaybeFixAll(
|
|
163502
|
+
return [createCodeFixActionMaybeFixAll(fixId52, changes, Diagnostics.Convert_const_to_let, fixId52, Diagnostics.Convert_all_const_to_let)];
|
|
163421
163503
|
},
|
|
163422
163504
|
getAllCodeActions: (context) => {
|
|
163423
163505
|
const { program } = context;
|
|
163424
163506
|
const seen = /* @__PURE__ */ new Map();
|
|
163425
163507
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
163426
|
-
eachDiagnostic(context,
|
|
163508
|
+
eachDiagnostic(context, errorCodes65, (diag2) => {
|
|
163427
163509
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
163428
163510
|
if (info) {
|
|
163429
163511
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
@@ -163434,7 +163516,7 @@ registerCodeFix({
|
|
|
163434
163516
|
});
|
|
163435
163517
|
}));
|
|
163436
163518
|
},
|
|
163437
|
-
fixIds: [
|
|
163519
|
+
fixIds: [fixId52]
|
|
163438
163520
|
});
|
|
163439
163521
|
function getInfo21(sourceFile, pos, program) {
|
|
163440
163522
|
var _a;
|
|
@@ -163452,26 +163534,26 @@ function doChange40(changes, sourceFile, token) {
|
|
|
163452
163534
|
}
|
|
163453
163535
|
|
|
163454
163536
|
// src/services/codefixes/fixExpectedComma.ts
|
|
163455
|
-
var
|
|
163537
|
+
var fixId53 = "fixExpectedComma";
|
|
163456
163538
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
163457
|
-
var
|
|
163539
|
+
var errorCodes66 = [expectedErrorCode];
|
|
163458
163540
|
registerCodeFix({
|
|
163459
|
-
errorCodes:
|
|
163541
|
+
errorCodes: errorCodes66,
|
|
163460
163542
|
getCodeActions(context) {
|
|
163461
163543
|
const { sourceFile } = context;
|
|
163462
163544
|
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
163463
163545
|
if (!info) return void 0;
|
|
163464
163546
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
163465
163547
|
return [createCodeFixAction(
|
|
163466
|
-
|
|
163548
|
+
fixId53,
|
|
163467
163549
|
changes,
|
|
163468
163550
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
163469
|
-
|
|
163551
|
+
fixId53,
|
|
163470
163552
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
163471
163553
|
)];
|
|
163472
163554
|
},
|
|
163473
|
-
fixIds: [
|
|
163474
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163555
|
+
fixIds: [fixId53],
|
|
163556
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes66, (changes, diag2) => {
|
|
163475
163557
|
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
163476
163558
|
if (info) doChange41(changes, context.sourceFile, info);
|
|
163477
163559
|
})
|
|
@@ -163487,25 +163569,25 @@ function doChange41(changes, sourceFile, { node }) {
|
|
|
163487
163569
|
|
|
163488
163570
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
163489
163571
|
var fixName7 = "addVoidToPromise";
|
|
163490
|
-
var
|
|
163491
|
-
var
|
|
163572
|
+
var fixId54 = "addVoidToPromise";
|
|
163573
|
+
var errorCodes67 = [
|
|
163492
163574
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
163493
163575
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
163494
163576
|
];
|
|
163495
163577
|
registerCodeFix({
|
|
163496
|
-
errorCodes:
|
|
163497
|
-
fixIds: [
|
|
163578
|
+
errorCodes: errorCodes67,
|
|
163579
|
+
fixIds: [fixId54],
|
|
163498
163580
|
getCodeActions(context) {
|
|
163499
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
163581
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange13(t, context.sourceFile, context.span, context.program));
|
|
163500
163582
|
if (changes.length > 0) {
|
|
163501
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
163583
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId54, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
163502
163584
|
}
|
|
163503
163585
|
},
|
|
163504
163586
|
getAllCodeActions(context) {
|
|
163505
|
-
return codeFixAll(context,
|
|
163587
|
+
return codeFixAll(context, errorCodes67, (changes, diag2) => makeChange13(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
163506
163588
|
}
|
|
163507
163589
|
});
|
|
163508
|
-
function
|
|
163590
|
+
function makeChange13(changes, sourceFile, span, program, seen) {
|
|
163509
163591
|
const node = getTokenAtPosition(sourceFile, span.start);
|
|
163510
163592
|
if (!isIdentifier(node) || !isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0) return;
|
|
163511
163593
|
const checker = program.getTypeChecker();
|
|
@@ -179580,10 +179662,10 @@ __export(ts_PasteEdits_exports, {
|
|
|
179580
179662
|
});
|
|
179581
179663
|
|
|
179582
179664
|
// src/services/pasteEdits.ts
|
|
179583
|
-
var
|
|
179665
|
+
var fixId55 = "providePostPasteEdits";
|
|
179584
179666
|
function pasteEditsProvider(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken) {
|
|
179585
179667
|
const changes = ts_textChanges_exports.ChangeTracker.with({ host, formatContext, preferences }, (changeTracker) => pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changeTracker));
|
|
179586
|
-
return { edits: changes, fixId:
|
|
179668
|
+
return { edits: changes, fixId: fixId55 };
|
|
179587
179669
|
}
|
|
179588
179670
|
function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changes) {
|
|
179589
179671
|
let actualPastedText;
|
|
@@ -192536,10 +192618,10 @@ ${e.message}`;
|
|
|
192536
192618
|
}
|
|
192537
192619
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
192538
192620
|
}
|
|
192539
|
-
getCombinedCodeFix({ scope, fixId:
|
|
192621
|
+
getCombinedCodeFix({ scope, fixId: fixId56 }, simplifiedResult) {
|
|
192540
192622
|
Debug.assert(scope.type === "file");
|
|
192541
192623
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
192542
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
192624
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId56, this.getFormatOptions(file), this.getPreferences(file));
|
|
192543
192625
|
if (simplifiedResult) {
|
|
192544
192626
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
192545
192627
|
} else {
|
|
@@ -192578,11 +192660,11 @@ ${e.message}`;
|
|
|
192578
192660
|
mapCodeAction({ description: description3, changes, commands }) {
|
|
192579
192661
|
return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
192580
192662
|
}
|
|
192581
|
-
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId:
|
|
192582
|
-
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
192663
|
+
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId56, fixAllDescription }) {
|
|
192664
|
+
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId56, fixAllDescription };
|
|
192583
192665
|
}
|
|
192584
|
-
mapPasteEditsAction({ edits, fixId:
|
|
192585
|
-
return { edits: this.mapTextChangesToCodeEdits(edits), fixId:
|
|
192666
|
+
mapPasteEditsAction({ edits, fixId: fixId56 }) {
|
|
192667
|
+
return { edits: this.mapTextChangesToCodeEdits(edits), fixId: fixId56 };
|
|
192586
192668
|
}
|
|
192587
192669
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
192588
192670
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|