From b4585ef72c8e8d7bbb79c9e7d0394dff10b84464 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 18 Jul 2019 06:21:15 -0700 Subject: [PATCH] Add types to reduxDevToolsConfig Summary: Getting rid of a flowfixme, part of T47375728 Reviewed By: passy Differential Revision: D16336917 fbshipit-source-id: 163734796b72ba2c8971f27ce213baf7ca3f23a1 --- src/utils/reduxDevToolsConfig.js | 59 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/src/utils/reduxDevToolsConfig.js b/src/utils/reduxDevToolsConfig.js index c858eed58..7e6d5d054 100644 --- a/src/utils/reduxDevToolsConfig.js +++ b/src/utils/reduxDevToolsConfig.js @@ -4,39 +4,32 @@ * LICENSE file in the root directory of this source tree. * @format */ +import type {State} from '../reducers/index'; +import type {DeviceExport} from '../devices/BaseDevice'; -// $FlowFixMe T47375728 -export const stateSanitizer = state => { - let sanitizedState = state; - if (state.connections) { - if (state.connections.devices) { - const {devices} = state.connections; - sanitizedState = { - ...sanitizedState, - connections: { - ...state.connections, - devices: devices.map(device => { - return { - ...device.toJSON(), - logs: '<>', - }; - }), - }, - }; - } - if (state.connections.selectedDevice) { - const {selectedDevice} = state.connections; - sanitizedState = { - ...sanitizedState, - connections: { - ...sanitizedState.connections, - selectedDevice: { - ...selectedDevice.toJSON(), - logs: '<>', - }, - }, - }; - } +export const stateSanitizer = (state: State) => { + if (state.connections && state.connections.devices) { + const {devices} = state.connections; + const {selectedDevice} = state.connections; + return { + ...state, + connections: { + ...state.connections, + devices: devices.map(device => { + return { + ...device.toJSON(), + logs: [], + }; + }), + selectedDevice: selectedDevice + ? { + ...selectedDevice.toJSON(), + logs: [], + } + : null, + }, + }; } - return sanitizedState; + + return state; };