typescript 5.7.0-dev.20240823 → 5.7.0-dev.20240825
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 +466 -385
- 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.20240825`;
|
|
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?"),
|
|
@@ -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
|
});
|
|
@@ -156756,8 +156837,8 @@ function getEmitModuleFormatOfFile(file, program) {
|
|
|
156756
156837
|
}
|
|
156757
156838
|
|
|
156758
156839
|
// src/services/codefixes/fixAddMissingConstraint.ts
|
|
156759
|
-
var
|
|
156760
|
-
var
|
|
156840
|
+
var fixId18 = "addMissingConstraint";
|
|
156841
|
+
var errorCodes20 = [
|
|
156761
156842
|
// We want errors this could be attached to:
|
|
156762
156843
|
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
156763
156844
|
Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
@@ -156770,20 +156851,20 @@ var errorCodes19 = [
|
|
|
156770
156851
|
Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code
|
|
156771
156852
|
];
|
|
156772
156853
|
registerCodeFix({
|
|
156773
|
-
errorCodes:
|
|
156854
|
+
errorCodes: errorCodes20,
|
|
156774
156855
|
getCodeActions(context) {
|
|
156775
156856
|
const { sourceFile, span, program, preferences, host } = context;
|
|
156776
156857
|
const info = getInfo6(program, sourceFile, span);
|
|
156777
156858
|
if (info === void 0) return;
|
|
156778
156859
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingConstraint(t, program, preferences, host, sourceFile, info));
|
|
156779
|
-
return [createCodeFixAction(
|
|
156860
|
+
return [createCodeFixAction(fixId18, changes, Diagnostics.Add_extends_constraint, fixId18, Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
156780
156861
|
},
|
|
156781
|
-
fixIds: [
|
|
156862
|
+
fixIds: [fixId18],
|
|
156782
156863
|
getAllCodeActions: (context) => {
|
|
156783
156864
|
const { program, preferences, host } = context;
|
|
156784
156865
|
const seen = /* @__PURE__ */ new Map();
|
|
156785
156866
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
156786
|
-
eachDiagnostic(context,
|
|
156867
|
+
eachDiagnostic(context, errorCodes20, (diag2) => {
|
|
156787
156868
|
const info = getInfo6(program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
156788
156869
|
if (info) {
|
|
156789
156870
|
if (addToSeen(seen, getNodeId(info.declaration))) {
|
|
@@ -156865,7 +156946,7 @@ function tryGetConstraintType(checker, node) {
|
|
|
156865
156946
|
var fixName = "fixOverrideModifier";
|
|
156866
156947
|
var fixAddOverrideId = "fixAddOverrideModifier";
|
|
156867
156948
|
var fixRemoveOverrideId = "fixRemoveOverrideModifier";
|
|
156868
|
-
var
|
|
156949
|
+
var errorCodes21 = [
|
|
156869
156950
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code,
|
|
156870
156951
|
Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code,
|
|
156871
156952
|
Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code,
|
|
@@ -156929,19 +157010,19 @@ var errorCodeFixIdMap = {
|
|
|
156929
157010
|
}
|
|
156930
157011
|
};
|
|
156931
157012
|
registerCodeFix({
|
|
156932
|
-
errorCodes:
|
|
157013
|
+
errorCodes: errorCodes21,
|
|
156933
157014
|
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
|
|
156934
157015
|
const { errorCode, span } = context;
|
|
156935
157016
|
const info = errorCodeFixIdMap[errorCode];
|
|
156936
157017
|
if (!info) return emptyArray;
|
|
156937
|
-
const { descriptions, fixId:
|
|
157018
|
+
const { descriptions, fixId: fixId56, fixAllDescriptions } = info;
|
|
156938
157019
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
156939
157020
|
return [
|
|
156940
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
157021
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId56, fixAllDescriptions)
|
|
156941
157022
|
];
|
|
156942
157023
|
},
|
|
156943
157024
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
156944
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157025
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes21, (changes, diag2) => {
|
|
156945
157026
|
const { code, start } = diag2;
|
|
156946
157027
|
const info = errorCodeFixIdMap[code];
|
|
156947
157028
|
if (!info || info.fixId !== context.fixId) {
|
|
@@ -157017,20 +157098,20 @@ function findContainerClassElementLike(sourceFile, pos) {
|
|
|
157017
157098
|
}
|
|
157018
157099
|
|
|
157019
157100
|
// src/services/codefixes/fixNoPropertyAccessFromIndexSignature.ts
|
|
157020
|
-
var
|
|
157021
|
-
var
|
|
157101
|
+
var fixId19 = "fixNoPropertyAccessFromIndexSignature";
|
|
157102
|
+
var errorCodes22 = [
|
|
157022
157103
|
Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0.code
|
|
157023
157104
|
];
|
|
157024
157105
|
registerCodeFix({
|
|
157025
|
-
errorCodes:
|
|
157026
|
-
fixIds: [
|
|
157106
|
+
errorCodes: errorCodes22,
|
|
157107
|
+
fixIds: [fixId19],
|
|
157027
157108
|
getCodeActions(context) {
|
|
157028
157109
|
const { sourceFile, span, preferences } = context;
|
|
157029
157110
|
const property = getPropertyAccessExpression(sourceFile, span.start);
|
|
157030
157111
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange14(t, context.sourceFile, property, preferences));
|
|
157031
|
-
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)];
|
|
157032
157113
|
},
|
|
157033
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157114
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes22, (changes, diag2) => doChange14(changes, diag2.file, getPropertyAccessExpression(diag2.file, diag2.start), context.preferences))
|
|
157034
157115
|
});
|
|
157035
157116
|
function doChange14(changes, sourceFile, node, preferences) {
|
|
157036
157117
|
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
@@ -157046,20 +157127,20 @@ function getPropertyAccessExpression(sourceFile, pos) {
|
|
|
157046
157127
|
}
|
|
157047
157128
|
|
|
157048
157129
|
// src/services/codefixes/fixImplicitThis.ts
|
|
157049
|
-
var
|
|
157050
|
-
var
|
|
157130
|
+
var fixId20 = "fixImplicitThis";
|
|
157131
|
+
var errorCodes23 = [Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code];
|
|
157051
157132
|
registerCodeFix({
|
|
157052
|
-
errorCodes:
|
|
157133
|
+
errorCodes: errorCodes23,
|
|
157053
157134
|
getCodeActions: function getCodeActionsToFixImplicitThis(context) {
|
|
157054
157135
|
const { sourceFile, program, span } = context;
|
|
157055
157136
|
let diagnostic;
|
|
157056
157137
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157057
157138
|
diagnostic = doChange15(t, sourceFile, span.start, program.getTypeChecker());
|
|
157058
157139
|
});
|
|
157059
|
-
return diagnostic ? [createCodeFixAction(
|
|
157140
|
+
return diagnostic ? [createCodeFixAction(fixId20, changes, diagnostic, fixId20, Diagnostics.Fix_all_implicit_this_errors)] : emptyArray;
|
|
157060
157141
|
},
|
|
157061
|
-
fixIds: [
|
|
157062
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157142
|
+
fixIds: [fixId20],
|
|
157143
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes23, (changes, diag2) => {
|
|
157063
157144
|
doChange15(changes, diag2.file, diag2.start, context.program.getTypeChecker());
|
|
157064
157145
|
})
|
|
157065
157146
|
});
|
|
@@ -157104,25 +157185,25 @@ function doChange15(changes, sourceFile, pos, checker) {
|
|
|
157104
157185
|
}
|
|
157105
157186
|
|
|
157106
157187
|
// src/services/codefixes/fixImportNonExportedMember.ts
|
|
157107
|
-
var
|
|
157108
|
-
var
|
|
157188
|
+
var fixId21 = "fixImportNonExportedMember";
|
|
157189
|
+
var errorCodes24 = [
|
|
157109
157190
|
Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code
|
|
157110
157191
|
];
|
|
157111
157192
|
registerCodeFix({
|
|
157112
|
-
errorCodes:
|
|
157113
|
-
fixIds: [
|
|
157193
|
+
errorCodes: errorCodes24,
|
|
157194
|
+
fixIds: [fixId21],
|
|
157114
157195
|
getCodeActions(context) {
|
|
157115
157196
|
const { sourceFile, span, program } = context;
|
|
157116
157197
|
const info = getInfo7(sourceFile, span.start, program);
|
|
157117
157198
|
if (info === void 0) return void 0;
|
|
157118
157199
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange16(t, program, info));
|
|
157119
|
-
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)];
|
|
157120
157201
|
},
|
|
157121
157202
|
getAllCodeActions(context) {
|
|
157122
157203
|
const { program } = context;
|
|
157123
157204
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157124
157205
|
const exports2 = /* @__PURE__ */ new Map();
|
|
157125
|
-
eachDiagnostic(context,
|
|
157206
|
+
eachDiagnostic(context, errorCodes24, (diag2) => {
|
|
157126
157207
|
const info = getInfo7(diag2.file, diag2.start, program);
|
|
157127
157208
|
if (info === void 0) return void 0;
|
|
157128
157209
|
const { exportName, node, moduleSourceFile } = info;
|
|
@@ -157262,20 +157343,20 @@ function getNodeOfSymbol(symbol) {
|
|
|
157262
157343
|
}
|
|
157263
157344
|
|
|
157264
157345
|
// src/services/codefixes/fixIncorrectNamedTupleSyntax.ts
|
|
157265
|
-
var
|
|
157266
|
-
var
|
|
157346
|
+
var fixId22 = "fixIncorrectNamedTupleSyntax";
|
|
157347
|
+
var errorCodes25 = [
|
|
157267
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,
|
|
157268
157349
|
Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type.code
|
|
157269
157350
|
];
|
|
157270
157351
|
registerCodeFix({
|
|
157271
|
-
errorCodes:
|
|
157352
|
+
errorCodes: errorCodes25,
|
|
157272
157353
|
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
|
|
157273
157354
|
const { sourceFile, span } = context;
|
|
157274
157355
|
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
|
|
157275
157356
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange17(t, sourceFile, namedTupleMember));
|
|
157276
|
-
return [createCodeFixAction(
|
|
157357
|
+
return [createCodeFixAction(fixId22, changes, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels, fixId22, Diagnostics.Move_labeled_tuple_element_modifiers_to_labels)];
|
|
157277
157358
|
},
|
|
157278
|
-
fixIds: [
|
|
157359
|
+
fixIds: [fixId22]
|
|
157279
157360
|
});
|
|
157280
157361
|
function getNamedTupleMember(sourceFile, pos) {
|
|
157281
157362
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -157310,8 +157391,8 @@ function doChange17(changes, sourceFile, namedTupleMember) {
|
|
|
157310
157391
|
}
|
|
157311
157392
|
|
|
157312
157393
|
// src/services/codefixes/fixSpelling.ts
|
|
157313
|
-
var
|
|
157314
|
-
var
|
|
157394
|
+
var fixId23 = "fixSpelling";
|
|
157395
|
+
var errorCodes26 = [
|
|
157315
157396
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157316
157397
|
Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157317
157398
|
Diagnostics.Cannot_find_name_0_Did_you_mean_1.code,
|
|
@@ -157328,7 +157409,7 @@ var errorCodes25 = [
|
|
|
157328
157409
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code
|
|
157329
157410
|
];
|
|
157330
157411
|
registerCodeFix({
|
|
157331
|
-
errorCodes:
|
|
157412
|
+
errorCodes: errorCodes26,
|
|
157332
157413
|
getCodeActions(context) {
|
|
157333
157414
|
const { sourceFile, errorCode } = context;
|
|
157334
157415
|
const info = getInfo8(sourceFile, context.span.start, context, errorCode);
|
|
@@ -157336,10 +157417,10 @@ registerCodeFix({
|
|
|
157336
157417
|
const { node, suggestedSymbol } = info;
|
|
157337
157418
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
157338
157419
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange18(t, sourceFile, node, suggestedSymbol, target));
|
|
157339
|
-
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)];
|
|
157340
157421
|
},
|
|
157341
|
-
fixIds: [
|
|
157342
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157422
|
+
fixIds: [fixId23],
|
|
157423
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes26, (changes, diag2) => {
|
|
157343
157424
|
const info = getInfo8(diag2.file, diag2.start, context, diag2.code);
|
|
157344
157425
|
const target = getEmitScriptTarget(context.host.getCompilationSettings());
|
|
157345
157426
|
if (info) doChange18(changes, context.sourceFile, info.node, info.suggestedSymbol, target);
|
|
@@ -157428,17 +157509,17 @@ function getResolvedSourceFileFromImportDeclaration(context, importDeclaration,
|
|
|
157428
157509
|
}
|
|
157429
157510
|
|
|
157430
157511
|
// src/services/codefixes/returnValueCorrect.ts
|
|
157431
|
-
var
|
|
157512
|
+
var fixId24 = "returnValueCorrect";
|
|
157432
157513
|
var fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
157433
157514
|
var fixRemoveBracesFromArrowFunctionBody = "fixRemoveBracesFromArrowFunctionBody";
|
|
157434
157515
|
var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen";
|
|
157435
|
-
var
|
|
157516
|
+
var errorCodes27 = [
|
|
157436
157517
|
Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value.code,
|
|
157437
157518
|
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
157438
157519
|
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
157439
157520
|
];
|
|
157440
157521
|
registerCodeFix({
|
|
157441
|
-
errorCodes:
|
|
157522
|
+
errorCodes: errorCodes27,
|
|
157442
157523
|
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
|
|
157443
157524
|
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
|
|
157444
157525
|
const { program, sourceFile, span: { start }, errorCode } = context;
|
|
@@ -157453,7 +157534,7 @@ registerCodeFix({
|
|
|
157453
157534
|
return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)];
|
|
157454
157535
|
}
|
|
157455
157536
|
},
|
|
157456
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157537
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes27, (changes, diag2) => {
|
|
157457
157538
|
const info = getInfo9(context.program.getTypeChecker(), diag2.file, diag2.start, diag2.code);
|
|
157458
157539
|
if (!info) return void 0;
|
|
157459
157540
|
switch (context.fixId) {
|
|
@@ -157652,7 +157733,7 @@ function wrapBlockWithParen(changes, sourceFile, declaration, expression) {
|
|
|
157652
157733
|
}
|
|
157653
157734
|
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
157654
157735
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
157655
|
-
return createCodeFixAction(
|
|
157736
|
+
return createCodeFixAction(fixId24, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
157656
157737
|
}
|
|
157657
157738
|
function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration, expression, commentSource) {
|
|
157658
157739
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => removeBlockBodyBrace(
|
|
@@ -157664,11 +157745,11 @@ function getActionForFixRemoveBracesFromArrowFunctionBody(context, declaration,
|
|
|
157664
157745
|
/*withParen*/
|
|
157665
157746
|
false
|
|
157666
157747
|
));
|
|
157667
|
-
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);
|
|
157668
157749
|
}
|
|
157669
157750
|
function getActionForfixWrapTheBlockWithParen(context, declaration, expression) {
|
|
157670
157751
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => wrapBlockWithParen(t, context.sourceFile, declaration, expression));
|
|
157671
|
-
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);
|
|
157672
157753
|
}
|
|
157673
157754
|
|
|
157674
157755
|
// src/services/codefixes/fixAddMissingMember.ts
|
|
@@ -157676,7 +157757,7 @@ var fixMissingMember = "fixMissingMember";
|
|
|
157676
157757
|
var fixMissingProperties = "fixMissingProperties";
|
|
157677
157758
|
var fixMissingAttributes = "fixMissingAttributes";
|
|
157678
157759
|
var fixMissingFunctionDeclaration = "fixMissingFunctionDeclaration";
|
|
157679
|
-
var
|
|
157760
|
+
var errorCodes28 = [
|
|
157680
157761
|
Diagnostics.Property_0_does_not_exist_on_type_1.code,
|
|
157681
157762
|
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
|
|
157682
157763
|
Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code,
|
|
@@ -157686,7 +157767,7 @@ var errorCodes27 = [
|
|
|
157686
157767
|
Diagnostics.Cannot_find_name_0.code
|
|
157687
157768
|
];
|
|
157688
157769
|
registerCodeFix({
|
|
157689
|
-
errorCodes:
|
|
157770
|
+
errorCodes: errorCodes28,
|
|
157690
157771
|
getCodeActions(context) {
|
|
157691
157772
|
const typeChecker = context.program.getTypeChecker();
|
|
157692
157773
|
const info = getInfo10(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program);
|
|
@@ -157713,21 +157794,21 @@ registerCodeFix({
|
|
|
157713
157794
|
},
|
|
157714
157795
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
157715
157796
|
getAllCodeActions: (context) => {
|
|
157716
|
-
const { program, fixId:
|
|
157797
|
+
const { program, fixId: fixId56 } = context;
|
|
157717
157798
|
const checker = program.getTypeChecker();
|
|
157718
157799
|
const seen = /* @__PURE__ */ new Map();
|
|
157719
157800
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
157720
157801
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157721
|
-
eachDiagnostic(context,
|
|
157802
|
+
eachDiagnostic(context, errorCodes28, (diag2) => {
|
|
157722
157803
|
const info = getInfo10(diag2.file, diag2.start, diag2.code, checker, context.program);
|
|
157723
157804
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
|
|
157724
157805
|
return;
|
|
157725
157806
|
}
|
|
157726
|
-
if (
|
|
157807
|
+
if (fixId56 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
157727
157808
|
addFunctionDeclaration(changes, context, info);
|
|
157728
|
-
} else if (
|
|
157809
|
+
} else if (fixId56 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
157729
157810
|
addObjectLiteralProperties(changes, context, info);
|
|
157730
|
-
} else if (
|
|
157811
|
+
} else if (fixId56 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
157731
157812
|
addJsxAttributes(changes, context, info);
|
|
157732
157813
|
} else {
|
|
157733
157814
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -158296,17 +158377,17 @@ function findScope(node) {
|
|
|
158296
158377
|
}
|
|
158297
158378
|
|
|
158298
158379
|
// src/services/codefixes/fixAddMissingNewOperator.ts
|
|
158299
|
-
var
|
|
158300
|
-
var
|
|
158380
|
+
var fixId25 = "addMissingNewOperator";
|
|
158381
|
+
var errorCodes29 = [Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new.code];
|
|
158301
158382
|
registerCodeFix({
|
|
158302
|
-
errorCodes:
|
|
158383
|
+
errorCodes: errorCodes29,
|
|
158303
158384
|
getCodeActions(context) {
|
|
158304
158385
|
const { sourceFile, span } = context;
|
|
158305
158386
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingNewOperator(t, sourceFile, span));
|
|
158306
|
-
return [createCodeFixAction(
|
|
158387
|
+
return [createCodeFixAction(fixId25, changes, Diagnostics.Add_missing_new_operator_to_call, fixId25, Diagnostics.Add_missing_new_operator_to_all_calls)];
|
|
158307
158388
|
},
|
|
158308
|
-
fixIds: [
|
|
158309
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158389
|
+
fixIds: [fixId25],
|
|
158390
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes29, (changes, diag2) => addMissingNewOperator(changes, context.sourceFile, diag2))
|
|
158310
158391
|
});
|
|
158311
158392
|
function addMissingNewOperator(changes, sourceFile, span) {
|
|
158312
158393
|
const call = cast(findAncestorMatchingSpan2(sourceFile, span), isCallExpression);
|
|
@@ -158325,9 +158406,9 @@ function findAncestorMatchingSpan2(sourceFile, span) {
|
|
|
158325
158406
|
// src/services/codefixes/fixAddMissingParam.ts
|
|
158326
158407
|
var addMissingParamFixId = "addMissingParam";
|
|
158327
158408
|
var addOptionalParamFixId = "addOptionalParam";
|
|
158328
|
-
var
|
|
158409
|
+
var errorCodes30 = [Diagnostics.Expected_0_arguments_but_got_1.code];
|
|
158329
158410
|
registerCodeFix({
|
|
158330
|
-
errorCodes:
|
|
158411
|
+
errorCodes: errorCodes30,
|
|
158331
158412
|
fixIds: [addMissingParamFixId, addOptionalParamFixId],
|
|
158332
158413
|
getCodeActions(context) {
|
|
158333
158414
|
const info = getInfo11(context.sourceFile, context.program, context.span.start);
|
|
@@ -158360,7 +158441,7 @@ registerCodeFix({
|
|
|
158360
158441
|
}
|
|
158361
158442
|
return actions2;
|
|
158362
158443
|
},
|
|
158363
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158444
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes30, (changes, diag2) => {
|
|
158364
158445
|
const info = getInfo11(context.sourceFile, context.program, diag2.start);
|
|
158365
158446
|
if (info) {
|
|
158366
158447
|
const { declarations, newParameters, newOptionalParameters } = info;
|
|
@@ -158563,12 +158644,12 @@ function getParameterType(importAdder, typeNode, scriptTarget) {
|
|
|
158563
158644
|
var fixName2 = "fixCannotFindModule";
|
|
158564
158645
|
var fixIdInstallTypesPackage = "installTypesPackage";
|
|
158565
158646
|
var errorCodeCannotFindModule = Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code;
|
|
158566
|
-
var
|
|
158647
|
+
var errorCodes31 = [
|
|
158567
158648
|
errorCodeCannotFindModule,
|
|
158568
158649
|
Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code
|
|
158569
158650
|
];
|
|
158570
158651
|
registerCodeFix({
|
|
158571
|
-
errorCodes:
|
|
158652
|
+
errorCodes: errorCodes31,
|
|
158572
158653
|
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
|
|
158573
158654
|
const { host, sourceFile, span: { start } } = context;
|
|
158574
158655
|
const packageName = tryGetImportedPackageName(sourceFile, start);
|
|
@@ -158586,7 +158667,7 @@ registerCodeFix({
|
|
|
158586
158667
|
},
|
|
158587
158668
|
fixIds: [fixIdInstallTypesPackage],
|
|
158588
158669
|
getAllCodeActions: (context) => {
|
|
158589
|
-
return codeFixAll(context,
|
|
158670
|
+
return codeFixAll(context, errorCodes31, (_changes, diag2, commands) => {
|
|
158590
158671
|
const packageName = tryGetImportedPackageName(diag2.file, diag2.start);
|
|
158591
158672
|
if (packageName === void 0) return void 0;
|
|
158592
158673
|
switch (context.fixId) {
|
|
@@ -158619,7 +158700,7 @@ function getTypesPackageNameToInstall(packageName, host, diagCode) {
|
|
|
158619
158700
|
}
|
|
158620
158701
|
|
|
158621
158702
|
// src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts
|
|
158622
|
-
var
|
|
158703
|
+
var errorCodes32 = [
|
|
158623
158704
|
Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2.code,
|
|
158624
158705
|
Diagnostics.Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2.code,
|
|
158625
158706
|
Diagnostics.Non_abstract_class_0_is_missing_implementations_for_the_following_members_of_1_Colon_2_and_3_more.code,
|
|
@@ -158627,18 +158708,18 @@ var errorCodes31 = [
|
|
|
158627
158708
|
Diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1.code,
|
|
158628
158709
|
Diagnostics.Non_abstract_class_expression_is_missing_implementations_for_the_following_members_of_0_Colon_1_and_2_more.code
|
|
158629
158710
|
];
|
|
158630
|
-
var
|
|
158711
|
+
var fixId26 = "fixClassDoesntImplementInheritedAbstractMember";
|
|
158631
158712
|
registerCodeFix({
|
|
158632
|
-
errorCodes:
|
|
158713
|
+
errorCodes: errorCodes32,
|
|
158633
158714
|
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
|
|
158634
158715
|
const { sourceFile, span } = context;
|
|
158635
158716
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => addMissingMembers(getClass2(sourceFile, span.start), sourceFile, context, t, context.preferences));
|
|
158636
|
-
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)];
|
|
158637
158718
|
},
|
|
158638
|
-
fixIds: [
|
|
158719
|
+
fixIds: [fixId26],
|
|
158639
158720
|
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
|
|
158640
158721
|
const seenClassDeclarations = /* @__PURE__ */ new Map();
|
|
158641
|
-
return codeFixAll(context,
|
|
158722
|
+
return codeFixAll(context, errorCodes32, (changes, diag2) => {
|
|
158642
158723
|
const classDeclaration = getClass2(diag2.file, diag2.start);
|
|
158643
158724
|
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
|
158644
158725
|
addMissingMembers(classDeclaration, context.sourceFile, context, changes, context.preferences);
|
|
@@ -158665,23 +158746,23 @@ function symbolPointsToNonPrivateAndAbstractMember(symbol) {
|
|
|
158665
158746
|
}
|
|
158666
158747
|
|
|
158667
158748
|
// src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts
|
|
158668
|
-
var
|
|
158669
|
-
var
|
|
158749
|
+
var fixId27 = "classSuperMustPrecedeThisAccess";
|
|
158750
|
+
var errorCodes33 = [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code];
|
|
158670
158751
|
registerCodeFix({
|
|
158671
|
-
errorCodes:
|
|
158752
|
+
errorCodes: errorCodes33,
|
|
158672
158753
|
getCodeActions(context) {
|
|
158673
158754
|
const { sourceFile, span } = context;
|
|
158674
158755
|
const nodes = getNodes(sourceFile, span.start);
|
|
158675
158756
|
if (!nodes) return void 0;
|
|
158676
158757
|
const { constructor, superCall } = nodes;
|
|
158677
158758
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange20(t, sourceFile, constructor, superCall));
|
|
158678
|
-
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)];
|
|
158679
158760
|
},
|
|
158680
|
-
fixIds: [
|
|
158761
|
+
fixIds: [fixId27],
|
|
158681
158762
|
getAllCodeActions(context) {
|
|
158682
158763
|
const { sourceFile } = context;
|
|
158683
158764
|
const seenClasses = /* @__PURE__ */ new Map();
|
|
158684
|
-
return codeFixAll(context,
|
|
158765
|
+
return codeFixAll(context, errorCodes33, (changes, diag2) => {
|
|
158685
158766
|
const nodes = getNodes(diag2.file, diag2.start);
|
|
158686
158767
|
if (!nodes) return;
|
|
158687
158768
|
const { constructor, superCall } = nodes;
|
|
@@ -158707,18 +158788,18 @@ function findSuperCall(n) {
|
|
|
158707
158788
|
}
|
|
158708
158789
|
|
|
158709
158790
|
// src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts
|
|
158710
|
-
var
|
|
158711
|
-
var
|
|
158791
|
+
var fixId28 = "constructorForDerivedNeedSuperCall";
|
|
158792
|
+
var errorCodes34 = [Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code];
|
|
158712
158793
|
registerCodeFix({
|
|
158713
|
-
errorCodes:
|
|
158794
|
+
errorCodes: errorCodes34,
|
|
158714
158795
|
getCodeActions(context) {
|
|
158715
158796
|
const { sourceFile, span } = context;
|
|
158716
158797
|
const ctr = getNode(sourceFile, span.start);
|
|
158717
158798
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange21(t, sourceFile, ctr));
|
|
158718
|
-
return [createCodeFixAction(
|
|
158799
|
+
return [createCodeFixAction(fixId28, changes, Diagnostics.Add_missing_super_call, fixId28, Diagnostics.Add_all_missing_super_calls)];
|
|
158719
158800
|
},
|
|
158720
|
-
fixIds: [
|
|
158721
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158801
|
+
fixIds: [fixId28],
|
|
158802
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes34, (changes, diag2) => doChange21(changes, context.sourceFile, getNode(diag2.file, diag2.start)))
|
|
158722
158803
|
});
|
|
158723
158804
|
function getNode(sourceFile, pos) {
|
|
158724
158805
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -158738,9 +158819,9 @@ function doChange21(changes, sourceFile, ctr) {
|
|
|
158738
158819
|
|
|
158739
158820
|
// src/services/codefixes/fixEnableJsxFlag.ts
|
|
158740
158821
|
var fixID = "fixEnableJsxFlag";
|
|
158741
|
-
var
|
|
158822
|
+
var errorCodes35 = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
|
|
158742
158823
|
registerCodeFix({
|
|
158743
|
-
errorCodes:
|
|
158824
|
+
errorCodes: errorCodes35,
|
|
158744
158825
|
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
|
|
158745
158826
|
const { configFile } = context.program.getCompilerOptions();
|
|
158746
158827
|
if (configFile === void 0) {
|
|
@@ -158752,7 +158833,7 @@ registerCodeFix({
|
|
|
158752
158833
|
];
|
|
158753
158834
|
},
|
|
158754
158835
|
fixIds: [fixID],
|
|
158755
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158836
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes35, (changes) => {
|
|
158756
158837
|
const { configFile } = context.program.getCompilerOptions();
|
|
158757
158838
|
if (configFile === void 0) {
|
|
158758
158839
|
return void 0;
|
|
@@ -158765,23 +158846,23 @@ function doChange22(changeTracker, configFile) {
|
|
|
158765
158846
|
}
|
|
158766
158847
|
|
|
158767
158848
|
// src/services/codefixes/fixNaNEquality.ts
|
|
158768
|
-
var
|
|
158769
|
-
var
|
|
158849
|
+
var fixId29 = "fixNaNEquality";
|
|
158850
|
+
var errorCodes36 = [
|
|
158770
158851
|
Diagnostics.This_condition_will_always_return_0.code
|
|
158771
158852
|
];
|
|
158772
158853
|
registerCodeFix({
|
|
158773
|
-
errorCodes:
|
|
158854
|
+
errorCodes: errorCodes36,
|
|
158774
158855
|
getCodeActions(context) {
|
|
158775
158856
|
const { sourceFile, span, program } = context;
|
|
158776
158857
|
const info = getInfo12(program, sourceFile, span);
|
|
158777
158858
|
if (info === void 0) return;
|
|
158778
158859
|
const { suggestion, expression, arg } = info;
|
|
158779
158860
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange23(t, sourceFile, arg, expression));
|
|
158780
|
-
return [createCodeFixAction(
|
|
158861
|
+
return [createCodeFixAction(fixId29, changes, [Diagnostics.Use_0, suggestion], fixId29, Diagnostics.Use_Number_isNaN_in_all_conditions)];
|
|
158781
158862
|
},
|
|
158782
|
-
fixIds: [
|
|
158863
|
+
fixIds: [fixId29],
|
|
158783
158864
|
getAllCodeActions: (context) => {
|
|
158784
|
-
return codeFixAll(context,
|
|
158865
|
+
return codeFixAll(context, errorCodes36, (changes, diag2) => {
|
|
158785
158866
|
const info = getInfo12(context.program, diag2.file, createTextSpan(diag2.start, diag2.length));
|
|
158786
158867
|
if (info) {
|
|
158787
158868
|
doChange23(changes, diag2.file, info.arg, info.expression);
|
|
@@ -158861,20 +158942,20 @@ registerCodeFix({
|
|
|
158861
158942
|
});
|
|
158862
158943
|
|
|
158863
158944
|
// src/services/codefixes/fixPropertyAssignment.ts
|
|
158864
|
-
var
|
|
158865
|
-
var
|
|
158945
|
+
var fixId30 = "fixPropertyAssignment";
|
|
158946
|
+
var errorCodes37 = [
|
|
158866
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
|
|
158867
158948
|
];
|
|
158868
158949
|
registerCodeFix({
|
|
158869
|
-
errorCodes:
|
|
158870
|
-
fixIds: [
|
|
158950
|
+
errorCodes: errorCodes37,
|
|
158951
|
+
fixIds: [fixId30],
|
|
158871
158952
|
getCodeActions(context) {
|
|
158872
158953
|
const { sourceFile, span } = context;
|
|
158873
158954
|
const property = getProperty2(sourceFile, span.start);
|
|
158874
158955
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange24(t, context.sourceFile, property));
|
|
158875
|
-
return [createCodeFixAction(
|
|
158956
|
+
return [createCodeFixAction(fixId30, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId30, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
|
|
158876
158957
|
},
|
|
158877
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158958
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes37, (changes, diag2) => doChange24(changes, diag2.file, getProperty2(diag2.file, diag2.start)))
|
|
158878
158959
|
});
|
|
158879
158960
|
function doChange24(changes, sourceFile, node) {
|
|
158880
158961
|
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer));
|
|
@@ -158884,20 +158965,20 @@ function getProperty2(sourceFile, pos) {
|
|
|
158884
158965
|
}
|
|
158885
158966
|
|
|
158886
158967
|
// src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts
|
|
158887
|
-
var
|
|
158888
|
-
var
|
|
158968
|
+
var fixId31 = "extendsInterfaceBecomesImplements";
|
|
158969
|
+
var errorCodes38 = [Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements.code];
|
|
158889
158970
|
registerCodeFix({
|
|
158890
|
-
errorCodes:
|
|
158971
|
+
errorCodes: errorCodes38,
|
|
158891
158972
|
getCodeActions(context) {
|
|
158892
158973
|
const { sourceFile } = context;
|
|
158893
158974
|
const nodes = getNodes2(sourceFile, context.span.start);
|
|
158894
158975
|
if (!nodes) return void 0;
|
|
158895
158976
|
const { extendsToken, heritageClauses } = nodes;
|
|
158896
158977
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChanges2(t, sourceFile, extendsToken, heritageClauses));
|
|
158897
|
-
return [createCodeFixAction(
|
|
158978
|
+
return [createCodeFixAction(fixId31, changes, Diagnostics.Change_extends_to_implements, fixId31, Diagnostics.Change_all_extended_interfaces_to_implements)];
|
|
158898
158979
|
},
|
|
158899
|
-
fixIds: [
|
|
158900
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
158980
|
+
fixIds: [fixId31],
|
|
158981
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes38, (changes, diag2) => {
|
|
158901
158982
|
const nodes = getNodes2(diag2.file, diag2.start);
|
|
158902
158983
|
if (nodes) doChanges2(changes, diag2.file, nodes.extendsToken, nodes.heritageClauses);
|
|
158903
158984
|
})
|
|
@@ -158924,15 +159005,15 @@ function doChanges2(changes, sourceFile, extendsToken, heritageClauses) {
|
|
|
158924
159005
|
}
|
|
158925
159006
|
|
|
158926
159007
|
// src/services/codefixes/fixForgottenThisPropertyAccess.ts
|
|
158927
|
-
var
|
|
159008
|
+
var fixId32 = "forgottenThisPropertyAccess";
|
|
158928
159009
|
var didYouMeanStaticMemberCode = Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code;
|
|
158929
|
-
var
|
|
159010
|
+
var errorCodes39 = [
|
|
158930
159011
|
Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code,
|
|
158931
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,
|
|
158932
159013
|
didYouMeanStaticMemberCode
|
|
158933
159014
|
];
|
|
158934
159015
|
registerCodeFix({
|
|
158935
|
-
errorCodes:
|
|
159016
|
+
errorCodes: errorCodes39,
|
|
158936
159017
|
getCodeActions(context) {
|
|
158937
159018
|
const { sourceFile } = context;
|
|
158938
159019
|
const info = getInfo13(sourceFile, context.span.start, context.errorCode);
|
|
@@ -158940,10 +159021,10 @@ registerCodeFix({
|
|
|
158940
159021
|
return void 0;
|
|
158941
159022
|
}
|
|
158942
159023
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange25(t, sourceFile, info));
|
|
158943
|
-
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)];
|
|
158944
159025
|
},
|
|
158945
|
-
fixIds: [
|
|
158946
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159026
|
+
fixIds: [fixId32],
|
|
159027
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes39, (changes, diag2) => {
|
|
158947
159028
|
const info = getInfo13(diag2.file, diag2.start, diag2.code);
|
|
158948
159029
|
if (info) doChange25(changes, context.sourceFile, info);
|
|
158949
159030
|
})
|
|
@@ -158962,12 +159043,12 @@ function doChange25(changes, sourceFile, { node, className }) {
|
|
|
158962
159043
|
// src/services/codefixes/fixInvalidJsxCharacters.ts
|
|
158963
159044
|
var fixIdExpression = "fixInvalidJsxCharacters_expression";
|
|
158964
159045
|
var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity";
|
|
158965
|
-
var
|
|
159046
|
+
var errorCodes40 = [
|
|
158966
159047
|
Diagnostics.Unexpected_token_Did_you_mean_or_gt.code,
|
|
158967
159048
|
Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code
|
|
158968
159049
|
];
|
|
158969
159050
|
registerCodeFix({
|
|
158970
|
-
errorCodes:
|
|
159051
|
+
errorCodes: errorCodes40,
|
|
158971
159052
|
fixIds: [fixIdExpression, fixIdHtmlEntity],
|
|
158972
159053
|
getCodeActions(context) {
|
|
158973
159054
|
const { sourceFile, preferences, span } = context;
|
|
@@ -158993,7 +159074,7 @@ registerCodeFix({
|
|
|
158993
159074
|
];
|
|
158994
159075
|
},
|
|
158995
159076
|
getAllCodeActions(context) {
|
|
158996
|
-
return codeFixAll(context,
|
|
159077
|
+
return codeFixAll(context, errorCodes40, (changes, diagnostic) => doChange26(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity));
|
|
158997
159078
|
}
|
|
158998
159079
|
});
|
|
158999
159080
|
var htmlEntity = {
|
|
@@ -159015,12 +159096,12 @@ function doChange26(changes, preferences, sourceFile, start, useHtmlEntity) {
|
|
|
159015
159096
|
// src/services/codefixes/fixUnmatchedParameter.ts
|
|
159016
159097
|
var deleteUnmatchedParameter = "deleteUnmatchedParameter";
|
|
159017
159098
|
var renameUnmatchedParameter = "renameUnmatchedParameter";
|
|
159018
|
-
var
|
|
159099
|
+
var errorCodes41 = [
|
|
159019
159100
|
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name.code
|
|
159020
159101
|
];
|
|
159021
159102
|
registerCodeFix({
|
|
159022
159103
|
fixIds: [deleteUnmatchedParameter, renameUnmatchedParameter],
|
|
159023
|
-
errorCodes:
|
|
159104
|
+
errorCodes: errorCodes41,
|
|
159024
159105
|
getCodeActions: function getCodeActionsToFixUnmatchedParameter(context) {
|
|
159025
159106
|
const { sourceFile, span } = context;
|
|
159026
159107
|
const actions2 = [];
|
|
@@ -159035,7 +159116,7 @@ registerCodeFix({
|
|
|
159035
159116
|
getAllCodeActions: function getAllCodeActionsToFixUnmatchedParameter(context) {
|
|
159036
159117
|
const tagsToSignature = /* @__PURE__ */ new Map();
|
|
159037
159118
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
159038
|
-
eachDiagnostic(context,
|
|
159119
|
+
eachDiagnostic(context, errorCodes41, ({ file, start }) => {
|
|
159039
159120
|
const info = getInfo14(file, start);
|
|
159040
159121
|
if (info) {
|
|
159041
159122
|
tagsToSignature.set(info.signature, append(tagsToSignature.get(info.signature), info.jsDocParameterTag));
|
|
@@ -159098,10 +159179,10 @@ function getInfo14(sourceFile, pos) {
|
|
|
159098
159179
|
}
|
|
159099
159180
|
|
|
159100
159181
|
// src/services/codefixes/fixUnreferenceableDecoratorMetadata.ts
|
|
159101
|
-
var
|
|
159102
|
-
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];
|
|
159103
159184
|
registerCodeFix({
|
|
159104
|
-
errorCodes:
|
|
159185
|
+
errorCodes: errorCodes42,
|
|
159105
159186
|
getCodeActions: (context) => {
|
|
159106
159187
|
const importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
159107
159188
|
if (!importDeclaration) return;
|
|
@@ -159109,14 +159190,14 @@ registerCodeFix({
|
|
|
159109
159190
|
const typeOnlyChanges = ts_textChanges_exports.ChangeTracker.with(context, (t) => doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program));
|
|
159110
159191
|
let actions2;
|
|
159111
159192
|
if (namespaceChanges.length) {
|
|
159112
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
159193
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId33, namespaceChanges, Diagnostics.Convert_named_imports_to_namespace_import));
|
|
159113
159194
|
}
|
|
159114
159195
|
if (typeOnlyChanges.length) {
|
|
159115
|
-
actions2 = append(actions2, createCodeFixActionWithoutFixAll(
|
|
159196
|
+
actions2 = append(actions2, createCodeFixActionWithoutFixAll(fixId33, typeOnlyChanges, Diagnostics.Use_import_type));
|
|
159116
159197
|
}
|
|
159117
159198
|
return actions2;
|
|
159118
159199
|
},
|
|
159119
|
-
fixIds: [
|
|
159200
|
+
fixIds: [fixId33]
|
|
159120
159201
|
});
|
|
159121
159202
|
function getImportDeclaration(sourceFile, program, start) {
|
|
159122
159203
|
const identifier = tryCast(getTokenAtPosition(sourceFile, start), isIdentifier);
|
|
@@ -159153,7 +159234,7 @@ var fixIdPrefix = "unusedIdentifier_prefix";
|
|
|
159153
159234
|
var fixIdDelete = "unusedIdentifier_delete";
|
|
159154
159235
|
var fixIdDeleteImports = "unusedIdentifier_deleteImports";
|
|
159155
159236
|
var fixIdInfer = "unusedIdentifier_infer";
|
|
159156
|
-
var
|
|
159237
|
+
var errorCodes43 = [
|
|
159157
159238
|
Diagnostics._0_is_declared_but_its_value_is_never_read.code,
|
|
159158
159239
|
Diagnostics._0_is_declared_but_never_used.code,
|
|
159159
159240
|
Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code,
|
|
@@ -159163,7 +159244,7 @@ var errorCodes42 = [
|
|
|
159163
159244
|
Diagnostics.All_type_parameters_are_unused.code
|
|
159164
159245
|
];
|
|
159165
159246
|
registerCodeFix({
|
|
159166
|
-
errorCodes:
|
|
159247
|
+
errorCodes: errorCodes43,
|
|
159167
159248
|
getCodeActions(context) {
|
|
159168
159249
|
const { errorCode, sourceFile, program, cancellationToken } = context;
|
|
159169
159250
|
const checker = program.getTypeChecker();
|
|
@@ -159252,7 +159333,7 @@ registerCodeFix({
|
|
|
159252
159333
|
const { sourceFile, program, cancellationToken } = context;
|
|
159253
159334
|
const checker = program.getTypeChecker();
|
|
159254
159335
|
const sourceFiles = program.getSourceFiles();
|
|
159255
|
-
return codeFixAll(context,
|
|
159336
|
+
return codeFixAll(context, errorCodes43, (changes, diag2) => {
|
|
159256
159337
|
const token = getTokenAtPosition(sourceFile, diag2.start);
|
|
159257
159338
|
switch (context.fixId) {
|
|
159258
159339
|
case fixIdPrefix:
|
|
@@ -159492,18 +159573,18 @@ function deleteFunctionLikeDeclaration(changes, sourceFile, node) {
|
|
|
159492
159573
|
}
|
|
159493
159574
|
|
|
159494
159575
|
// src/services/codefixes/fixUnreachableCode.ts
|
|
159495
|
-
var
|
|
159496
|
-
var
|
|
159576
|
+
var fixId34 = "fixUnreachableCode";
|
|
159577
|
+
var errorCodes44 = [Diagnostics.Unreachable_code_detected.code];
|
|
159497
159578
|
registerCodeFix({
|
|
159498
|
-
errorCodes:
|
|
159579
|
+
errorCodes: errorCodes44,
|
|
159499
159580
|
getCodeActions(context) {
|
|
159500
159581
|
const syntacticDiagnostics = context.program.getSyntacticDiagnostics(context.sourceFile, context.cancellationToken);
|
|
159501
159582
|
if (syntacticDiagnostics.length) return;
|
|
159502
159583
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange27(t, context.sourceFile, context.span.start, context.span.length, context.errorCode));
|
|
159503
|
-
return [createCodeFixAction(
|
|
159584
|
+
return [createCodeFixAction(fixId34, changes, Diagnostics.Remove_unreachable_code, fixId34, Diagnostics.Remove_all_unreachable_code)];
|
|
159504
159585
|
},
|
|
159505
|
-
fixIds: [
|
|
159506
|
-
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))
|
|
159507
159588
|
});
|
|
159508
159589
|
function doChange27(changes, sourceFile, start, length2, errorCode) {
|
|
159509
159590
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -159554,16 +159635,16 @@ function lastWhere(a, pred) {
|
|
|
159554
159635
|
}
|
|
159555
159636
|
|
|
159556
159637
|
// src/services/codefixes/fixUnusedLabel.ts
|
|
159557
|
-
var
|
|
159558
|
-
var
|
|
159638
|
+
var fixId35 = "fixUnusedLabel";
|
|
159639
|
+
var errorCodes45 = [Diagnostics.Unused_label.code];
|
|
159559
159640
|
registerCodeFix({
|
|
159560
|
-
errorCodes:
|
|
159641
|
+
errorCodes: errorCodes45,
|
|
159561
159642
|
getCodeActions(context) {
|
|
159562
159643
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange28(t, context.sourceFile, context.span.start));
|
|
159563
|
-
return [createCodeFixAction(
|
|
159644
|
+
return [createCodeFixAction(fixId35, changes, Diagnostics.Remove_unused_label, fixId35, Diagnostics.Remove_all_unused_labels)];
|
|
159564
159645
|
},
|
|
159565
|
-
fixIds: [
|
|
159566
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159646
|
+
fixIds: [fixId35],
|
|
159647
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes45, (changes, diag2) => doChange28(changes, diag2.file, diag2.start))
|
|
159567
159648
|
});
|
|
159568
159649
|
function doChange28(changes, sourceFile, start) {
|
|
159569
159650
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -159582,13 +159663,13 @@ function doChange28(changes, sourceFile, start) {
|
|
|
159582
159663
|
// src/services/codefixes/fixJSDocTypes.ts
|
|
159583
159664
|
var fixIdPlain = "fixJSDocTypes_plain";
|
|
159584
159665
|
var fixIdNullable = "fixJSDocTypes_nullable";
|
|
159585
|
-
var
|
|
159666
|
+
var errorCodes46 = [
|
|
159586
159667
|
Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments.code,
|
|
159587
159668
|
Diagnostics._0_at_the_end_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code,
|
|
159588
159669
|
Diagnostics._0_at_the_start_of_a_type_is_not_valid_TypeScript_syntax_Did_you_mean_to_write_1.code
|
|
159589
159670
|
];
|
|
159590
159671
|
registerCodeFix({
|
|
159591
|
-
errorCodes:
|
|
159672
|
+
errorCodes: errorCodes46,
|
|
159592
159673
|
getCodeActions(context) {
|
|
159593
159674
|
const { sourceFile } = context;
|
|
159594
159675
|
const checker = context.program.getTypeChecker();
|
|
@@ -159601,20 +159682,20 @@ registerCodeFix({
|
|
|
159601
159682
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
159602
159683
|
}
|
|
159603
159684
|
return actions2;
|
|
159604
|
-
function fix(type2,
|
|
159685
|
+
function fix(type2, fixId56, fixAllDescription) {
|
|
159605
159686
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
159606
|
-
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);
|
|
159607
159688
|
}
|
|
159608
159689
|
},
|
|
159609
159690
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
159610
159691
|
getAllCodeActions(context) {
|
|
159611
|
-
const { fixId:
|
|
159692
|
+
const { fixId: fixId56, program, sourceFile } = context;
|
|
159612
159693
|
const checker = program.getTypeChecker();
|
|
159613
|
-
return codeFixAll(context,
|
|
159694
|
+
return codeFixAll(context, errorCodes46, (changes, err) => {
|
|
159614
159695
|
const info = getInfo15(err.file, err.start, checker);
|
|
159615
159696
|
if (!info) return;
|
|
159616
159697
|
const { typeNode, type } = info;
|
|
159617
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ &&
|
|
159698
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId56 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
159618
159699
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
159619
159700
|
});
|
|
159620
159701
|
}
|
|
@@ -159670,21 +159751,21 @@ function getType(checker, node) {
|
|
|
159670
159751
|
}
|
|
159671
159752
|
|
|
159672
159753
|
// src/services/codefixes/fixMissingCallParentheses.ts
|
|
159673
|
-
var
|
|
159674
|
-
var
|
|
159754
|
+
var fixId36 = "fixMissingCallParentheses";
|
|
159755
|
+
var errorCodes47 = [
|
|
159675
159756
|
Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code
|
|
159676
159757
|
];
|
|
159677
159758
|
registerCodeFix({
|
|
159678
|
-
errorCodes:
|
|
159679
|
-
fixIds: [
|
|
159759
|
+
errorCodes: errorCodes47,
|
|
159760
|
+
fixIds: [fixId36],
|
|
159680
159761
|
getCodeActions(context) {
|
|
159681
159762
|
const { sourceFile, span } = context;
|
|
159682
159763
|
const callName = getCallName(sourceFile, span.start);
|
|
159683
159764
|
if (!callName) return;
|
|
159684
159765
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange30(t, context.sourceFile, callName));
|
|
159685
|
-
return [createCodeFixAction(
|
|
159766
|
+
return [createCodeFixAction(fixId36, changes, Diagnostics.Add_missing_call_parentheses, fixId36, Diagnostics.Add_all_missing_call_parentheses)];
|
|
159686
159767
|
},
|
|
159687
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
159768
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes47, (changes, diag2) => {
|
|
159688
159769
|
const callName = getCallName(diag2.file, diag2.start);
|
|
159689
159770
|
if (callName) doChange30(changes, diag2.file, callName);
|
|
159690
159771
|
})
|
|
@@ -159708,11 +159789,11 @@ function getCallName(sourceFile, start) {
|
|
|
159708
159789
|
}
|
|
159709
159790
|
|
|
159710
159791
|
// src/services/codefixes/fixMissingTypeAnnotationOnExports.ts
|
|
159711
|
-
var
|
|
159792
|
+
var fixId37 = "fixMissingTypeAnnotationOnExports";
|
|
159712
159793
|
var addAnnotationFix = "add-annotation";
|
|
159713
159794
|
var addInlineTypeAssertion = "add-type-assertion";
|
|
159714
159795
|
var extractExpression = "extract-expression";
|
|
159715
|
-
var
|
|
159796
|
+
var errorCodes48 = [
|
|
159716
159797
|
Diagnostics.Function_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
159717
159798
|
Diagnostics.Method_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
159718
159799
|
Diagnostics.At_least_one_accessor_must_have_an_explicit_return_type_annotation_with_isolatedDeclarations.code,
|
|
@@ -159752,8 +159833,8 @@ var canHaveTypeAnnotation = /* @__PURE__ */ new Set([
|
|
|
159752
159833
|
var declarationEmitNodeBuilderFlags2 = 1024 /* MultilineObjectLiterals */ | 2048 /* WriteClassExpressionAsTypeLiteral */ | 4096 /* UseTypeOfFunction */ | 8 /* UseStructuralFallback */ | 524288 /* AllowEmptyTuple */ | 4 /* GenerateNamesForShadowedTypeParams */ | 1 /* NoTruncation */;
|
|
159753
159834
|
var declarationEmitInternalNodeBuilderFlags2 = 1 /* WriteComputedProps */;
|
|
159754
159835
|
registerCodeFix({
|
|
159755
|
-
errorCodes:
|
|
159756
|
-
fixIds: [
|
|
159836
|
+
errorCodes: errorCodes48,
|
|
159837
|
+
fixIds: [fixId37],
|
|
159757
159838
|
getCodeActions(context) {
|
|
159758
159839
|
const fixes = [];
|
|
159759
159840
|
addCodeAction(addAnnotationFix, fixes, context, 0 /* Full */, (f) => f.addTypeAnnotation(context.span));
|
|
@@ -159767,7 +159848,7 @@ registerCodeFix({
|
|
|
159767
159848
|
},
|
|
159768
159849
|
getAllCodeActions: (context) => {
|
|
159769
159850
|
const changes = withContext(context, 0 /* Full */, (f) => {
|
|
159770
|
-
eachDiagnostic(context,
|
|
159851
|
+
eachDiagnostic(context, errorCodes48, (diag2) => {
|
|
159771
159852
|
f.addTypeAnnotation(diag2);
|
|
159772
159853
|
});
|
|
159773
159854
|
});
|
|
@@ -159781,7 +159862,7 @@ function addCodeAction(fixName8, fixes, context, typePrintMode, cb) {
|
|
|
159781
159862
|
fixName8,
|
|
159782
159863
|
changes.textChanges,
|
|
159783
159864
|
changes.result,
|
|
159784
|
-
|
|
159865
|
+
fixId37,
|
|
159785
159866
|
Diagnostics.Add_all_missing_type_annotations
|
|
159786
159867
|
));
|
|
159787
159868
|
}
|
|
@@ -160601,26 +160682,26 @@ function withContext(context, typePrintMode, cb) {
|
|
|
160601
160682
|
}
|
|
160602
160683
|
|
|
160603
160684
|
// src/services/codefixes/fixAwaitInSyncFunction.ts
|
|
160604
|
-
var
|
|
160605
|
-
var
|
|
160685
|
+
var fixId38 = "fixAwaitInSyncFunction";
|
|
160686
|
+
var errorCodes49 = [
|
|
160606
160687
|
Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160607
160688
|
Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160608
160689
|
Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
160609
160690
|
Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code
|
|
160610
160691
|
];
|
|
160611
160692
|
registerCodeFix({
|
|
160612
|
-
errorCodes:
|
|
160693
|
+
errorCodes: errorCodes49,
|
|
160613
160694
|
getCodeActions(context) {
|
|
160614
160695
|
const { sourceFile, span } = context;
|
|
160615
160696
|
const nodes = getNodes3(sourceFile, span.start);
|
|
160616
160697
|
if (!nodes) return void 0;
|
|
160617
160698
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange31(t, sourceFile, nodes));
|
|
160618
|
-
return [createCodeFixAction(
|
|
160699
|
+
return [createCodeFixAction(fixId38, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId38, Diagnostics.Add_all_missing_async_modifiers)];
|
|
160619
160700
|
},
|
|
160620
|
-
fixIds: [
|
|
160701
|
+
fixIds: [fixId38],
|
|
160621
160702
|
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
|
|
160622
160703
|
const seen = /* @__PURE__ */ new Map();
|
|
160623
|
-
return codeFixAll(context,
|
|
160704
|
+
return codeFixAll(context, errorCodes49, (changes, diag2) => {
|
|
160624
160705
|
const nodes = getNodes3(diag2.file, diag2.start);
|
|
160625
160706
|
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
|
160626
160707
|
doChange31(changes, context.sourceFile, nodes);
|
|
@@ -160673,21 +160754,21 @@ function doChange31(changes, sourceFile, { insertBefore, returnType }) {
|
|
|
160673
160754
|
}
|
|
160674
160755
|
|
|
160675
160756
|
// src/services/codefixes/fixPropertyOverrideAccessor.ts
|
|
160676
|
-
var
|
|
160757
|
+
var errorCodes50 = [
|
|
160677
160758
|
Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property.code,
|
|
160678
160759
|
Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code
|
|
160679
160760
|
];
|
|
160680
|
-
var
|
|
160761
|
+
var fixId39 = "fixPropertyOverrideAccessor";
|
|
160681
160762
|
registerCodeFix({
|
|
160682
|
-
errorCodes:
|
|
160763
|
+
errorCodes: errorCodes50,
|
|
160683
160764
|
getCodeActions(context) {
|
|
160684
160765
|
const edits = doChange32(context.sourceFile, context.span.start, context.span.length, context.errorCode, context);
|
|
160685
160766
|
if (edits) {
|
|
160686
|
-
return [createCodeFixAction(
|
|
160767
|
+
return [createCodeFixAction(fixId39, edits, Diagnostics.Generate_get_and_set_accessors, fixId39, Diagnostics.Generate_get_and_set_accessors_for_all_overriding_properties)];
|
|
160687
160768
|
}
|
|
160688
160769
|
},
|
|
160689
|
-
fixIds: [
|
|
160690
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
160770
|
+
fixIds: [fixId39],
|
|
160771
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes50, (changes, diag2) => {
|
|
160691
160772
|
const edits = doChange32(diag2.file, diag2.start, diag2.length, diag2.code, context);
|
|
160692
160773
|
if (edits) {
|
|
160693
160774
|
for (const edit of edits) {
|
|
@@ -160723,8 +160804,8 @@ function doChange32(file, start, length2, code, context) {
|
|
|
160723
160804
|
}
|
|
160724
160805
|
|
|
160725
160806
|
// src/services/codefixes/inferFromUsage.ts
|
|
160726
|
-
var
|
|
160727
|
-
var
|
|
160807
|
+
var fixId40 = "inferFromUsage";
|
|
160808
|
+
var errorCodes51 = [
|
|
160728
160809
|
// Variable declarations
|
|
160729
160810
|
Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code,
|
|
160730
160811
|
// Variable uses
|
|
@@ -160758,7 +160839,7 @@ var errorCodes50 = [
|
|
|
160758
160839
|
Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code
|
|
160759
160840
|
];
|
|
160760
160841
|
registerCodeFix({
|
|
160761
|
-
errorCodes:
|
|
160842
|
+
errorCodes: errorCodes51,
|
|
160762
160843
|
getCodeActions(context) {
|
|
160763
160844
|
const { sourceFile, program, span: { start }, errorCode, cancellationToken, host, preferences } = context;
|
|
160764
160845
|
const token = getTokenAtPosition(sourceFile, start);
|
|
@@ -160778,13 +160859,13 @@ registerCodeFix({
|
|
|
160778
160859
|
);
|
|
160779
160860
|
});
|
|
160780
160861
|
const name = declaration && getNameOfDeclaration(declaration);
|
|
160781
|
-
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)];
|
|
160782
160863
|
},
|
|
160783
|
-
fixIds: [
|
|
160864
|
+
fixIds: [fixId40],
|
|
160784
160865
|
getAllCodeActions(context) {
|
|
160785
160866
|
const { sourceFile, program, cancellationToken, host, preferences } = context;
|
|
160786
160867
|
const markSeen = nodeSeenTracker();
|
|
160787
|
-
return codeFixAll(context,
|
|
160868
|
+
return codeFixAll(context, errorCodes51, (changes, err) => {
|
|
160788
160869
|
doChange33(changes, sourceFile, getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences);
|
|
160789
160870
|
});
|
|
160790
160871
|
}
|
|
@@ -161715,13 +161796,13 @@ function inferTypeFromReferences(program, references, cancellationToken) {
|
|
|
161715
161796
|
}
|
|
161716
161797
|
|
|
161717
161798
|
// src/services/codefixes/fixReturnTypeInAsyncFunction.ts
|
|
161718
|
-
var
|
|
161719
|
-
var
|
|
161799
|
+
var fixId41 = "fixReturnTypeInAsyncFunction";
|
|
161800
|
+
var errorCodes52 = [
|
|
161720
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
|
|
161721
161802
|
];
|
|
161722
161803
|
registerCodeFix({
|
|
161723
|
-
errorCodes:
|
|
161724
|
-
fixIds: [
|
|
161804
|
+
errorCodes: errorCodes52,
|
|
161805
|
+
fixIds: [fixId41],
|
|
161725
161806
|
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
|
|
161726
161807
|
const { sourceFile, program, span } = context;
|
|
161727
161808
|
const checker = program.getTypeChecker();
|
|
@@ -161732,14 +161813,14 @@ registerCodeFix({
|
|
|
161732
161813
|
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
|
|
161733
161814
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange34(t, sourceFile, returnTypeNode, promisedTypeNode));
|
|
161734
161815
|
return [createCodeFixAction(
|
|
161735
|
-
|
|
161816
|
+
fixId41,
|
|
161736
161817
|
changes,
|
|
161737
161818
|
[Diagnostics.Replace_0_with_Promise_1, checker.typeToString(returnType), checker.typeToString(promisedType)],
|
|
161738
|
-
|
|
161819
|
+
fixId41,
|
|
161739
161820
|
Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions
|
|
161740
161821
|
)];
|
|
161741
161822
|
},
|
|
161742
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
161823
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes52, (changes, diag2) => {
|
|
161743
161824
|
const info = getInfo16(diag2.file, context.program.getTypeChecker(), diag2.start);
|
|
161744
161825
|
if (info) {
|
|
161745
161826
|
doChange34(changes, diag2.file, info.returnTypeNode, info.promisedTypeNode);
|
|
@@ -161775,13 +161856,13 @@ function doChange34(changes, sourceFile, returnTypeNode, promisedTypeNode) {
|
|
|
161775
161856
|
|
|
161776
161857
|
// src/services/codefixes/disableJsDiagnostics.ts
|
|
161777
161858
|
var fixName4 = "disableJsDiagnostics";
|
|
161778
|
-
var
|
|
161779
|
-
var
|
|
161859
|
+
var fixId42 = "disableJsDiagnostics";
|
|
161860
|
+
var errorCodes53 = mapDefined(Object.keys(Diagnostics), (key) => {
|
|
161780
161861
|
const diag2 = Diagnostics[key];
|
|
161781
161862
|
return diag2.category === 1 /* Error */ ? diag2.code : void 0;
|
|
161782
161863
|
});
|
|
161783
161864
|
registerCodeFix({
|
|
161784
|
-
errorCodes:
|
|
161865
|
+
errorCodes: errorCodes53,
|
|
161785
161866
|
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
|
|
161786
161867
|
const { sourceFile, program, span, host, formatContext } = context;
|
|
161787
161868
|
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {
|
|
@@ -161802,21 +161883,21 @@ registerCodeFix({
|
|
|
161802
161883
|
)
|
|
161803
161884
|
];
|
|
161804
161885
|
if (ts_textChanges_exports.isValidLocationToAddComment(sourceFile, span.start)) {
|
|
161805
|
-
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));
|
|
161806
161887
|
}
|
|
161807
161888
|
return fixes;
|
|
161808
161889
|
},
|
|
161809
|
-
fixIds: [
|
|
161890
|
+
fixIds: [fixId42],
|
|
161810
161891
|
getAllCodeActions: (context) => {
|
|
161811
161892
|
const seenLines = /* @__PURE__ */ new Set();
|
|
161812
|
-
return codeFixAll(context,
|
|
161893
|
+
return codeFixAll(context, errorCodes53, (changes, diag2) => {
|
|
161813
161894
|
if (ts_textChanges_exports.isValidLocationToAddComment(diag2.file, diag2.start)) {
|
|
161814
|
-
|
|
161895
|
+
makeChange9(changes, diag2.file, diag2.start, seenLines);
|
|
161815
161896
|
}
|
|
161816
161897
|
});
|
|
161817
161898
|
}
|
|
161818
161899
|
});
|
|
161819
|
-
function
|
|
161900
|
+
function makeChange9(changes, sourceFile, position, seenLines) {
|
|
161820
161901
|
const { line: lineNumber } = getLineAndCharacterOfPosition(sourceFile, position);
|
|
161821
161902
|
if (!seenLines || tryAddToSet(seenLines, lineNumber)) {
|
|
161822
161903
|
changes.insertCommentBeforeLine(sourceFile, lineNumber, position, " @ts-ignore");
|
|
@@ -162829,9 +162910,9 @@ var fixName6 = "strictClassInitialization";
|
|
|
162829
162910
|
var fixIdAddDefiniteAssignmentAssertions = "addMissingPropertyDefiniteAssignmentAssertions";
|
|
162830
162911
|
var fixIdAddUndefinedType = "addMissingPropertyUndefinedType";
|
|
162831
162912
|
var fixIdAddInitializer = "addMissingPropertyInitializer";
|
|
162832
|
-
var
|
|
162913
|
+
var errorCodes54 = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
|
|
162833
162914
|
registerCodeFix({
|
|
162834
|
-
errorCodes:
|
|
162915
|
+
errorCodes: errorCodes54,
|
|
162835
162916
|
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
|
|
162836
162917
|
const info = getInfo17(context.sourceFile, context.span.start);
|
|
162837
162918
|
if (!info) return;
|
|
@@ -162843,7 +162924,7 @@ registerCodeFix({
|
|
|
162843
162924
|
},
|
|
162844
162925
|
fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
|
|
162845
162926
|
getAllCodeActions: (context) => {
|
|
162846
|
-
return codeFixAll(context,
|
|
162927
|
+
return codeFixAll(context, errorCodes54, (changes, diag2) => {
|
|
162847
162928
|
const info = getInfo17(diag2.file, diag2.start);
|
|
162848
162929
|
if (!info) return;
|
|
162849
162930
|
switch (context.fixId) {
|
|
@@ -162966,20 +163047,20 @@ function getDefaultValueFromType(checker, type) {
|
|
|
162966
163047
|
}
|
|
162967
163048
|
|
|
162968
163049
|
// src/services/codefixes/requireInTs.ts
|
|
162969
|
-
var
|
|
162970
|
-
var
|
|
163050
|
+
var fixId43 = "requireInTs";
|
|
163051
|
+
var errorCodes55 = [Diagnostics.require_call_may_be_converted_to_an_import.code];
|
|
162971
163052
|
registerCodeFix({
|
|
162972
|
-
errorCodes:
|
|
163053
|
+
errorCodes: errorCodes55,
|
|
162973
163054
|
getCodeActions(context) {
|
|
162974
163055
|
const info = getInfo18(context.sourceFile, context.program, context.span.start, context.preferences);
|
|
162975
163056
|
if (!info) {
|
|
162976
163057
|
return void 0;
|
|
162977
163058
|
}
|
|
162978
163059
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange35(t, context.sourceFile, info));
|
|
162979
|
-
return [createCodeFixAction(
|
|
163060
|
+
return [createCodeFixAction(fixId43, changes, Diagnostics.Convert_require_to_import, fixId43, Diagnostics.Convert_all_require_to_import)];
|
|
162980
163061
|
},
|
|
162981
|
-
fixIds: [
|
|
162982
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163062
|
+
fixIds: [fixId43],
|
|
163063
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes55, (changes, diag2) => {
|
|
162983
163064
|
const info = getInfo18(diag2.file, context.program, diag2.start, context.preferences);
|
|
162984
163065
|
if (info) {
|
|
162985
163066
|
doChange35(changes, context.sourceFile, info);
|
|
@@ -163056,19 +163137,19 @@ function tryCreateNamedImportsFromObjectBindingPattern(node) {
|
|
|
163056
163137
|
}
|
|
163057
163138
|
|
|
163058
163139
|
// src/services/codefixes/useDefaultImport.ts
|
|
163059
|
-
var
|
|
163060
|
-
var
|
|
163140
|
+
var fixId44 = "useDefaultImport";
|
|
163141
|
+
var errorCodes56 = [Diagnostics.Import_may_be_converted_to_a_default_import.code];
|
|
163061
163142
|
registerCodeFix({
|
|
163062
|
-
errorCodes:
|
|
163143
|
+
errorCodes: errorCodes56,
|
|
163063
163144
|
getCodeActions(context) {
|
|
163064
163145
|
const { sourceFile, span: { start } } = context;
|
|
163065
163146
|
const info = getInfo19(sourceFile, start);
|
|
163066
163147
|
if (!info) return void 0;
|
|
163067
163148
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange36(t, sourceFile, info, context.preferences));
|
|
163068
|
-
return [createCodeFixAction(
|
|
163149
|
+
return [createCodeFixAction(fixId44, changes, Diagnostics.Convert_to_default_import, fixId44, Diagnostics.Convert_all_to_default_imports)];
|
|
163069
163150
|
},
|
|
163070
|
-
fixIds: [
|
|
163071
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163151
|
+
fixIds: [fixId44],
|
|
163152
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes56, (changes, diag2) => {
|
|
163072
163153
|
const info = getInfo19(diag2.file, diag2.start);
|
|
163073
163154
|
if (info) doChange36(changes, diag2.file, info, context.preferences);
|
|
163074
163155
|
})
|
|
@@ -163095,24 +163176,24 @@ function doChange36(changes, sourceFile, info, preferences) {
|
|
|
163095
163176
|
}
|
|
163096
163177
|
|
|
163097
163178
|
// src/services/codefixes/useBigintLiteral.ts
|
|
163098
|
-
var
|
|
163099
|
-
var
|
|
163179
|
+
var fixId45 = "useBigintLiteral";
|
|
163180
|
+
var errorCodes57 = [
|
|
163100
163181
|
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code
|
|
163101
163182
|
];
|
|
163102
163183
|
registerCodeFix({
|
|
163103
|
-
errorCodes:
|
|
163184
|
+
errorCodes: errorCodes57,
|
|
163104
163185
|
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
|
|
163105
|
-
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));
|
|
163106
163187
|
if (changes.length > 0) {
|
|
163107
|
-
return [createCodeFixAction(
|
|
163188
|
+
return [createCodeFixAction(fixId45, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId45, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
163108
163189
|
}
|
|
163109
163190
|
},
|
|
163110
|
-
fixIds: [
|
|
163191
|
+
fixIds: [fixId45],
|
|
163111
163192
|
getAllCodeActions: (context) => {
|
|
163112
|
-
return codeFixAll(context,
|
|
163193
|
+
return codeFixAll(context, errorCodes57, (changes, diag2) => makeChange10(changes, diag2.file, diag2));
|
|
163113
163194
|
}
|
|
163114
163195
|
});
|
|
163115
|
-
function
|
|
163196
|
+
function makeChange10(changeTracker, sourceFile, span) {
|
|
163116
163197
|
const numericLiteral = tryCast(getTokenAtPosition(sourceFile, span.start), isNumericLiteral);
|
|
163117
163198
|
if (!numericLiteral) {
|
|
163118
163199
|
return;
|
|
@@ -163123,18 +163204,18 @@ function makeChange9(changeTracker, sourceFile, span) {
|
|
|
163123
163204
|
|
|
163124
163205
|
// src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts
|
|
163125
163206
|
var fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
|
|
163126
|
-
var
|
|
163127
|
-
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];
|
|
163128
163209
|
registerCodeFix({
|
|
163129
|
-
errorCodes:
|
|
163210
|
+
errorCodes: errorCodes58,
|
|
163130
163211
|
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
|
|
163131
163212
|
const { sourceFile, span } = context;
|
|
163132
163213
|
const importType = getImportTypeNode(sourceFile, span.start);
|
|
163133
163214
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange37(t, sourceFile, importType));
|
|
163134
|
-
return [createCodeFixAction(
|
|
163215
|
+
return [createCodeFixAction(fixId46, changes, Diagnostics.Add_missing_typeof, fixId46, Diagnostics.Add_missing_typeof)];
|
|
163135
163216
|
},
|
|
163136
|
-
fixIds: [
|
|
163137
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163217
|
+
fixIds: [fixId46],
|
|
163218
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => doChange37(changes, context.sourceFile, getImportTypeNode(diag2.file, diag2.start)))
|
|
163138
163219
|
});
|
|
163139
163220
|
function getImportTypeNode(sourceFile, pos) {
|
|
163140
163221
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
@@ -163157,9 +163238,9 @@ function doChange37(changes, sourceFile, importType) {
|
|
|
163157
163238
|
|
|
163158
163239
|
// src/services/codefixes/wrapJsxInFragment.ts
|
|
163159
163240
|
var fixID2 = "wrapJsxInFragment";
|
|
163160
|
-
var
|
|
163241
|
+
var errorCodes59 = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
|
|
163161
163242
|
registerCodeFix({
|
|
163162
|
-
errorCodes:
|
|
163243
|
+
errorCodes: errorCodes59,
|
|
163163
163244
|
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
|
|
163164
163245
|
const { sourceFile, span } = context;
|
|
163165
163246
|
const node = findNodeToFix(sourceFile, span.start);
|
|
@@ -163168,7 +163249,7 @@ registerCodeFix({
|
|
|
163168
163249
|
return [createCodeFixAction(fixID2, changes, Diagnostics.Wrap_in_JSX_fragment, fixID2, Diagnostics.Wrap_all_unparented_JSX_in_JSX_fragment)];
|
|
163169
163250
|
},
|
|
163170
163251
|
fixIds: [fixID2],
|
|
163171
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163252
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
|
|
163172
163253
|
const node = findNodeToFix(context.sourceFile, diag2.start);
|
|
163173
163254
|
if (!node) return void 0;
|
|
163174
163255
|
doChange38(changes, context.sourceFile, node);
|
|
@@ -163207,18 +163288,18 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
163207
163288
|
}
|
|
163208
163289
|
|
|
163209
163290
|
// src/services/codefixes/wrapDecoratorInParentheses.ts
|
|
163210
|
-
var
|
|
163211
|
-
var
|
|
163291
|
+
var fixId47 = "wrapDecoratorInParentheses";
|
|
163292
|
+
var errorCodes60 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
|
|
163212
163293
|
registerCodeFix({
|
|
163213
|
-
errorCodes:
|
|
163294
|
+
errorCodes: errorCodes60,
|
|
163214
163295
|
getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
|
|
163215
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
163216
|
-
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)];
|
|
163217
163298
|
},
|
|
163218
|
-
fixIds: [
|
|
163219
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163299
|
+
fixIds: [fixId47],
|
|
163300
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes60, (changes, diag2) => makeChange11(changes, diag2.file, diag2.start))
|
|
163220
163301
|
});
|
|
163221
|
-
function
|
|
163302
|
+
function makeChange11(changeTracker, sourceFile, pos) {
|
|
163222
163303
|
const token = getTokenAtPosition(sourceFile, pos);
|
|
163223
163304
|
const decorator = findAncestor(token, isDecorator);
|
|
163224
163305
|
Debug.assert(!!decorator, "Expected position to be owned by a decorator.");
|
|
@@ -163227,20 +163308,20 @@ function makeChange10(changeTracker, sourceFile, pos) {
|
|
|
163227
163308
|
}
|
|
163228
163309
|
|
|
163229
163310
|
// src/services/codefixes/convertToMappedObjectType.ts
|
|
163230
|
-
var
|
|
163231
|
-
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];
|
|
163232
163313
|
registerCodeFix({
|
|
163233
|
-
errorCodes:
|
|
163314
|
+
errorCodes: errorCodes61,
|
|
163234
163315
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
163235
163316
|
const { sourceFile, span } = context;
|
|
163236
163317
|
const info = getInfo20(sourceFile, span.start);
|
|
163237
163318
|
if (!info) return void 0;
|
|
163238
163319
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
163239
163320
|
const name = idText(info.container.name);
|
|
163240
|
-
return [createCodeFixAction(
|
|
163321
|
+
return [createCodeFixAction(fixId48, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId48, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
163241
163322
|
},
|
|
163242
|
-
fixIds: [
|
|
163243
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163323
|
+
fixIds: [fixId48],
|
|
163324
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes61, (changes, diag2) => {
|
|
163244
163325
|
const info = getInfo20(diag2.file, diag2.start);
|
|
163245
163326
|
if (info) doChange39(changes, diag2.file, info);
|
|
163246
163327
|
})
|
|
@@ -163285,12 +163366,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
|
163285
163366
|
}
|
|
163286
163367
|
|
|
163287
163368
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
163288
|
-
var
|
|
163289
|
-
var
|
|
163369
|
+
var fixId49 = "removeAccidentalCallParentheses";
|
|
163370
|
+
var errorCodes62 = [
|
|
163290
163371
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
163291
163372
|
];
|
|
163292
163373
|
registerCodeFix({
|
|
163293
|
-
errorCodes:
|
|
163374
|
+
errorCodes: errorCodes62,
|
|
163294
163375
|
getCodeActions(context) {
|
|
163295
163376
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
163296
163377
|
if (!callExpression) {
|
|
@@ -163299,30 +163380,30 @@ registerCodeFix({
|
|
|
163299
163380
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
163300
163381
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
163301
163382
|
});
|
|
163302
|
-
return [createCodeFixActionWithoutFixAll(
|
|
163383
|
+
return [createCodeFixActionWithoutFixAll(fixId49, changes, Diagnostics.Remove_parentheses)];
|
|
163303
163384
|
},
|
|
163304
|
-
fixIds: [
|
|
163385
|
+
fixIds: [fixId49]
|
|
163305
163386
|
});
|
|
163306
163387
|
|
|
163307
163388
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
163308
|
-
var
|
|
163309
|
-
var
|
|
163389
|
+
var fixId50 = "removeUnnecessaryAwait";
|
|
163390
|
+
var errorCodes63 = [
|
|
163310
163391
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
163311
163392
|
];
|
|
163312
163393
|
registerCodeFix({
|
|
163313
|
-
errorCodes:
|
|
163394
|
+
errorCodes: errorCodes63,
|
|
163314
163395
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
163315
|
-
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));
|
|
163316
163397
|
if (changes.length > 0) {
|
|
163317
|
-
return [createCodeFixAction(
|
|
163398
|
+
return [createCodeFixAction(fixId50, changes, Diagnostics.Remove_unnecessary_await, fixId50, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
163318
163399
|
}
|
|
163319
163400
|
},
|
|
163320
|
-
fixIds: [
|
|
163401
|
+
fixIds: [fixId50],
|
|
163321
163402
|
getAllCodeActions: (context) => {
|
|
163322
|
-
return codeFixAll(context,
|
|
163403
|
+
return codeFixAll(context, errorCodes63, (changes, diag2) => makeChange12(changes, diag2.file, diag2));
|
|
163323
163404
|
}
|
|
163324
163405
|
});
|
|
163325
|
-
function
|
|
163406
|
+
function makeChange12(changeTracker, sourceFile, span) {
|
|
163326
163407
|
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === 135 /* AwaitKeyword */);
|
|
163327
163408
|
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
163328
163409
|
if (!awaitExpression) {
|
|
@@ -163347,20 +163428,20 @@ function makeChange11(changeTracker, sourceFile, span) {
|
|
|
163347
163428
|
}
|
|
163348
163429
|
|
|
163349
163430
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
163350
|
-
var
|
|
163351
|
-
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";
|
|
163352
163433
|
registerCodeFix({
|
|
163353
|
-
errorCodes:
|
|
163354
|
-
fixIds: [
|
|
163434
|
+
errorCodes: errorCodes64,
|
|
163435
|
+
fixIds: [fixId51],
|
|
163355
163436
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
163356
163437
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
163357
163438
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
163358
163439
|
});
|
|
163359
163440
|
if (changes.length) {
|
|
163360
|
-
return [createCodeFixAction(
|
|
163441
|
+
return [createCodeFixAction(fixId51, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId51, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
163361
163442
|
}
|
|
163362
163443
|
},
|
|
163363
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163444
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, error2) => {
|
|
163364
163445
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
163365
163446
|
})
|
|
163366
163447
|
});
|
|
@@ -163409,22 +163490,22 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
163409
163490
|
}
|
|
163410
163491
|
|
|
163411
163492
|
// src/services/codefixes/convertConstToLet.ts
|
|
163412
|
-
var
|
|
163413
|
-
var
|
|
163493
|
+
var fixId52 = "fixConvertConstToLet";
|
|
163494
|
+
var errorCodes65 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
163414
163495
|
registerCodeFix({
|
|
163415
|
-
errorCodes:
|
|
163496
|
+
errorCodes: errorCodes65,
|
|
163416
163497
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
163417
163498
|
const { sourceFile, span, program } = context;
|
|
163418
163499
|
const info = getInfo21(sourceFile, span.start, program);
|
|
163419
163500
|
if (info === void 0) return;
|
|
163420
163501
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
163421
|
-
return [createCodeFixActionMaybeFixAll(
|
|
163502
|
+
return [createCodeFixActionMaybeFixAll(fixId52, changes, Diagnostics.Convert_const_to_let, fixId52, Diagnostics.Convert_all_const_to_let)];
|
|
163422
163503
|
},
|
|
163423
163504
|
getAllCodeActions: (context) => {
|
|
163424
163505
|
const { program } = context;
|
|
163425
163506
|
const seen = /* @__PURE__ */ new Map();
|
|
163426
163507
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
163427
|
-
eachDiagnostic(context,
|
|
163508
|
+
eachDiagnostic(context, errorCodes65, (diag2) => {
|
|
163428
163509
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
163429
163510
|
if (info) {
|
|
163430
163511
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
@@ -163435,7 +163516,7 @@ registerCodeFix({
|
|
|
163435
163516
|
});
|
|
163436
163517
|
}));
|
|
163437
163518
|
},
|
|
163438
|
-
fixIds: [
|
|
163519
|
+
fixIds: [fixId52]
|
|
163439
163520
|
});
|
|
163440
163521
|
function getInfo21(sourceFile, pos, program) {
|
|
163441
163522
|
var _a;
|
|
@@ -163453,26 +163534,26 @@ function doChange40(changes, sourceFile, token) {
|
|
|
163453
163534
|
}
|
|
163454
163535
|
|
|
163455
163536
|
// src/services/codefixes/fixExpectedComma.ts
|
|
163456
|
-
var
|
|
163537
|
+
var fixId53 = "fixExpectedComma";
|
|
163457
163538
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
163458
|
-
var
|
|
163539
|
+
var errorCodes66 = [expectedErrorCode];
|
|
163459
163540
|
registerCodeFix({
|
|
163460
|
-
errorCodes:
|
|
163541
|
+
errorCodes: errorCodes66,
|
|
163461
163542
|
getCodeActions(context) {
|
|
163462
163543
|
const { sourceFile } = context;
|
|
163463
163544
|
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
163464
163545
|
if (!info) return void 0;
|
|
163465
163546
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
163466
163547
|
return [createCodeFixAction(
|
|
163467
|
-
|
|
163548
|
+
fixId53,
|
|
163468
163549
|
changes,
|
|
163469
163550
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
163470
|
-
|
|
163551
|
+
fixId53,
|
|
163471
163552
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
163472
163553
|
)];
|
|
163473
163554
|
},
|
|
163474
|
-
fixIds: [
|
|
163475
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
163555
|
+
fixIds: [fixId53],
|
|
163556
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes66, (changes, diag2) => {
|
|
163476
163557
|
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
163477
163558
|
if (info) doChange41(changes, context.sourceFile, info);
|
|
163478
163559
|
})
|
|
@@ -163488,25 +163569,25 @@ function doChange41(changes, sourceFile, { node }) {
|
|
|
163488
163569
|
|
|
163489
163570
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
163490
163571
|
var fixName7 = "addVoidToPromise";
|
|
163491
|
-
var
|
|
163492
|
-
var
|
|
163572
|
+
var fixId54 = "addVoidToPromise";
|
|
163573
|
+
var errorCodes67 = [
|
|
163493
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,
|
|
163494
163575
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
163495
163576
|
];
|
|
163496
163577
|
registerCodeFix({
|
|
163497
|
-
errorCodes:
|
|
163498
|
-
fixIds: [
|
|
163578
|
+
errorCodes: errorCodes67,
|
|
163579
|
+
fixIds: [fixId54],
|
|
163499
163580
|
getCodeActions(context) {
|
|
163500
|
-
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));
|
|
163501
163582
|
if (changes.length > 0) {
|
|
163502
|
-
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)];
|
|
163503
163584
|
}
|
|
163504
163585
|
},
|
|
163505
163586
|
getAllCodeActions(context) {
|
|
163506
|
-
return codeFixAll(context,
|
|
163587
|
+
return codeFixAll(context, errorCodes67, (changes, diag2) => makeChange13(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
163507
163588
|
}
|
|
163508
163589
|
});
|
|
163509
|
-
function
|
|
163590
|
+
function makeChange13(changes, sourceFile, span, program, seen) {
|
|
163510
163591
|
const node = getTokenAtPosition(sourceFile, span.start);
|
|
163511
163592
|
if (!isIdentifier(node) || !isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0) return;
|
|
163512
163593
|
const checker = program.getTypeChecker();
|
|
@@ -179581,10 +179662,10 @@ __export(ts_PasteEdits_exports, {
|
|
|
179581
179662
|
});
|
|
179582
179663
|
|
|
179583
179664
|
// src/services/pasteEdits.ts
|
|
179584
|
-
var
|
|
179665
|
+
var fixId55 = "providePostPasteEdits";
|
|
179585
179666
|
function pasteEditsProvider(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken) {
|
|
179586
179667
|
const changes = ts_textChanges_exports.ChangeTracker.with({ host, formatContext, preferences }, (changeTracker) => pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changeTracker));
|
|
179587
|
-
return { edits: changes, fixId:
|
|
179668
|
+
return { edits: changes, fixId: fixId55 };
|
|
179588
179669
|
}
|
|
179589
179670
|
function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changes) {
|
|
179590
179671
|
let actualPastedText;
|
|
@@ -192537,10 +192618,10 @@ ${e.message}`;
|
|
|
192537
192618
|
}
|
|
192538
192619
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
192539
192620
|
}
|
|
192540
|
-
getCombinedCodeFix({ scope, fixId:
|
|
192621
|
+
getCombinedCodeFix({ scope, fixId: fixId56 }, simplifiedResult) {
|
|
192541
192622
|
Debug.assert(scope.type === "file");
|
|
192542
192623
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
192543
|
-
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));
|
|
192544
192625
|
if (simplifiedResult) {
|
|
192545
192626
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
192546
192627
|
} else {
|
|
@@ -192579,11 +192660,11 @@ ${e.message}`;
|
|
|
192579
192660
|
mapCodeAction({ description: description3, changes, commands }) {
|
|
192580
192661
|
return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
192581
192662
|
}
|
|
192582
|
-
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId:
|
|
192583
|
-
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 };
|
|
192584
192665
|
}
|
|
192585
|
-
mapPasteEditsAction({ edits, fixId:
|
|
192586
|
-
return { edits: this.mapTextChangesToCodeEdits(edits), fixId:
|
|
192666
|
+
mapPasteEditsAction({ edits, fixId: fixId56 }) {
|
|
192667
|
+
return { edits: this.mapTextChangesToCodeEdits(edits), fixId: fixId56 };
|
|
192587
192668
|
}
|
|
192588
192669
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
192589
192670
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|