From ec1e56e945ab4caba90a5a5fab230efde3a0d405 Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Sat, 22 Oct 2022 19:17:27 +0800 Subject: [PATCH] feat: add type to exporter generic param --- src/app.ts | 2 ++ src/types.ts | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index 64a1247..02088a1 100644 --- a/src/app.ts +++ b/src/app.ts @@ -85,6 +85,7 @@ class BattleFetcher { if (!group) { return { + type: "VsBattle", challengeProgress: null, bankaraMatchChallenge: null, listNode: null, @@ -112,6 +113,7 @@ class BattleFetcher { } return { + type: "VsBattle", bankaraMatchChallenge, listNode, challengeProgress, diff --git a/src/types.ts b/src/types.ts index a2fb8cf..5deee1e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -97,6 +97,7 @@ export type ChallengeProgress = { }; // With challenge info export type VsBattle = { + type: "VsBattle"; listNode: null | BattleListNode; bankaraMatchChallenge: null | BankaraMatchChallenge; challengeProgress: null | ChallengeProgress; @@ -138,7 +139,12 @@ export type VsHistoryDetail = { duration: number; }; -export type BattleExporter = { +export type BattleExporter< + D extends { + // type is seful when you implement more than one BattleExporter on the same class + type: string; + }, +> = { name: string; notExported: (list: string[]) => Promise; exportBattle: (detail: D) => Promise;