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,19 +1,61 @@
/* @flow */
import {
DropdownItem,
DropdownItemGroup,
DropdownMenuStateless
} from '@atlaskit/dropdown-menu';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { translate } from '../../../base/i18n';
/**
* The type of the React {@code Component} props of {@link StreamKeyPicker}.
*/
type Props = {
/**
* Broadcasts available for selection. Each broadcast item should be an
* object with a title for display in the dropdown and a boundStreamID to
* return in the {@link onBroadcastSelected} callback.
*/
broadcasts: Array<Object>,
/**
* Callback invoked when an item in the dropdown is selected. The selected
* broadcast's boundStreamID will be passed back.
*/
onBroadcastSelected: Function,
/**
* The boundStreamID of the broadcast that should display as selected in the
* dropdown.
*/
selectedBoundStreamID: string,
/**
* Invoked to obtain translated strings.
*/
t: Function
};
/**
* The type of the React {@code Component} state of {@link StreamKeyPicker}.
*/
type State = {
/**
* Whether or not to display the dropdown menu to pick a YouTube broadcast.
*/
isDropdownOpen: boolean
};
/**
* A dropdown to select a YouTube broadcast.
*
* @extends Component
*/
class StreamKeyPicker extends PureComponent {
class StreamKeyPicker extends PureComponent<Props, State> {
/**
* Default values for {@code StreamKeyForm} component's properties.
*
@@ -23,41 +65,8 @@ class StreamKeyPicker extends PureComponent {
broadcasts: []
};
/**
* {@code StreamKeyPicker} component's property types.
*/
static propTypes = {
/**
* Broadcasts available for selection. Each broadcast item should be an
* object with a title for display in the dropdown and a boundStreamID
* to return in the {@link onBroadcastSelected} callback.
*/
broadcasts: PropTypes.array,
/**
* Callback invoked when an item in the dropdown is selected. The
* selected broadcast's boundStreamID will be passed back.
*/
onBroadcastSelected: PropTypes.func,
/**
* The boundStreamID of the broadcast that should display as selected in
* the dropdown.
*/
selectedBoundStreamID: PropTypes.string,
/**
* Invoked to obtain translated strings.
*/
t: PropTypes.func
};
/**
* The initial state of a {@code StreamKeyForm} instance.
*
* @type {{
* isDropdownOpen: boolean
* }}
*/
state = {
isDropdownOpen: false
@@ -69,7 +78,7 @@ class StreamKeyPicker extends PureComponent {
* @param {Props} props - The React {@code Component} props to initialize
* the new {@code StreamKeyPicker} instance with.
*/
constructor(props) {
constructor(props: Props) {
super(props);
// Bind event handlers so they are only bound once per instance.
@@ -139,6 +148,8 @@ class StreamKeyPicker extends PureComponent {
});
}
_onDropdownOpenChange: (Object) => void;
/**
* Sets the dropdown to be displayed or not based on the passed in event.
*
@@ -154,6 +165,8 @@ class StreamKeyPicker extends PureComponent {
});
}
_onSelect: (string) => void;
/**
* Callback invoked when an item has been clicked in the dropdown menu.
*