Strictify index.tsx
Summary: As per title Reviewed By: danielbuechele Differential Revision: D17265679 fbshipit-source-id: 664f92f803a44dd485fb7078b59c88e95998decf
This commit is contained in:
committed by
Facebook Github Bot
parent
428f6b4fc1
commit
b75a3dc56b
@@ -9,6 +9,7 @@ import {remote} from 'electron';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import {ReactElement} from 'react';
|
||||
import CancellableExportStatus from '../chrome/CancellableExportStatus';
|
||||
import {Actions} from './';
|
||||
export const ACTIVE_SHEET_PLUGIN_SHEET: 'PLUGIN_SHEET' = 'PLUGIN_SHEET';
|
||||
export const ACTIVE_SHEET_BUG_REPORTER: 'BUG_REPORTER' = 'BUG_REPORTER';
|
||||
export const ACTIVE_SHEET_PLUGIN_DEBUGGER: 'PLUGIN_DEBUGGER' =
|
||||
@@ -139,7 +140,10 @@ const initialState: () => State = () => ({
|
||||
flipperRating: null,
|
||||
});
|
||||
|
||||
export default function reducer(state: State, action: Action): State {
|
||||
export default function reducer(
|
||||
state: State | undefined,
|
||||
action: Actions,
|
||||
): State {
|
||||
state = state || initialState();
|
||||
if (
|
||||
action.type === 'leftSidebarVisible' ||
|
||||
|
||||
@@ -14,6 +14,7 @@ import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||
import {performance} from 'perf_hooks';
|
||||
import {SAVED_PLUGINS_COUNT} from '../Client';
|
||||
import isHeadless from '../utils/isHeadless';
|
||||
import {Actions} from '.';
|
||||
const WelcomeScreen = isHeadless()
|
||||
? require('../chrome/WelcomeScreenHeadless').default
|
||||
: require('../chrome/WelcomeScreen').default;
|
||||
@@ -130,7 +131,7 @@ const INITAL_STATE: State = {
|
||||
staticView: WelcomeScreen,
|
||||
};
|
||||
|
||||
const reducer = (state: State = INITAL_STATE, action: Action): State => {
|
||||
const reducer = (state: State = INITAL_STATE, action: Actions): State => {
|
||||
switch (action.type) {
|
||||
case 'SET_STATIC_VIEW': {
|
||||
const {payload} = action;
|
||||
@@ -417,7 +418,7 @@ const reducer = (state: State = INITAL_STATE, action: Action): State => {
|
||||
}
|
||||
};
|
||||
|
||||
export default (state: State = INITAL_STATE, action: Action): State => {
|
||||
export default (state: State = INITAL_STATE, action: Actions): State => {
|
||||
const nextState = reducer(state, action);
|
||||
|
||||
if (nextState.selectedDevice) {
|
||||
|
||||
@@ -28,10 +28,11 @@ import plugins, {
|
||||
} from './plugins';
|
||||
import user, {State as UserState, Action as UserAction} from './user';
|
||||
|
||||
import {persistReducer} from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage/index.js';
|
||||
import {persistReducer, PersistPartial} from 'redux-persist';
|
||||
|
||||
import {Store as ReduxStore, MiddlewareAPI as ReduxMiddlewareAPI} from 'redux';
|
||||
// @ts-ignore: explicitly need to import index.js, otherwise index.native.js is imported, because redux-persist assumes we are react-native, because we are using metro-bundler
|
||||
import storage from 'redux-persist/lib/storage/index.js';
|
||||
|
||||
export type Actions =
|
||||
| ApplicationAction
|
||||
@@ -43,19 +44,19 @@ export type Actions =
|
||||
| {type: 'INIT'};
|
||||
|
||||
export type State = {
|
||||
application: ApplicationState;
|
||||
connections: DevicesState;
|
||||
application: ApplicationState & PersistPartial;
|
||||
connections: DevicesState & PersistPartial;
|
||||
pluginStates: PluginStatesState;
|
||||
notifications: NotificationsState;
|
||||
notifications: NotificationsState & PersistPartial;
|
||||
plugins: PluginsState;
|
||||
user: UserState;
|
||||
user: UserState & PersistPartial;
|
||||
};
|
||||
|
||||
export type Store = ReduxStore<State, Actions>;
|
||||
export type MiddlewareAPI = ReduxMiddlewareAPI<Dispatch<Actions>, State>;
|
||||
|
||||
export default combineReducers<State, Actions>({
|
||||
application: persistReducer(
|
||||
application: persistReducer<ApplicationState, Actions>(
|
||||
{
|
||||
key: 'application',
|
||||
storage,
|
||||
@@ -63,7 +64,7 @@ export default combineReducers<State, Actions>({
|
||||
},
|
||||
application,
|
||||
),
|
||||
connections: persistReducer(
|
||||
connections: persistReducer<DevicesState, Actions>(
|
||||
{
|
||||
key: 'connections',
|
||||
storage,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @format
|
||||
*/
|
||||
import {Notification} from '../plugin';
|
||||
|
||||
import {Actions} from './';
|
||||
export type PluginNotification = {
|
||||
notification: Notification;
|
||||
pluginId: string;
|
||||
@@ -60,7 +60,7 @@ const INITIAL_STATE: State = {
|
||||
|
||||
export default function reducer(
|
||||
state: State = INITIAL_STATE,
|
||||
action: Action,
|
||||
action: Actions,
|
||||
): State {
|
||||
switch (action.type) {
|
||||
case 'SET_ACTIVE_NOTIFICATIONS': {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {Actions} from '.';
|
||||
|
||||
export type State = {
|
||||
[pluginKey: string]: Object;
|
||||
};
|
||||
@@ -29,8 +31,8 @@ export type Action =
|
||||
const INITIAL_STATE: State = {};
|
||||
|
||||
export default function reducer(
|
||||
state: State = INITIAL_STATE,
|
||||
action: Action,
|
||||
state: State | undefined = INITIAL_STATE,
|
||||
action: Actions,
|
||||
): State {
|
||||
if (action.type === 'SET_PLUGIN_STATE') {
|
||||
const newPluginState = action.payload.state;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import {FlipperPlugin, FlipperDevicePlugin} from '../plugin';
|
||||
import {PluginDefinition} from '../dispatcher/plugins';
|
||||
import {Actions} from '.';
|
||||
|
||||
export type State = {
|
||||
devicePlugins: Map<string, typeof FlipperDevicePlugin>;
|
||||
@@ -51,8 +52,8 @@ const INITIAL_STATE: State = {
|
||||
};
|
||||
|
||||
export default function reducer(
|
||||
state: State = INITIAL_STATE,
|
||||
action: Action,
|
||||
state: State | undefined = INITIAL_STATE,
|
||||
action: Actions,
|
||||
): State {
|
||||
if (action.type === 'REGISTER_PLUGINS') {
|
||||
const {devicePlugins, clientPlugins} = state;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {Actions} from './';
|
||||
|
||||
export type User = {
|
||||
name?: string;
|
||||
profile_picture?: {
|
||||
@@ -27,7 +29,7 @@ const INITIAL_STATE: State = {};
|
||||
|
||||
export default function reducer(
|
||||
state: State = INITIAL_STATE,
|
||||
action: Action,
|
||||
action: Actions,
|
||||
): State {
|
||||
if (action.type === 'LOGOUT') {
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user