Skip to content

Commit 3166ef3

Browse files
author
Andy Hanson
committed
Remove InfoBase
1 parent c0e3731 commit 3166ef3

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/services/codefixes/fixAddMissingMember.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ts.codefix {
1212
const info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker());
1313
if (!info) return undefined;
1414

15-
if (info.kind === InfoKind.enum) {
15+
if (info.kind === InfoKind.Enum) {
1616
const { token, parentDeclaration } = info;
1717
const changes = textChanges.ChangeTracker.with(context, t => addEnumMemberDeclaration(t, context.program.getTypeChecker(), token, parentDeclaration));
1818
return [createCodeFixAction(fixName, changes, [Diagnostics.Add_missing_enum_member_0, token.text], fixId, Diagnostics.Add_all_missing_members)];
@@ -39,7 +39,7 @@ namespace ts.codefix {
3939
return;
4040
}
4141

42-
if (info.kind === InfoKind.enum) {
42+
if (info.kind === InfoKind.Enum) {
4343
const { token, parentDeclaration } = info;
4444
addEnumMemberDeclaration(changes, checker, token, parentDeclaration);
4545
}
@@ -93,18 +93,15 @@ namespace ts.codefix {
9393
}
9494

9595
type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration;
96-
interface InfoBase {
97-
readonly kind: InfoKind;
96+
const enum InfoKind { Enum, ClassOrInterface }
97+
interface EnumInfo {
98+
readonly kind: InfoKind.Enum;
9899
readonly token: Identifier;
99-
readonly parentDeclaration: EnumDeclaration | ClassOrInterface;
100-
}
101-
enum InfoKind { enum, class }
102-
interface EnumInfo extends InfoBase {
103-
readonly kind: InfoKind.enum;
104100
readonly parentDeclaration: EnumDeclaration;
105101
}
106-
interface ClassOrInterfaceInfo extends InfoBase {
107-
readonly kind: InfoKind.class;
102+
interface ClassOrInterfaceInfo {
103+
readonly kind: InfoKind.ClassOrInterface;
104+
readonly token: Identifier;
108105
readonly parentDeclaration: ClassOrInterface;
109106
readonly makeStatic: boolean;
110107
readonly declSourceFile: SourceFile;
@@ -136,11 +133,11 @@ namespace ts.codefix {
136133
const declSourceFile = classOrInterface.getSourceFile();
137134
const inJs = isSourceFileJavaScript(declSourceFile);
138135
const call = tryCast(parent.parent, isCallExpression);
139-
return { kind: InfoKind.class, token, parentDeclaration: classOrInterface, makeStatic, declSourceFile, inJs, call };
136+
return { kind: InfoKind.ClassOrInterface, token, parentDeclaration: classOrInterface, makeStatic, declSourceFile, inJs, call };
140137
}
141138
const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
142139
if (enumDeclaration) {
143-
return { kind: InfoKind.enum, token, parentDeclaration: enumDeclaration };
140+
return { kind: InfoKind.Enum, token, parentDeclaration: enumDeclaration };
144141
}
145142
return undefined;
146143
}

0 commit comments

Comments
 (0)