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

BaseReactPlayer types are not correct #1739

Open
bnbs opened this issue Feb 15, 2024 · 1 comment
Open

BaseReactPlayer types are not correct #1739

bnbs opened this issue Feb 15, 2024 · 1 comment
Labels
enhancement Indicates new feature requests

Comments

@bnbs
Copy link

bnbs commented Feb 15, 2024

I'm implementing a custom player in TypeScript and for this I have a class that extends BaseReactPlayer<ReactPlayerProps>. I initialize duration, currentTime and secondsLoaded to null, but I noticed that the getDuration, getCurrentTime and getSecondsLoaded methods must return a number, so TypeScript complains about this since I'm initializing these values as null. I took a look at all the players that exist in react-player and noticed that if not all, then almost all players return null in these methods and not just numbers, so I assumed that the types are not correct. Am I missing something or are the types just not correct?

@luwes
Copy link
Collaborator

luwes commented Feb 22, 2024

yes, the types could use some refinements.

if we look at the native video element currentTime should start at 0, as does getSecondsLoaded() so those should be fine.

however duration is NaN by default which doesn't have an equivalent in TS so undefined or unknown would make sense here

@luwes luwes added the enhancement Indicates new feature requests label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants