Open sean-adams opened 10 months ago
@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
?
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 inWebcamProps
.Achieving this did require optional chaining on
onUserMedia
andonUserMediaError
as well as coercingimageSmoothing
to a boolean.