diff --git a/src/compute-pr-actions.ts b/src/compute-pr-actions.ts index e8132fb81..c62192dc9 100644 --- a/src/compute-pr-actions.ts +++ b/src/compute-pr-actions.ts @@ -48,13 +48,24 @@ export const LabelNames = [ ...StalenessKinds, ] as const; -export interface Actions { - projectColumn?: ColumnName | "*REMOVE*"; +export type Actions = { labels: LabelName[]; responseComments: Comments.Comment[]; - state?: "close" | "merge"; shouldUpdateLabels: boolean; -} +} & ( + | { + state?: never; + projectColumn?: ColumnName | "*REMOVE*"; + } + | { + state: "close"; + projectColumn: "*REMOVE*"; + } + | { + state: "merge"; + projectColumn: "Recently Merged"; + } +); function createDefaultActions(): Actions { return { @@ -65,14 +76,6 @@ function createDefaultActions(): Actions { }; } -function createEmptyActions(): Actions { - return { - labels: [], - responseComments: [], - shouldUpdateLabels: false, - }; -} - type Staleness = { readonly kind: StalenessKind; readonly days: number; @@ -223,7 +226,9 @@ export function process(prInfo: BotResult, extendedCallback: (info: ExtendedPrInfo) => void = _i => {}): Actions { if (prInfo.type === "remove") { return { - ...createEmptyActions(), + labels: [], + responseComments: [], + shouldUpdateLabels: false, projectColumn: prInfo.isDraft ? "Needs Author Action" : "*REMOVE*", }; }