-
Notifications
You must be signed in to change notification settings - Fork 30.4k
/
Copy pathindex.d.ts
208 lines (168 loc) · 7.37 KB
/
index.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
export as namespace ReduxActions;
// FSA-compliant action.
// See: https://github.com/acdlite/flux-standard-action
export interface BaseAction {
type: string;
}
export interface Action<Payload> extends BaseAction {
payload: Payload;
error?: boolean | undefined;
}
export interface ActionMeta<Payload, Meta> extends Action<Payload> {
meta: Meta;
}
// https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/combineActions.js#L27
export interface CombinedActionType {
_dummy: undefined;
}
export type ReducerMapValue<State, Payload> =
| Reducer<State, Payload>
| ReducerNextThrow<State, Payload>
| ReducerMap<State, Payload>;
export interface ReducerMap<State, Payload> {
[actionType: string]: ReducerMapValue<State, Payload>;
}
export interface ReducerMapMeta<State, Payload, Meta> {
[actionType: string]:
| ReducerMeta<State, Payload, Meta>
| ReducerNextThrowMeta<State, Payload, Meta>
| ReducerMapMeta<State, Payload, Meta>;
}
export interface ReducerNextThrow<State, Payload> {
next?(state: State, action: Action<Payload>): State;
throw?(state: State, action: Action<Payload>): State;
}
export interface ReducerNextThrowMeta<State, Payload, Meta> {
next?(state: State, action: ActionMeta<Payload, Meta>): State;
throw?(state: State, action: ActionMeta<Payload, Meta>): State;
}
export type BaseActionFunctions<TAction> =
| ActionFunction0<TAction>
| ActionFunction1<any, TAction>
| ActionFunction2<any, any, TAction>
| ActionFunction3<any, any, any, TAction>
| ActionFunction4<any, any, any, any, TAction>
| ActionFunctionAny<TAction>;
export type ActionFunctions<Payload> = BaseActionFunctions<Action<Payload>>;
export type ActionWithMetaFunctions<Payload, Meta> = BaseActionFunctions<ActionMeta<Payload, Meta>>;
export type Reducer<State, Payload> = (state: State, action: Action<Payload>) => State;
export type ReducerMeta<State, Payload, Meta> = (state: State, action: ActionMeta<Payload, Meta>) => State;
export type ReduxCompatibleReducer<State, Payload> = (state: State | undefined, action: Action<Payload>) => State;
export type ReduxCompatibleReducerMeta<State, Payload, Meta> = (
state: State | undefined,
action: ActionMeta<Payload, Meta>,
) => State;
/** argument inferring borrowed from lodash definitions */
export type ActionFunction0<R> = () => R;
export type ActionFunction1<T1, R> = (t1: T1) => R;
export type ActionFunction2<T1, T2, R> = (t1: T1, t2: T2) => R;
export type ActionFunction3<T1, T2, T3, R> = (t1: T1, t2: T2, t3: T3) => R;
export type ActionFunction4<T1, T2, T3, T4, R> = (t1: T1, t2: T2, t3: T3, t4: T4) => R;
export type ActionFunctionAny<R> = (...args: any[]) => R;
// https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/createAction.js#L6
export function createAction(
actionType: string,
): ActionFunctionAny<Action<any>>;
export function createAction<Payload>(
actionType: string,
payloadCreator: ActionFunction0<Payload>,
): ActionFunction0<Action<Payload>>;
export function createAction<Payload, Arg1>(
actionType: string,
payloadCreator: ActionFunction1<Arg1, Payload>,
): ActionFunction1<Arg1, Action<Payload>>;
export function createAction<Payload, Arg1, Arg2>(
actionType: string,
payloadCreator: ActionFunction2<Arg1, Arg2, Payload>,
): ActionFunction2<Arg1, Arg2, Action<Payload>>;
export function createAction<Payload, Arg1, Arg2, Arg3>(
actionType: string,
payloadCreator: ActionFunction3<Arg1, Arg2, Arg3, Payload>,
): ActionFunction3<Arg1, Arg2, Arg3, Action<Payload>>;
export function createAction<Payload, Arg1, Arg2, Arg3, Arg4>(
actionType: string,
payloadCreator: ActionFunction4<Arg1, Arg2, Arg3, Arg4, Payload>,
): ActionFunction4<Arg1, Arg2, Arg3, Arg4, Action<Payload>>;
export function createAction<Payload>(
actionType: string,
): ActionFunction1<Payload, Action<Payload>>;
export function createAction<Meta>(
actionType: string,
payloadCreator: null | undefined,
metaCreator: ActionFunctionAny<Meta>,
): ActionFunctionAny<ActionMeta<any, Meta>>;
export function createAction<Payload, Meta>(
actionType: string,
payloadCreator: ActionFunctionAny<Payload>,
metaCreator: ActionFunctionAny<Meta>,
): ActionFunctionAny<ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1>(
actionType: string,
payloadCreator: ActionFunction1<Arg1, Payload>,
metaCreator: ActionFunction1<Arg1, Meta>,
): ActionFunction1<Arg1, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2>(
actionType: string,
payloadCreator: ActionFunction2<Arg1, Arg2, Payload>,
metaCreator: ActionFunction2<Arg1, Arg2, Meta>,
): ActionFunction2<Arg1, Arg2, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2, Arg3>(
actionType: string,
payloadCreator: ActionFunction3<Arg1, Arg2, Arg3, Payload>,
metaCreator: ActionFunction3<Arg1, Arg2, Arg3, Meta>,
): ActionFunction3<Arg1, Arg2, Arg3, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2, Arg3, Arg4>(
actionType: string,
payloadCreator: ActionFunction4<Arg1, Arg2, Arg3, Arg4, Payload>,
metaCreator: ActionFunction4<Arg1, Arg2, Arg3, Arg4, Meta>,
): ActionFunction4<Arg1, Arg2, Arg3, Arg4, ActionMeta<Payload, Meta>>;
export function handleAction<State, Payload>(
actionType: string | ActionFunctions<Payload> | CombinedActionType,
reducer: Reducer<State, Payload> | ReducerNextThrow<State, Payload>,
initialState: State,
): ReduxCompatibleReducer<State, Payload>;
export function handleAction<State, Payload, Meta>(
actionType: string | ActionWithMetaFunctions<Payload, Meta> | CombinedActionType,
reducer: ReducerMeta<State, Payload, Meta> | ReducerNextThrowMeta<State, Payload, Meta>,
initialState: State,
): ReduxCompatibleReducerMeta<State, Payload, Meta>;
export interface Options {
prefix?: string | undefined;
namespace?: string | undefined;
}
export function handleActions<StateAndPayload>(
reducerMap: ReducerMap<StateAndPayload, StateAndPayload>,
initialState: StateAndPayload,
options?: Options,
): ReduxCompatibleReducer<StateAndPayload, StateAndPayload>;
export function handleActions<State, Payload>(
reducerMap: ReducerMap<State, Payload>,
initialState: State,
options?: Options,
): ReduxCompatibleReducer<State, Payload>;
export function handleActions<State, Payload, Meta>(
reducerMap: ReducerMapMeta<State, Payload, Meta>,
initialState: State,
options?: Options,
): ReduxCompatibleReducerMeta<State, Payload, Meta>;
// https://github.com/redux-utilities/redux-actions/blob/v2.3.0/src/combineActions.js#L21
export function combineActions(...actionTypes: Array<ActionFunctions<any> | string | symbol>): CombinedActionType;
export interface ActionMap<Payload, Meta> {
[actionType: string]:
| ActionMap<Payload, Meta>
| ActionFunctionAny<Payload>
| [ActionFunctionAny<Payload>, ActionFunctionAny<Meta>]
| undefined;
}
export function createActions<Payload>(
actionMapOrIdentityAction: ActionMap<Payload, any> | string,
...identityActions: Array<string | Options>
): {
[actionName: string]: ActionFunctionAny<Action<Payload>>;
};
export function createActions(
actionMapOrIdentityAction: ActionMap<any, any> | string,
...identityActions: Array<string | Options>
): {
[actionName: string]: ActionFunctionAny<Action<any>>;
};