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