feat: add type to exporter generic param

main
spacemeowx2 2022-10-22 19:17:27 +08:00
parent 1f16903aa1
commit ec1e56e945
2 changed files with 9 additions and 1 deletions

View File

@ -85,6 +85,7 @@ class BattleFetcher {
if (!group) { if (!group) {
return { return {
type: "VsBattle",
challengeProgress: null, challengeProgress: null,
bankaraMatchChallenge: null, bankaraMatchChallenge: null,
listNode: null, listNode: null,
@ -112,6 +113,7 @@ class BattleFetcher {
} }
return { return {
type: "VsBattle",
bankaraMatchChallenge, bankaraMatchChallenge,
listNode, listNode,
challengeProgress, challengeProgress,

View File

@ -97,6 +97,7 @@ export type ChallengeProgress = {
}; };
// With challenge info // With challenge info
export type VsBattle = { export type VsBattle = {
type: "VsBattle";
listNode: null | BattleListNode; listNode: null | BattleListNode;
bankaraMatchChallenge: null | BankaraMatchChallenge; bankaraMatchChallenge: null | BankaraMatchChallenge;
challengeProgress: null | ChallengeProgress; challengeProgress: null | ChallengeProgress;
@ -138,7 +139,12 @@ export type VsHistoryDetail = {
duration: number; duration: number;
}; };
export type BattleExporter<D> = { export type BattleExporter<
D extends {
// type is seful when you implement more than one BattleExporter on the same class
type: string;
},
> = {
name: string; name: string;
notExported: (list: string[]) => Promise<string[]>; notExported: (list: string[]) => Promise<string[]>;
exportBattle: (detail: D) => Promise<void>; exportBattle: (detail: D) => Promise<void>;