Feature/improve typing of metadata related logic (#268)

* Improve metadata typing

* Rename types

Still included the "I" prefix for interfaces

* Improve typing in setting util files
This commit is contained in:
schroda
2023-04-22 11:34:19 +02:00
committed by GitHub
parent 0a56a2f6d4
commit 4157611d83
4 changed files with 89 additions and 92 deletions

View File

@@ -74,13 +74,13 @@ export interface IMetadataMigration {
keys?: { oldKey: string; newKey: string }[];
}
export interface IMetadata<VALUES extends AllowedMetadataValueTypes = string> {
[key: string]: VALUES;
}
export type Metadata<Keys extends string = string, Values = string> = {
[key in Keys]: Values;
};
export interface IMetadataHolder<VALUES extends AllowedMetadataValueTypes = string> {
meta?: IMetadata<VALUES>;
}
export type MetadataHolder<Keys extends string = string, Values = string> = {
meta?: Metadata<Keys, Values>;
};
export type AllowedMetadataValueTypes = string | boolean | number | undefined;
@@ -100,7 +100,7 @@ export interface IMangaCard {
unreadCount?: number;
downloadCount?: number;
inLibrary?: boolean;
meta?: IMetadata;
meta?: Metadata;
inLibraryAt: number;
lastReadAt: number;
}
@@ -122,7 +122,7 @@ export interface IManga {
inLibrary: boolean;
source: ISource;
meta: IMetadata;
meta: Metadata;
realUrl: string;
freshData: boolean;
@@ -158,7 +158,7 @@ export interface IChapter {
chapterCount: number;
pageCount: number;
downloaded: boolean;
meta: IMetadata;
meta: Metadata;
}
export interface IMangaChapter {
@@ -178,7 +178,7 @@ export interface ICategory {
order: number;
name: string;
default: boolean;
meta: IMetadata;
meta: Metadata;
}
export interface INavbarOverride {