|
| 1 | +// flow-typed signature: 86993bd000012d3e1ef10d757d16952d |
| 2 | +// flow-typed version: a165222d28/redux_v3.x.x/flow_>=v0.33.x |
| 3 | + |
| 4 | +declare module 'redux' { |
| 5 | + |
| 6 | + /* |
| 7 | +
|
| 8 | + S = State |
| 9 | + A = Action |
| 10 | + D = Dispatch |
| 11 | +
|
| 12 | + */ |
| 13 | + |
| 14 | + declare type DispatchAPI<A> = (action: A) => A; |
| 15 | + declare type Dispatch<A: { type: $Subtype<string> }> = DispatchAPI<A>; |
| 16 | + |
| 17 | + declare type MiddlewareAPI<S, A, D = Dispatch<A>> = { |
| 18 | + dispatch: D; |
| 19 | + getState(): S; |
| 20 | + }; |
| 21 | + |
| 22 | + declare type Store<S, A, D = Dispatch<A>> = { |
| 23 | + // rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages) |
| 24 | + dispatch: D; |
| 25 | + getState(): S; |
| 26 | + subscribe(listener: () => void): () => void; |
| 27 | + replaceReducer(nextReducer: Reducer<S, A>): void |
| 28 | + }; |
| 29 | + |
| 30 | + declare type Reducer<S, A> = (state: S, action: A) => S; |
| 31 | + |
| 32 | + declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | void, action: A) => S; |
| 33 | + |
| 34 | + declare type Middleware<S, A, D = Dispatch<A>> = |
| 35 | + (api: MiddlewareAPI<S, A, D>) => |
| 36 | + (next: D) => D; |
| 37 | + |
| 38 | + declare type StoreCreator<S, A, D = Dispatch<A>> = { |
| 39 | + (reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>; |
| 40 | + (reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>; |
| 41 | + }; |
| 42 | + |
| 43 | + declare type StoreEnhancer<S, A, D = Dispatch<A>> = (next: StoreCreator<S, A, D>) => StoreCreator<S, A, D>; |
| 44 | + |
| 45 | + declare function createStore<S, A, D>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>; |
| 46 | + declare function createStore<S, A, D>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A, D>): Store<S, A, D>; |
| 47 | + |
| 48 | + declare function applyMiddleware<S, A, D>(...middlewares: Array<Middleware<S, A, D>>): StoreEnhancer<S, A, D>; |
| 49 | + |
| 50 | + declare type ActionCreator<A, B> = (...args: Array<B>) => A; |
| 51 | + declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> }; |
| 52 | + |
| 53 | + declare function bindActionCreators<A, C: ActionCreator<A, any>, D: DispatchAPI<A>>(actionCreator: C, dispatch: D): C; |
| 54 | + declare function bindActionCreators<A, K, C: ActionCreators<K, A>, D: DispatchAPI<A>>(actionCreators: C, dispatch: D): C; |
| 55 | + |
| 56 | + declare function combineReducers<O: Object, A>(reducers: O): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>; |
| 57 | + |
| 58 | + declare function compose<A, B>(ab: (a: A) => B): (a: A) => B |
| 59 | + declare function compose<A, B, C>( |
| 60 | + bc: (b: B) => C, |
| 61 | + ab: (a: A) => B |
| 62 | + ): (a: A) => C |
| 63 | + declare function compose<A, B, C, D>( |
| 64 | + cd: (c: C) => D, |
| 65 | + bc: (b: B) => C, |
| 66 | + ab: (a: A) => B |
| 67 | + ): (a: A) => D |
| 68 | + declare function compose<A, B, C, D, E>( |
| 69 | + de: (d: D) => E, |
| 70 | + cd: (c: C) => D, |
| 71 | + bc: (b: B) => C, |
| 72 | + ab: (a: A) => B |
| 73 | + ): (a: A) => E |
| 74 | + declare function compose<A, B, C, D, E, F>( |
| 75 | + ef: (e: E) => F, |
| 76 | + de: (d: D) => E, |
| 77 | + cd: (c: C) => D, |
| 78 | + bc: (b: B) => C, |
| 79 | + ab: (a: A) => B |
| 80 | + ): (a: A) => F |
| 81 | + declare function compose<A, B, C, D, E, F, G>( |
| 82 | + fg: (f: F) => G, |
| 83 | + ef: (e: E) => F, |
| 84 | + de: (d: D) => E, |
| 85 | + cd: (c: C) => D, |
| 86 | + bc: (b: B) => C, |
| 87 | + ab: (a: A) => B |
| 88 | + ): (a: A) => G |
| 89 | + declare function compose<A, B, C, D, E, F, G, H>( |
| 90 | + gh: (g: G) => H, |
| 91 | + fg: (f: F) => G, |
| 92 | + ef: (e: E) => F, |
| 93 | + de: (d: D) => E, |
| 94 | + cd: (c: C) => D, |
| 95 | + bc: (b: B) => C, |
| 96 | + ab: (a: A) => B |
| 97 | + ): (a: A) => H |
| 98 | + declare function compose<A, B, C, D, E, F, G, H, I>( |
| 99 | + hi: (h: H) => I, |
| 100 | + gh: (g: G) => H, |
| 101 | + fg: (f: F) => G, |
| 102 | + ef: (e: E) => F, |
| 103 | + de: (d: D) => E, |
| 104 | + cd: (c: C) => D, |
| 105 | + bc: (b: B) => C, |
| 106 | + ab: (a: A) => B |
| 107 | + ): (a: A) => I |
| 108 | + |
| 109 | +} |
0 commit comments