Skip to content

Commit

Permalink
refactor: replace enums with types
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed May 8, 2024
1 parent a1a0be8 commit 697432d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 45 deletions.
60 changes: 32 additions & 28 deletions src/models/Anime/anime.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,38 @@ export interface AnimeTheme {
endings: string[];
}

export enum AnimeType {
tv = 'TV',
movie = 'Movie',
ova = 'Ova',
special = 'Special',
ona = 'Ona',
music = 'Music',
}
const AnimeType = {
tv: 'TV',
movie: 'Movie',
ova: 'Ova',
special: 'Special',
ona: 'Ona',
music: 'Music',
} as const;
export type AnimeType = (typeof AnimeType)[keyof typeof AnimeType];

export enum AnimeStatus {
finished = 'Finished Airing',
airing = 'Currently Airing',
complete = 'Complete',
upcoming = 'Not yet aired',
}
const AnimeStatus = {
finished: 'Finished Airing',
airing: 'Currently Airing',
complete: 'Complete',
upcoming: 'Not yet aired',
} as const;
export type AnimeStatus = (typeof AnimeStatus)[keyof typeof AnimeStatus];

export enum AnimeRating {
g = 'g',
pg = 'pg',
pg13 = 'pg13',
r17 = 'r17',
r = 'r',
rx = 'rx',
}
const AnimeRating = {
g: 'g',
pg: 'pg',
pg13: 'pg13',
r17: 'r17',
r: 'r',
rx: 'rx',
} as const;
export type AnimeRating = (typeof AnimeRating)[keyof typeof AnimeRating];

export enum AnimeSeason {
spring = 'spring',
summer = 'summer',
fall = 'fall',
winter = 'winter',
}
const AnimeSeason = {
spring: 'spring',
summer: 'summer',
fall: 'fall',
winter: 'winter',
} as const;
export type AnimeSeason = (typeof AnimeSeason)[keyof typeof AnimeSeason];
2 changes: 1 addition & 1 deletion src/models/Common/seasons-list.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { AnimeSeason } from '../Anime';

export interface SeasonsListData {
year: number;
seasons: Array<keyof typeof AnimeSeason>;
seasons: AnimeSeason[];
}
34 changes: 18 additions & 16 deletions src/models/Manga/manga.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ export interface Manga {
external?: JikanNamedResource[];
}

export enum MangaType {
manga = 'Manga',
novel = 'Novel',
lightnovel = 'Lightnovel',
oneshot = 'Oneshot',
doujin = 'Doujin',
manhwa = 'Manhwa',
manhua = 'Manhua',
}
const MangaType = {
manga: 'Manga',
novel: 'Novel',
lightnovel: 'Lightnovel',
oneshot: 'Oneshot',
doujin: 'Doujin',
manhwa: 'Manhwa',
manhua: 'Manhua',
} as const;
export type MangaType = (typeof MangaType)[keyof typeof MangaType];

export enum MangaStatus {
publishing = 'Publishing',
complete = 'Complete',
hiatus = 'On Hiatus',
discontinued = 'Discontinued',
upcoming = 'Upcoming',
}
const MangaStatus = {
publishing: 'Publishing',
complete: 'Complete',
hiatus: 'On Hiatus',
discontinued: 'Discontinued',
upcoming: 'Upcoming',
} as const;
export type MangaStatus = (typeof MangaStatus)[keyof typeof MangaStatus];

0 comments on commit 697432d

Please sign in to comment.