Skip to content

Commit 1231f8a

Browse files
Adds redux-actions TSD
1 parent ffc05c5 commit 1231f8a

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

tsd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"commit": "d969b903d1fce89a5e43828ec68458b4f852db4d"
6767
},
6868
"redux-actions/redux-actions.d.ts": {
69-
"commit": "544a35a10866b32afda9c7f029c0764558563f4f"
69+
"commit": "6052959591c9bc6f8463c58220965c7030ba934d"
7070
}
7171
}
7272
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+

typings/tsd.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
/// <reference path="orchestrator/orchestrator.d.ts" />
2222
/// <reference path="q/Q.d.ts" />
2323
/// <reference path="isomorphic-fetch/isomorphic-fetch.d.ts" />
24+
/// <reference path="redux-actions/redux-actions.d.ts" />

0 commit comments

Comments
 (0)