Skip to content

Commit 4b02617

Browse files
DanielRosenwassermprobst
authored andcommitted
Add function names for code fixes. (microsoft#46728)
* Add function names for code fixes. * Remove double space. * Undo CRLF -> LF change.
1 parent 5102b4c commit 4b02617

30 files changed

+34
-35
lines changed

src/services/codefixes/addConvertToUnknownForNonOverlappingTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: (context) => {
7+
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
88
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
99
return [createCodeFixAction(fixId, changes, Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
1010
},

src/services/codefixes/addEmptyExportDeclaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts.codefix {
55
Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code,
66
Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code,
77
],
8-
getCodeActions: context => {
8+
getCodeActions: function getCodeActionsToAddEmptyExportDeclaration(context) {
99
const { sourceFile } = context;
1010
const changes = textChanges.ChangeTracker.with(context, changes => {
1111
const exportDeclaration = factory.createExportDeclaration(

src/services/codefixes/addMissingAsync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ts.codefix {
1111
registerCodeFix({
1212
fixIds: [fixId],
1313
errorCodes,
14-
getCodeActions: context => {
14+
getCodeActions: function getCodeActionsToAddMissingAsync(context) {
1515
const { sourceFile, errorCode, cancellationToken, program, span } = context;
1616
const diagnostic = find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode));
1717
const directSpan = diagnostic && diagnostic.relatedInformation && find(diagnostic.relatedInformation, r => r.code === Diagnostics.Did_you_mean_to_mark_this_function_as_async.code) as TextSpan | undefined;

src/services/codefixes/addMissingAwait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace ts.codefix {
3030
registerCodeFix({
3131
fixIds: [fixId],
3232
errorCodes,
33-
getCodeActions: context => {
33+
getCodeActions: function getCodeActionsToAddMissingAwait(context) {
3434
const { sourceFile, errorCode, span, cancellationToken, program } = context;
3535
const expression = getAwaitErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program);
3636
if (!expression) {

src/services/codefixes/addMissingConst.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ts.codefix {
88

99
registerCodeFix({
1010
errorCodes,
11-
getCodeActions: (context) => {
11+
getCodeActions: function getCodeActionsToAddMissingConst(context) {
1212
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start, context.program));
1313
if (changes.length > 0) {
1414
return [createCodeFixAction(fixId, changes, Diagnostics.Add_const_to_unresolved_variable, fixId, Diagnostics.Add_const_to_all_unresolved_variables)];

src/services/codefixes/addMissingDeclareProperty.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ts.codefix {
77

88
registerCodeFix({
99
errorCodes,
10-
getCodeActions: (context) => {
10+
getCodeActions: function getCodeActionsToAddMissingDeclareOnProperty(context) {
1111
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
1212
if (changes.length > 0) {
1313
return [createCodeFixAction(fixId, changes, Diagnostics.Prefix_with_declare, fixId, Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)];

src/services/codefixes/addMissingInvocationForDecorator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics._0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: (context) => {
7+
getCodeActions: function getCodeActionsToAddMissingInvocationForDecorator(context) {
88
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
99
return [createCodeFixAction(fixId, changes, Diagnostics.Call_decorator_expression, fixId, Diagnostics.Add_to_all_uncalled_decorators)];
1010
},

src/services/codefixes/addNameToNamelessParameter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: (context) => {
7+
getCodeActions: function getCodeActionsToAddNameToNamelessParameter(context) {
88
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
99
return [createCodeFixAction(fixId, changes, Diagnostics.Add_parameter_name, fixId, Diagnostics.Add_names_to_all_parameters_without_names)];
1010
},

src/services/codefixes/convertConstToLet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts.codefix {
55

66
registerCodeFix({
77
errorCodes,
8-
getCodeActions: context => {
8+
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
99
const { sourceFile, span, program } = context;
1010
const range = getConstTokenRange(sourceFile, span.start, program);
1111
if (range === undefined) return;

src/services/codefixes/convertLiteralTypeToMappedType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts.codefix {
55

66
registerCodeFix({
77
errorCodes,
8-
getCodeActions: context => {
8+
getCodeActions: function getCodeActionsToConvertLiteralTypeToMappedType(context) {
99
const { sourceFile, span } = context;
1010
const info = getInfo(sourceFile, span.start);
1111
if (!info) {

src/services/codefixes/convertToMappedObjectType.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/* @internal */
22
namespace ts.codefix {
3-
const fixIdAddMissingTypeof = "fixConvertToMappedObjectType";
4-
const fixId = fixIdAddMissingTypeof;
3+
const fixId = "fixConvertToMappedObjectType";
54
const errorCodes = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
65

76
type FixableDeclaration = InterfaceDeclaration | TypeAliasDeclaration;
87

98
registerCodeFix({
109
errorCodes,
11-
getCodeActions: context => {
10+
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
1211
const { sourceFile, span } = context;
1312
const info = getInfo(sourceFile, span.start);
1413
if (!info) return undefined;

src/services/codefixes/convertToTypeOnlyExport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ namespace ts.codefix {
44
const fixId = "convertToTypeOnlyExport";
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: context => {
7+
getCodeActions: function getCodeActionsToConvertToTypeOnlyExport(context) {
88
const changes = textChanges.ChangeTracker.with(context, t => fixSingleExportDeclaration(t, getExportSpecifierForDiagnosticSpan(context.span, context.sourceFile), context));
99
if (changes.length) {
1010
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_type_only_export, fixId, Diagnostics.Convert_all_re_exported_types_to_type_only_exports)];
1111
}
1212
},
1313
fixIds: [fixId],
14-
getAllCodeActions: context => {
14+
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyExport(context) {
1515
const fixedExportDeclarations = new Map<number, true>();
1616
return codeFixAll(context, errorCodes, (changes, diag) => {
1717
const exportSpecifier = getExportSpecifierForDiagnosticSpan(diag, context.sourceFile);

src/services/codefixes/convertToTypeOnlyImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const fixId = "convertToTypeOnlyImport";
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: context => {
7+
getCodeActions: function getCodeActionsToConvertToTypeOnlyImport(context) {
88
const changes = textChanges.ChangeTracker.with(context, t => {
99
const importDeclaration = getImportDeclarationForDiagnosticSpan(context.span, context.sourceFile);
1010
fixSingleImportDeclaration(t, importDeclaration, context);
@@ -14,7 +14,7 @@ namespace ts.codefix {
1414
}
1515
},
1616
fixIds: [fixId],
17-
getAllCodeActions: context => {
17+
getAllCodeActions: function getAllCodeActionsToConvertToTypeOnlyImport(context) {
1818
return codeFixAll(context, errorCodes, (changes, diag) => {
1919
const importDeclaration = getImportDeclarationForDiagnosticSpan(diag, context.sourceFile);
2020
fixSingleImportDeclaration(changes, importDeclaration, context);

src/services/codefixes/disableJsDiagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ts.codefix {
99

1010
registerCodeFix({
1111
errorCodes,
12-
getCodeActions(context) {
12+
getCodeActions: function getCodeActionsToDisableJsDiagnostics(context) {
1313
const { sourceFile, program, span, host, formatContext } = context;
1414

1515
if (!isInJSFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) {

src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ts.codefix {
66

77
registerCodeFix({
88
errorCodes,
9-
getCodeActions: context => {
9+
getCodeActions: function getCodeActionsToAddMissingTypeof(context) {
1010
const { sourceFile, span } = context;
1111
const importType = getImportTypeNode(sourceFile, span.start);
1212
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, importType));

src/services/codefixes/fixAwaitInSyncFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts.codefix {
1515
return [createCodeFixAction(fixId, changes, Diagnostics.Add_async_modifier_to_containing_function, fixId, Diagnostics.Add_all_missing_async_modifiers)];
1616
},
1717
fixIds: [fixId],
18-
getAllCodeActions: context => {
18+
getAllCodeActions: function getAllCodeActionsToFixAwaitInSyncFunction(context) {
1919
const seen = new Map<number, true>();
2020
return codeFixAll(context, errorCodes, (changes, diag) => {
2121
const nodes = getNodes(diag.file, diag.start);

src/services/codefixes/fixCannotFindModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ts.codefix {
1010
];
1111
registerCodeFix({
1212
errorCodes,
13-
getCodeActions: context => {
13+
getCodeActions: function getCodeActionsToFixNotFoundModule(context) {
1414
const { host, sourceFile, span: { start } } = context;
1515
const packageName = tryGetImportedPackageName(sourceFile, start);
1616
if (packageName === undefined) return undefined;

src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ namespace ts.codefix {
77
const fixId = "fixClassDoesntImplementInheritedAbstractMember";
88
registerCodeFix({
99
errorCodes,
10-
getCodeActions(context) {
10+
getCodeActions: function getCodeActionsToFixClassNotImplementingInheritedMembers(context) {
1111
const { sourceFile, span } = context;
1212
const changes = textChanges.ChangeTracker.with(context, t =>
1313
addMissingMembers(getClass(sourceFile, span.start), sourceFile, context, t, context.preferences));
1414
return changes.length === 0 ? undefined : [createCodeFixAction(fixId, changes, Diagnostics.Implement_inherited_abstract_class, fixId, Diagnostics.Implement_all_inherited_abstract_classes)];
1515
},
1616
fixIds: [fixId],
17-
getAllCodeActions: context => {
17+
getAllCodeActions: function getAllCodeActionsToFixClassDoesntImplementInheritedAbstractMember(context) {
1818
const seenClassDeclarations = new Map<number, true>();
1919
return codeFixAll(context, errorCodes, (changes, diag) => {
2020
const classDeclaration = getClass(diag.file, diag.start);

src/services/codefixes/fixEnableExperimentalDecorators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ts.codefix {
66
];
77
registerCodeFix({
88
errorCodes,
9-
getCodeActions: (context) => {
9+
getCodeActions: function getCodeActionsToEnableExperimentalDecorators(context) {
1010
const { configFile } = context.program.getCompilerOptions();
1111
if (configFile === undefined) {
1212
return undefined;

src/services/codefixes/fixEnableJsxFlag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: context => {
7+
getCodeActions: function getCodeActionsToFixEnableJsxFlag(context) {
88
const { configFile } = context.program.getCompilerOptions();
99
if (configFile === undefined) {
1010
return undefined;

src/services/codefixes/fixIncorrectNamedTupleSyntax.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ts.codefix {
88

99
registerCodeFix({
1010
errorCodes,
11-
getCodeActions: context => {
11+
getCodeActions: function getCodeActionsToFixIncorrectNamedTupleSyntax(context) {
1212
const { sourceFile, span } = context;
1313
const namedTupleMember = getNamedTupleMember(sourceFile, span.start);
1414
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, namedTupleMember));

src/services/codefixes/fixModuleAndTargetOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts.codefix {
55
Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
66
Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code,
77
],
8-
getCodeActions: context => {
8+
getCodeActions: function getCodeActionsToFixModuleAndTarget(context) {
99
const compilerOptions = context.program.getCompilerOptions();
1010
const { configFile } = compilerOptions;
1111
if (configFile === undefined) {

src/services/codefixes/fixOverrideModifier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace ts.codefix {
8585

8686
registerCodeFix({
8787
errorCodes,
88-
getCodeActions: context => {
88+
getCodeActions: function getCodeActionsToFixOverrideModifierIssues(context) {
8989
const { errorCode, span } = context;
9090

9191
const info = errorCodeFixIdMap[errorCode];

src/services/codefixes/fixReturnTypeInAsyncFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts.codefix {
1515
registerCodeFix({
1616
errorCodes,
1717
fixIds: [fixId],
18-
getCodeActions: context => {
18+
getCodeActions: function getCodeActionsToFixReturnTypeInAsyncFunction(context) {
1919
const { sourceFile, program, span } = context;
2020
const checker = program.getTypeChecker();
2121
const info = getInfo(sourceFile, program.getTypeChecker(), span.start);

src/services/codefixes/fixStrictClassInitialization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ts.codefix {
77
const errorCodes = [Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor.code];
88
registerCodeFix({
99
errorCodes,
10-
getCodeActions: (context) => {
10+
getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
1111
const propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
1212
if (!propertyDeclaration) return;
1313

src/services/codefixes/removeUnnecessaryAwait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ts.codefix {
77

88
registerCodeFix({
99
errorCodes,
10-
getCodeActions: (context) => {
10+
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
1111
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
1212
if (changes.length > 0) {
1313
return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unnecessary_await, fixId, Diagnostics.Remove_all_unnecessary_uses_of_await)];

src/services/codefixes/returnValueCorrect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace ts.codefix {
3636
registerCodeFix({
3737
errorCodes,
3838
fixIds: [fixIdAddReturnStatement, fixRemoveBracesFromArrowFunctionBody, fixIdWrapTheBlockWithParen],
39-
getCodeActions: context => {
39+
getCodeActions: function getCodeActionsToCorrectReturnValue(context) {
4040
const { program, sourceFile, span: { start }, errorCode } = context;
4141
const info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode);
4242
if (!info) return undefined;

src/services/codefixes/splitTypeOnlyImport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ts.codefix {
55
registerCodeFix({
66
errorCodes,
77
fixIds: [fixId],
8-
getCodeActions: context => {
8+
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
99
const changes = textChanges.ChangeTracker.with(context, t => {
1010
return splitTypeOnlyImport(t, getImportDeclaration(context.sourceFile, context.span), context);
1111
});

src/services/codefixes/useBigintLiteral.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ts.codefix {
77

88
registerCodeFix({
99
errorCodes,
10-
getCodeActions: context => {
10+
getCodeActions: function getCodeActionsToUseBigintLiteral(context) {
1111
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
1212
if (changes.length > 0) {
1313
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, Diagnostics.Convert_all_to_bigint_numeric_literals)];

src/services/codefixes/wrapJsxInFragment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts.codefix {
44
const errorCodes = [Diagnostics.JSX_expressions_must_have_one_parent_element.code];
55
registerCodeFix({
66
errorCodes,
7-
getCodeActions: context => {
7+
getCodeActions: function getCodeActionsToWrapJsxInFragment(context) {
88
const { sourceFile, span } = context;
99
const node = findNodeToFix(sourceFile, span.start);
1010
if (!node) return undefined;

0 commit comments

Comments
 (0)