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

make all props optional #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sean-adams
Copy link

@sean-adams sean-adams commented Dec 6, 2023

All component props are either not required and/or have reasonable defaults in defaultProps, but Typescript will still complain if you don't provide them because they are not marked as optional in WebcamProps.

Achieving this did require optional chaining on onUserMedia and onUserMediaError as well as coercing imageSmoothing to a boolean.

@mozmorris
Copy link
Owner

@sean-adams thank you for sending this PR.

What does your TypeScript setup look like? Can you supply a reproducible example? We don't see this issue on any of the multiple projects this library is used on. It's a long time since the types were added but I remember that the default props were properly inferred. I believe this was the recommended setup at the time. For example, I think you would agree the optional chaining is not actually needed at runtime, since those props have defaults.

If there is now an issue with this setup, it would be great if we could avoid the code changes that are not actually needed. Perhaps by extending the PropTypes with typeof WebCam.defaultProps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants