Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[flow] Take advantage of flow-typed
Lyubomir Marinov5de1a7442942
diff --git a/.eslintrc.js b/.eslintrc.jsindex 2b93976795..64947373ae 100644--- a/.eslintrc.js+++ b/.eslintrc.js@@ -4,7 +4,10 @@ module.exports = {'commonjs': true,'es6': true},- 'extends': 'eslint:recommended',+ 'extends': [+ 'eslint:recommended',+ 'plugin:flowtype/recommended'+ ],'globals': {// The globals that (1) are accessed but not defined within many of our// files, (2) are certainly defined, and (3) we would like to use@@ -19,6 +22,9 @@ module.exports = {},'sourceType': 'module'},+ 'plugins': [+ 'flowtype'+ ],'rules': {'new-cap': ['error',diff --git a/package.json b/package.jsonindex dd9f61bf46..32de0f2e63 100644--- a/package.json+++ b/package.json@@ -60,6 +60,7 @@"clean-css": "^3.0.0","css-loader": "*","eslint": "^3.14.1",+ "eslint-plugin-flowtype": "^2.30.0","eslint-plugin-import": "^2.2.0","eslint-plugin-jsdoc": "*","eslint-plugin-react": "*",diff --git a/react/features/base/connection/actions.native.js b/react/features/base/connection/actions.native.jsindex 329b2e6d4a..77f8671b21 100644--- a/react/features/base/connection/actions.native.js+++ b/react/features/base/connection/actions.native.js@@ -1,3 +1,7 @@+/* @flow */++import type { Dispatch } from 'redux';+import { conferenceWillLeave } from '../conference';import JitsiMeetJS from '../lib-jitsi-meet';@@ -14,10 +18,10 @@ const JitsiConnectionEvents = JitsiMeetJS.events.connection;/*** Opens new connection.*- * @returns {Promise<JitsiConnection>}+ * @returns {Function}*/export function connect() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {const state = getState();const connectionOptions= state['features/base/connection'].connectionOptions;@@ -57,7 +61,7 @@ export function connect() {* @param {string} message - Disconnect reason.* @returns {void}*/- function connectionDisconnected(message) {+ function connectionDisconnected(message: string) {connection.removeEventListener(JitsiConnectionEvents.CONNECTION_DISCONNECTED,connectionDisconnected);@@ -110,7 +114,7 @@ export function connect() {* @returns {Function}*/export function disconnect() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {const state = getState();const conference = state['features/base/conference'].conference;const connection = state['features/base/connection'].connection;@@ -148,7 +152,7 @@ export function disconnect() {* domain: string* }}*/-export function setDomain(domain) {+export function setDomain(domain: string) {return {type: SET_DOMAIN,domain@@ -167,7 +171,7 @@ export function setDomain(domain) {* message: string* }}*/-function _connectionDisconnected(connection, message) {+function _connectionDisconnected(connection, message: string) {return {type: CONNECTION_DISCONNECTED,connection,@@ -205,7 +209,7 @@ function _connectionEstablished(connection) {* error: string* }}*/-function _connectionFailed(connection, error) {+function _connectionFailed(connection, error: string) {return {type: CONNECTION_FAILED,connection,diff --git a/react/features/base/connection/actions.web.js b/react/features/base/connection/actions.web.jsindex dc432eac28..c1b44589e8 100644--- a/react/features/base/connection/actions.web.js+++ b/react/features/base/connection/actions.web.js@@ -1,10 +1,15 @@-/* global APP, JitsiMeetJS */+/* @flow */++import type { Dispatch } from 'redux';import UIEvents from '../../../../service/UI/UIEvents';import { SET_DOMAIN } from './actionTypes';import './reducer';+declare var APP: Object;+declare var JitsiMeetJS: Object;+const JitsiConferenceEvents = JitsiMeetJS.events.conference;const logger = require('jitsi-meet-logger').getLogger(__filename);@@ -14,7 +19,7 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);* @returns {Promise<JitsiConnection>}*/export function connect() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {const state = getState();// XXX Lib-jitsi-meet does not accept uppercase letters.@@ -88,7 +93,7 @@ export function disconnect() {* domain: string* }}*/-export function setDomain(domain) {+export function setDomain(domain: string) {return {type: SET_DOMAIN,domaindiff --git a/react/features/base/media/actions.js b/react/features/base/media/actions.jsindex c3e38baa64..cbd9222ffe 100644--- a/react/features/base/media/actions.js+++ b/react/features/base/media/actions.js@@ -1,3 +1,7 @@+/* @flow */++import type { Dispatch } from 'redux';+import {SET_AUDIO_MUTED,SET_CAMERA_FACING_MODE,@@ -17,7 +21,7 @@ import './reducer';* muted: boolean* }}*/-export function setAudioMuted(muted) {+export function setAudioMuted(muted: boolean) {return {type: SET_AUDIO_MUTED,muted@@ -33,7 +37,7 @@ export function setAudioMuted(muted) {* cameraFacingMode: CAMERA_FACING_MODE* }}*/-export function setCameraFacingMode(cameraFacingMode) {+export function setCameraFacingMode(cameraFacingMode: CAMERA_FACING_MODE) {return {type: SET_CAMERA_FACING_MODE,cameraFacingMode@@ -50,7 +54,7 @@ export function setCameraFacingMode(cameraFacingMode) {* muted: boolean* }}*/-export function setVideoMuted(muted) {+export function setVideoMuted(muted: boolean) {return {type: SET_VIDEO_MUTED,muted@@ -63,7 +67,7 @@ export function setVideoMuted(muted) {* @returns {Function}*/export function toggleAudioMuted() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {const muted = getState()['features/base/media'].audio.muted;return dispatch(setAudioMuted(!muted));@@ -76,7 +80,7 @@ export function toggleAudioMuted() {* @returns {Function}*/export function toggleCameraFacingMode() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {let cameraFacingMode= getState()['features/base/media'].video.facingMode;@@ -95,7 +99,7 @@ export function toggleCameraFacingMode() {* @returns {Function}*/export function toggleVideoMuted() {- return (dispatch, getState) => {+ return (dispatch: Dispatch<*>, getState: Function) => {const muted = getState()['features/base/media'].video.muted;return dispatch(setVideoMuted(!muted));diff --git a/react/features/base/react/functions.js b/react/features/base/react/functions.jsindex 457418d6ed..9b0f163e7f 100644--- a/react/features/base/react/functions.js+++ b/react/features/base/react/functions.js@@ -1,5 +1,7 @@/* @flow */+/* eslint-disable flowtype/space-before-type-colon */+/*** Prevents further propagation of the events to be handler by a specific event* handler/listener in the capturing and bubbling phases.@@ -11,7 +13,10 @@*/export function stopEventPropagation<T>(eventHandler: (ev: Event) => T): (ev: Event) => T {- return (ev: Event) => {++/* eslint-enable flowtype/space-before-type-colon */++ return (ev: Event): T => {const r = eventHandler(ev);// React Native does not propagate the press event so, for the sake ofdiff --git a/react/features/base/redux/ReducerRegistry.js b/react/features/base/redux/ReducerRegistry.jsindex 4e9563cf79..18628f5bd8 100644--- a/react/features/base/redux/ReducerRegistry.js+++ b/react/features/base/redux/ReducerRegistry.js@@ -1,10 +1,21 @@+/* @flow */+import { combineReducers } from 'redux';+import type { Reducer } from 'redux';++/**+ * The type of the dictionary/map which associates a reducer (function) with the+ * name of he Redux state property managed by the reducer.+ */+declare type NameReducerMap<S, A> = { [name: string]: Reducer<S, A> };/*** A registry for Redux reducers, allowing features to register themselves* without needing to create additional inter-feature dependencies.*/class ReducerRegistry {+ _elements: NameReducerMap<*, *>;+/*** Creates a ReducerRegistry instance.*/@@ -12,6 +23,9 @@ class ReducerRegistry {/*** The set of registered reducers, keyed based on the field each reducer* will manage.+ *+ * @private+ * @type {NameReducerMap}*/this._elements = {};}@@ -23,7 +37,7 @@ class ReducerRegistry {* included (such as reducers from third-party modules).* @returns {Function}*/- combineReducers(additional = {}) {+ combineReducers(additional: NameReducerMap<*, *> = {}) {return combineReducers({...this._elements,...additional@@ -37,10 +51,10 @@ class ReducerRegistry {** @param {string} name - The field in the state object that will be managed* by the provided reducer.- * @param {Function} reducer - A Redux reducer.+ * @param {Reducer} reducer - A Redux reducer.* @returns {void}*/- register(name, reducer) {+ register(name: string, reducer: Reducer<*, *>) {this._elements[name] = reducer;}}