Skip to content

Commit

Permalink
add types to related
Browse files Browse the repository at this point in the history
  • Loading branch information
vixalien committed May 4, 2023
1 parent 5688e90 commit 779e742
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions continuations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ function get_continuation_object(ctoken: string) {
};
}

export function get_continuation_contents(
export function get_continuation_contents<T extends any = any>(
continuation: any,
parse: (data: any) => any[],
parse: (data: any) => T[],
) {
for (const term of ["contents", "items"]) {
if (term in continuation) {
return parse(continuation[term]);
}
}

return [] as any[];
return [] as T[];
}

export async function resend_request_until_valid(
Expand Down
8 changes: 6 additions & 2 deletions mixins/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import {
THUMBNAIL_CROPPED,
TITLE_TEXT,
} from "../nav.ts";
import { parse_content_list, parse_playlist } from "../parsers/browsing.ts";
import {
parse_content_list,
parse_playlist,
ParsedPlaylist,
} from "../parsers/browsing.ts";
import {
parse_playlist_items,
PlaylistItem,
Expand Down Expand Up @@ -62,7 +66,7 @@ export interface Playlist {
continuation: string | null;
suggestions: any;
suggestions_continuation: string | null;
related: any;
related: ParsedPlaylist[];
}

export interface PlaylistSuggestions {
Expand Down

0 comments on commit 779e742

Please sign in to comment.