opentok / opentok-react-native

OpenTok React Native - a library for OpenTok iOS and Android SDKs
https://tokbox.com/
MIT License
210 stars 155 forks source link

fix typings for issue 690 #691

Closed MartinHarkins closed 10 months ago

MartinHarkins commented 11 months ago

Contributing checklist

Solves issue(s)

Fixes: https://github.com/opentok/opentok-react-native/issues/690

The typings file was broken. Essentially the basic fixes needed are along those lines:

-    rtcStatsReport?: CallbackWithParam<RtcStatsReport>, any>;
+    rtcStatsReport?: CallbackWithParam<RtcStatsReport, any>;

Another issue was with the recent typings added on OTSessionProps, OTSubscriberProps and OTPublisherProps

Some methods were added onto the JS component, like OTSession#getCapabilities... However, they are not in fact props.

The issue with those typings is that they force consumers of those three components, to fill in those props; despite the fact that they cannot be used anywhere in the component implementations. The only reason they could be used was if a developer subclassed for example OTSession, and then called those props themselves.

Those methods are a part of the components, but using them actually requires subclassing said components. There is no practical way to use them otherwise.

Additionally; OTSession, OTPublisher and OTSubscriber should probably have those functions removed from the declared propTypes and defaultProps.

I can do that but I need confirmation before I perform that change.

In anycase, if possible this PR could be merged and published quickly in order to fix the typings which are completely broken at the moment.