Skip to content

Commit

Permalink
Fix flow verification errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGrandon authored and fusion-bot[bot] committed May 24, 2018
1 parent a7c18f3 commit f12c473
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
./src/

[libs]
./node_modules/fusion-core/flow-typed

[lints]

Expand Down
94 changes: 94 additions & 0 deletions flow-typed/npm/redux_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// @flow
// flow-typed signature: cca4916b0213065533df8335c3285a4a
// flow-typed version: cab04034e7/redux_v3.x.x/flow_>=v0.55.x

declare module 'redux' {
/*
S = State
A = Action
D = Dispatch
*/

declare export type DispatchAPI<A> = (action: A) => A;
declare export type Dispatch<A: {type: $Subtype<string>}> = DispatchAPI<A>;

declare export type MiddlewareAPI<S, A, D = Dispatch<A>> = {
dispatch: D,
getState(): S,
};

declare export type Store<S, A, D = Dispatch<A>> = {
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages)
dispatch: D,
getState(): S,
subscribe(listener: () => void): () => void,
replaceReducer(nextReducer: Reducer<S, A>): void,
};

declare export type Reducer<S, A> = (state: S | void, action: A) => S;

declare export type CombinedReducer<S, A> = (
state: ($Shape<S> & {}) | void,
action: A
) => S;

declare export type Middleware<S, A, D = Dispatch<A>> = (
api: MiddlewareAPI<S, A, D>
) => (next: D) => D;

declare export type StoreCreator<S, A, D = Dispatch<A>> = {
(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>,
(
reducer: Reducer<S, A>,
preloadedState: S,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>,
};

declare export type StoreEnhancer<S, A, D = Dispatch<A>> = (
next: StoreCreator<S, A, D>
) => StoreCreator<S, A, D>;

declare export function createStore<S, A, D>(
reducer: Reducer<S, A>,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>;
declare export function createStore<S, A, D>(
reducer: Reducer<S, A>,
preloadedState?: S,
enhancer?: StoreEnhancer<S, A, D>
): Store<S, A, D>;

declare export function applyMiddleware<S, A, D>(
...middlewares: Array<Middleware<S, A, D>>
): StoreEnhancer<S, A, D>;

declare export type ActionCreator<A, B> = (...args: Array<B>) => A;
declare export type ActionCreators<K, A> = {[key: K]: ActionCreator<A, any>};

declare export function bindActionCreators<
A,
C: ActionCreator<A, any>,
D: DispatchAPI<A>
>(
actionCreator: C,
dispatch: D
): C;
declare export function bindActionCreators<
A,
K,
C: ActionCreators<K, A>,
D: DispatchAPI<A>
>(
actionCreators: C,
dispatch: D
): C;

declare export function combineReducers<O: Object, A>(
reducers: O
): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>;

declare export var compose: $Compose;
}
5 changes: 4 additions & 1 deletion src/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import error from './error';

import type {State} from './types.js';

export default (state: State, action: Object) => {
export default (state?: State, action: Object) => {
if (!state) {
return {};
}
return {
count: count(state.count, action),
rpcCount: rpcCount(state.rpcCount, action),
Expand Down

0 comments on commit f12c473

Please sign in to comment.