@@ -2,11 +2,13 @@ export interface AnyAction {
2
2
type : any ;
3
3
}
4
4
5
+ export type Meta = null | { [ key : string ] : any } ;
6
+
5
7
export interface Action < P > extends AnyAction {
6
8
type : string ;
7
9
payload : P ;
8
10
error ?: boolean ;
9
- meta ?: Object | null ;
11
+ meta ?: Meta ;
10
12
}
11
13
12
14
export interface Success < P , S > {
@@ -28,11 +30,11 @@ export function isType<P>(
28
30
29
31
export interface ActionCreator < P > {
30
32
type : string ;
31
- ( payload : P , meta ?: Object | null ) : Action < P > ;
33
+ ( payload : P , meta ?: Meta ) : Action < P > ;
32
34
}
33
35
34
36
export interface EmptyActionCreator extends ActionCreator < undefined > {
35
- ( payload ?: undefined , meta ?: Object | null ) : Action < undefined > ;
37
+ ( payload ?: undefined , meta ?: Meta ) : Action < undefined > ;
36
38
}
37
39
38
40
export interface AsyncActionCreators < P , S , E > {
@@ -43,18 +45,18 @@ export interface AsyncActionCreators<P, S, E> {
43
45
}
44
46
45
47
export interface ActionCreatorFactory {
46
- ( type : string , commonMeta ?: Object | null ,
48
+ ( type : string , commonMeta ?: Meta ,
47
49
error ?: boolean ) : EmptyActionCreator ;
48
- < P > ( type : string , commonMeta ?: Object | null ,
50
+ < P > ( type : string , commonMeta ?: Meta ,
49
51
isError ?: boolean ) : ActionCreator < P > ;
50
- < P > ( type : string , commonMeta ?: Object | null ,
52
+ < P > ( type : string , commonMeta ?: Meta ,
51
53
isError ?: ( payload : P ) => boolean ) : ActionCreator < P > ;
52
54
53
55
async < P , S > (
54
- type : string , commonMeta ?: Object | null ,
56
+ type : string , commonMeta ?: Meta ,
55
57
) : AsyncActionCreators < P , S , any > ;
56
58
async < P , S , E > (
57
- type : string , commonMeta ?: Object | null ,
59
+ type : string , commonMeta ?: Meta ,
58
60
) : AsyncActionCreators < P , S , E > ;
59
61
}
60
62
@@ -74,7 +76,7 @@ export default function actionCreatorFactory(
74
76
const base = prefix ? `${ prefix } /` : "" ;
75
77
76
78
function actionCreator < P > (
77
- type : string , commonMeta ?: Object | null ,
79
+ type : string , commonMeta ?: Meta ,
78
80
isError : ( ( payload : P ) => boolean ) | boolean = defaultIsError ,
79
81
) : ActionCreator < P > {
80
82
const fullType = base + type ;
@@ -87,7 +89,7 @@ export default function actionCreatorFactory(
87
89
}
88
90
89
91
return Object . assign (
90
- ( payload : P , meta ?: Object | null ) => {
92
+ ( payload : P , meta ?: Meta ) => {
91
93
const action : Action < P > = {
92
94
type : fullType ,
93
95
payload,
@@ -108,7 +110,7 @@ export default function actionCreatorFactory(
108
110
}
109
111
110
112
function asyncActionCreators < P , S , E > (
111
- type : string , commonMeta ?: Object | null ,
113
+ type : string , commonMeta ?: Meta ,
112
114
) : AsyncActionCreators < P , S , E > {
113
115
return {
114
116
type : base + type ,
0 commit comments