|
| 1 | +// Type definitions for redux-actions v0.8.0 |
| 2 | +// Project: https://github.com/acdlite/redux-actions |
| 3 | +// Definitions by: Jack Hsu <https://github.com/jaysoo>, Alex Gorbatchev <https://github.com/alexgorbatchev> |
| 4 | +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
| 5 | + |
| 6 | +declare namespace ReduxActions { |
| 7 | + // FSA-compliant action. |
| 8 | + // See: https://github.com/acdlite/flux-standard-action |
| 9 | + interface BaseAction { |
| 10 | + type: string |
| 11 | + } |
| 12 | + |
| 13 | + interface Action<Payload> extends BaseAction { |
| 14 | + payload?: Payload |
| 15 | + error?: boolean |
| 16 | + meta?: any |
| 17 | + } |
| 18 | + |
| 19 | + interface ActionMeta<Payload, Meta> extends Action<Payload> { |
| 20 | + meta: Meta |
| 21 | + } |
| 22 | + |
| 23 | + type PayloadCreator<Input, Payload> = (...args: Input[]) => Payload; |
| 24 | + |
| 25 | + type MetaCreator<Input, Payload> = (...args: Input[]) => Payload; |
| 26 | + |
| 27 | + type Reducer<Payload> = (state: Payload, action: Action<Payload>) => Payload; |
| 28 | + |
| 29 | + type ReducerMeta<Payload, Meta> = (state: Payload, action: ActionMeta<Payload, Meta>) => Payload; |
| 30 | + |
| 31 | + type ReducerMap<Payload> = { |
| 32 | + [actionType: string]: Reducer<Payload> |
| 33 | + }; |
| 34 | + |
| 35 | + export function createAction( |
| 36 | + actionType: string, |
| 37 | + payloadCreator?: PayloadCreator<any, any>, |
| 38 | + metaCreator?: MetaCreator<any, any> |
| 39 | + ): (...args: any[]) => Action<any>; |
| 40 | + |
| 41 | + export function createAction<InputAndPayload>( |
| 42 | + actionType: string, |
| 43 | + payloadCreator?: PayloadCreator<InputAndPayload, InputAndPayload> |
| 44 | + ): (...args: InputAndPayload[]) => Action<InputAndPayload>; |
| 45 | + |
| 46 | + export function createAction<Input, Payload>( |
| 47 | + actionType: string, |
| 48 | + payloadCreator?: PayloadCreator<Input, Payload> |
| 49 | + ): (...args: Input[]) => Action<Payload>; |
| 50 | + |
| 51 | + export function createAction<Input, Payload, Meta>( |
| 52 | + actionType: string, |
| 53 | + payloadCreator: PayloadCreator<Input, Payload>, |
| 54 | + metaCreator: MetaCreator<Input, Meta> |
| 55 | + ): (...args: Input[]) => ActionMeta<Payload, Meta>; |
| 56 | + |
| 57 | + export function handleAction<Payload>( |
| 58 | + actionType: string, |
| 59 | + reducer: Reducer<Payload> | ReducerMap<Payload> |
| 60 | + ): Reducer<Payload>; |
| 61 | + |
| 62 | + export function handleAction<Payload, Meta>( |
| 63 | + actionType: string, |
| 64 | + reducer: ReducerMeta<Payload, Meta> | ReducerMap<Payload> |
| 65 | + ): Reducer<Payload>; |
| 66 | + |
| 67 | + export function handleActions<Payload>(reducerMap: ReducerMap<Payload>, initialState?: Payload): Reducer<Payload>; |
| 68 | +} |
| 69 | + |
| 70 | +declare module 'redux-actions' { |
| 71 | + export = ReduxActions; |
| 72 | +} |
| 73 | + |
0 commit comments