-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
60 lines (45 loc) · 1.99 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
import { Action, Middleware } from 'redux';
export type Enhancement = object;
export type EnhancerId = string | symbol;
type ActionEnhancerByIdShape = {
readonly id: EnhancerId;
};
type ActionEnhancerByTypeShape = {
actionTypes: string[];
};
type MapState<Enhancement, State, Value> = {
mapState: [Value] extends [never] ?
(state: State) => Enhancement :
(state: State, value: Value) => Enhancement;
};
export type ActionEnhancerById<E extends Enhancement, State = unknown, Value = never> =
ActionEnhancerByIdShape & MapState<E, State, Value>;
export type ActionEnhancerByType<E extends Enhancement, State = unknown, Value = never> =
ActionEnhancerByTypeShape & MapState<E, State, Value>;
export type ActionEnhancer<E extends Enhancement, State = unknown, Value = never> =
ActionEnhancerById<E, State, Value> | ActionEnhancerByType<E, State, Value>;
export type UnenhancedAction<T> = Action<T> & {
[index: string]: any;
};
export type EnhancedAction<
A extends Action,
E1 extends Enhancement,
E2 extends Enhancement = E1,
E3 extends Enhancement = E1,
E4 extends Enhancement = E1,
E5 extends Enhancement = E1,
E6 extends Enhancement = E1,
E7 extends Enhancement = E1,
E8 extends Enhancement = E1,
E9 extends Enhancement = E1
> = A & E1 & E2 & E3 & E4 & E5 & E6 & E7 & E8 & E9;
export type AnyEnhancer<State = unknown> =
ActionEnhancer<Enhancement, State, any> |
ActionEnhancer<Enhancement, State, never>;
declare function isEnhancerById<E extends Enhancement, State = unknown, Value = never>(e: ActionEnhancer<E, State, Value>): e is ActionEnhancerById<E, State, Value>;
declare function isEnhancerByType<E extends Enhancement, State = unknown, Value = never>(e: ActionEnhancer<E, State, Value>): e is ActionEnhancerByType<E, State, Value>;
export {isEnhancerById, isEnhancerByType};
declare function createActionEnhancerMiddleware<S = unknown>(
getEnhancers: ((state: S) => AnyEnhancer<S>[]) | AnyEnhancer<S>[]
): Middleware;
export default createActionEnhancerMiddleware;