From 6b066fe8ca130fe327dd08b52264b92502cd250b Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 20 Apr 2024 01:29:14 +0200 Subject: [PATCH] Extract Mangas action option types --- src/lib/data/Mangas.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib/data/Mangas.ts b/src/lib/data/Mangas.ts index 7d3d4059..9e4e00d6 100644 --- a/src/lib/data/Mangas.ts +++ b/src/lib/data/Mangas.ts @@ -124,13 +124,25 @@ type MigrateOptions = { migrateCategories?: boolean; deleteChapters?: boolean; }; + +type MarkAsReadActionOption = MarkAsReadOptions & + PropertiesNever & + PropertiesNever; +type ChangeCategoriesActionOption = PropertiesNever & + ChangeCategoriesOptions & + PropertiesNever; +type MigrateActionOption = PropertiesNever & + PropertiesNever & + MigrateOptions; +type DefaultActionOption = Partial & Partial & Partial; + type PerformActionOptions = Action extends 'mark_as_read' - ? MarkAsReadOptions & PropertiesNever & PropertiesNever + ? MarkAsReadActionOption : Action extends 'change_categories' - ? PropertiesNever & ChangeCategoriesOptions & PropertiesNever + ? ChangeCategoriesActionOption : Action extends 'migrate' - ? PropertiesNever & PropertiesNever & MigrateOptions - : Partial & Partial & Partial; + ? MigrateActionOption + : DefaultActionOption; export class Mangas { static getIds(mangas: { id: number }[]): number[] {