Skip to content

Commit 2fa27ff

Browse files
author
Andy Hanson
committed
Combine code-fix-all for missing class member and missing enum member
1 parent 18e3f48 commit 2fa27ff

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4450,9 +4450,5 @@
44504450
"Add missing enum member '{0}'": {
44514451
"category": "Message",
44524452
"code": 95063
4453-
},
4454-
"Add all missing enum members": {
4455-
"category": "Message",
4456-
"code": 95064
44574453
}
44584454
}

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace ts.codefix {
1515
if (info.kind === InfoKind.enum) {
1616
const { token, enumDeclaration } = info;
1717
const changes = textChanges.ChangeTracker.with(context, t => addEnumMemberDeclaration(t, context.program.getTypeChecker(), token, enumDeclaration));
18-
return singleElementArray(createCodeFixAction(fixName, changes, [Diagnostics.Add_missing_enum_member_0, token.text], fixId, Diagnostics.Add_all_missing_enum_members));
18+
return [createCodeFixAction(fixName, changes, [Diagnostics.Add_missing_enum_member_0, token.text], fixId, Diagnostics.Add_all_missing_members)];
1919
}
2020
const { classDeclaration, classDeclarationSourceFile, inJs, makeStatic, token, call } = info;
2121
const methodCodeAction = call && getActionForMethodDeclaration(context, classDeclarationSourceFile, classDeclaration, token, call, makeStatic, inJs, context.preferences);

tests/cases/fourslash/codeFixAddMissingMember_all.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
//// this.x = "";
88
//// }
99
////}
10+
////
11+
////enum E {}
12+
////E.A;
1013

1114
verify.codeFixAll({
1215
fixId: "addMissingMember",
@@ -22,5 +25,10 @@ verify.codeFixAll({
2225
y(): any {
2326
throw new Error("Method not implemented.");
2427
}
25-
}`,
28+
}
29+
30+
enum E {
31+
A
32+
}
33+
E.A;`,
2634
});

0 commit comments

Comments
 (0)