ref: move all prop type declaration to flow

For the most part the changes are taking the "static propTypes" declaration off
of components and declaring them as Flow types. Sometimes to support flow some
method signatures had to be added. There are some exceptions in which more had
to be done to tame the beast:
- AbstractVideoTrack: put in additional truthy checks for videoTrack.
- Video: add truthy checks for the _videoElement ref.
- shouldRenderVideoTrack function: Some component could pass null for the
  videoTrack argument and Flow wanted that called out explicitly.
- DisplayName: Add a truthy check for the input ref before acting on it.
- NumbersList: Move array checks inline for Flow to comprehend array methods
  could be called. Add type checks in the Object.entries loop as the value is
  assumed to be a mixed type by Flow.
- AbstractToolbarButton: add additional truthy check for passed in type.
This commit is contained in:
Leonard Kim
2018-10-29 22:02:23 -07:00
committed by Zoltan Bettenbuk
parent 554974a36d
commit 486e8e35d9
77 changed files with 2815 additions and 2456 deletions

View File

@@ -1,4 +1,5 @@
import PropTypes from 'prop-types';
/* @flow */
import React, { Component } from 'react';
import {
@@ -18,6 +19,33 @@ export const REMOTE_CONTROL_MENU_STATES = {
STARTED: 3
};
/**
* The type of the React {@code Component} props of {@link RemoteControlButton}.
*/
type Props = {
/**
* The callback to invoke when the component is clicked.
*/
onClick: Function,
/**
* The ID of the participant linked to the onClick callback.
*/
participantID: string,
/**
* The current status of remote control. Should be a number listed in the
* enum REMOTE_CONTROL_MENU_STATES.
*/
remoteControlState: number,
/**
* Invoked to obtain translated strings.
*/
t: Function
};
/**
* Implements a React {@link Component} which displays a button showing the
* current state of remote control for a participant and can start or stop a
@@ -25,42 +53,14 @@ export const REMOTE_CONTROL_MENU_STATES = {
*
* @extends Component
*/
class RemoteControlButton extends Component {
/**
* {@code RemoteControlButton} component's property types.
*
* @static
*/
static propTypes = {
/**
* The callback to invoke when the component is clicked.
*/
onClick: PropTypes.func,
/**
* The ID of the participant linked to the onClick callback.
*/
participantID: PropTypes.string,
/**
* The current status of remote control. Should be a number listed in
* the enum REMOTE_CONTROL_MENU_STATES.
*/
remoteControlState: PropTypes.number,
/**
* Invoked to obtain translated strings.
*/
t: PropTypes.func
};
class RemoteControlButton extends Component<Props> {
/**
* Initializes a new {@code RemoteControlButton} instance.
*
* @param {Object} props - The read-only React Component props with which
* the new instance is to be initialized.
*/
constructor(props) {
constructor(props: Props) {
super(props);
// Bind event handlers so they are only bound once for every instance.
@@ -112,6 +112,8 @@ class RemoteControlButton extends Component {
);
}
_onClick: () => void;
/**
* Sends analytics event for pressing the button and executes the passed
* onClick handler.