Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser/youtube/Playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Playlist extends Feed<IBrowseResponse> {
this.info = {
...this.page.metadata?.item().as(PlaylistMetadata),
...{
subtitle: header.subtitle,
subtitle: header ? header.subtitle : null,
Copy link
Contributor

@ChunkyProgrammer ChunkyProgrammer Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this file uses header?. instead so i'm not sure if header?.subtitle would be preferred

Ex:
can_share: header?.can_share,
can_delete: header?.can_delete,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using header?.subtitle would result in it returning undefined, which would change the type of the subtitle property from Text | null to Text | null | undefined. This could be mitigated by doing header?.subtitle ?? null, but due to YouTube.js targetting ES2016, it gets transpiled to the rather verbose: (_b = header === null || header === void 0 ? void 0 : header.subtitle) !== null && _b !== void 0 ? _b : null,.

I can change the type of subtitle to be Text | undefined, if you would prefer that over null, I definitely don't want both null and undefined being possible?

author: secondary_info?.owner?.as(VideoOwner).author ?? header?.author,
thumbnails: primary_info?.thumbnail_renderer?.as(PlaylistVideoThumbnail, PlaylistCustomThumbnail).thumbnail as Thumbnail[],
total_items: this.#getStat(0, primary_info),
Expand Down