Skip to content

Commit

Permalink
add type to trending-song & top-song
Browse files Browse the repository at this point in the history
  • Loading branch information
vixalien committed Jul 25, 2023
1 parent 870c966 commit 21ee27c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions parsers/browsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,14 @@ export function parse_channel_contents(results: any[]) {
return parse_categories(results, categories_data);
}

export type NonNUllableChannelContents = ReturnType<typeof parse_channel_contents>;
export type NonNUllableChannelContents = ReturnType<
typeof parse_channel_contents
>;

export type ChannelContents = {
[Key in keyof NonNUllableChannelContents]: NonNUllableChannelContents[Key] | null;
[Key in keyof NonNUllableChannelContents]:
| NonNUllableChannelContents[Key]
| null;
};

export function parse_artist_contents(results: any[]) {
Expand Down Expand Up @@ -554,6 +558,7 @@ export function parse_video(result: any): ParsedVideo {
export type TrendChange = "UP" | "DOWN" /* | "NEW" */ | "NEUTRAL";

export interface TopSong {
type: "top-song";
title: string;
videoId: string;
artists: SongArtist[] | null;
Expand All @@ -579,6 +584,7 @@ export function parse_top_song(result: any): TopSong {
);

return {
type: "top-song",
title: j(title_run, "text"),
videoId: j(title_run, NAVIGATION_VIDEO_ID),
artists: parse_song_artists(result, 1),
Expand Down Expand Up @@ -647,6 +653,7 @@ export function parse_top_artist(result: any): TopArtist {
}

export interface TrendingSong {
type: "trending-song";
title: string;
videoId: string | null;
artists: SongArtist[] | null;
Expand Down Expand Up @@ -686,6 +693,7 @@ export function parse_trending(result: any): TrendingSong {
);

return {
type: "trending-song",
title: j(title_run, "text"),
videoId: jo(title_run, NAVIGATION_VIDEO_ID),
artists: parse_song_artists(result, 1, undefined),
Expand Down

0 comments on commit 21ee27c

Please sign in to comment.