Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Mismatch between docs, TS types, and behavior for cuepoints and chapters #947

Closed
1 task done
decepulis opened this issue Jul 12, 2024 · 0 comments · Fixed by #977
Closed
1 task done

Bug: Mismatch between docs, TS types, and behavior for cuepoints and chapters #947

decepulis opened this issue Jul 12, 2024 · 0 comments · Fixed by #977
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@decepulis
Copy link
Contributor

decepulis commented Jul 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Which Mux Elements/Packages does this apply to? Select all that apply

mux-player-react

Which browsers are you using?

Safari

Which operating systems are you using?

macOS

Description

The types described in the docs don't match up with the types in TypeScript for addCuePoints and addChapters in @mux/mux-player-react

Reduced test case

https://codesandbox.io/p/sandbox/dreamy-pascal-637nl9?file=%2Fsrc%2FApp.tsx%3A9%2C45

Steps to reproduce

Cue points

  • Try passing an object with type { startTime: number; endTime?: number; value: any; } to addCuePoints. TypeScript yells (even though this type is in the Mux Docs).
  • Try passing an object with type { time: number; value: any } to addCuePoints. TypeScript does not yell (even though this type is not in the Mux Docs)

Chapters

  • Try passing an object with type { startTime: number; endTime?: number; value: any; } to addChapters. TypeScript yells (even though this type is in the Mux Docs).
  • Try passing an object with type { startTime: number; endTime: number; value: any; } to addChapters. TypeScript does not yell.

Current Behavior

Cue points

  • Docs say { startTime: number; endTime?: number; value: any; }
  • TS types say addCuePoints<T = any>(cuePoints: { time: number; value: T; }[]): Promise<TextTrack | undefined>;
  • I'm using { time: number; value: any } and it's working as expected

Chapters

  • Docs say { startTime: number; endTime?: number; value: any; }
  • TS types say addChapters(chapters: { startTime: number; endTime: number; value: string; }[]): Promise<TextTrack> | undefined;. (Notice that endTime is required in TS)
  • I'm using { startTime: number; value: string } and it's working as expected

Expected Behavior

I'm assuming the docs are correct here. So...

Cue Points

  • TS should say addCuePoints<T = any>(cuePoints: { startTime: number; endTime?: number; value: T; }[]): Promise<TextTrack | undefined>;
  • And maybe { time: number; value: T } should be supported as a legacy option, since that's how Cue Points used to work, right?

Chapters

  • TS types should say addChapters(chapters: { startTime: number; endTime?: number; value: string; }[]): Promise<TextTrack> | undefined;

Errors

image image

What version of the package are you using?

2.8.0

@decepulis decepulis added bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant