-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathredux-location-state.d.ts
75 lines (68 loc) · 2.63 KB
/
redux-location-state.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
declare module 'redux-location-state' {
import type {Dispatch, Middleware, PayloadAction, Reducer, Store} from '@reduxjs/toolkit';
import type {History, Location} from 'history';
import type {LOCATION_POP, LOCATION_PUSH} from 'redux-location-state/lib/constants';
export function listenForHistoryChange(store: Store, history: History): void;
export interface ParamSetup {
[key: string]: {
[key: string]: {
stateKey: string;
type?: 'array' | 'bool' | 'number' | 'object' | 'date';
initialState?: any;
options?: {
shouldPush?: boolean;
isFlags?: boolean;
delimiter?: string;
keepOrder?: boolean;
serialize?: (value: any) => string;
parse?: (value: string) => any;
};
};
};
}
export interface LocationWithQuery extends Location {
query: Record<string, any>;
}
export function createReduxLocationActions<S = any, A extends Action = AnyAction, P = S>(
paramSetup: ParamSetup,
mergeLocationToState: any,
history: History,
rootReducer: Reducer<S, A, P>,
overwriteLocationHandling: (
setupObject: ParamSetup,
nextState: S,
location: Location,
) => {location: Location; shouldPush: boolean},
): {
locationMiddleware: Middleware<
{},
S,
Dispatch<
| PayloadAction<Location, typeof LOCATION_PUSH>
| PayloadAction<Location, typeof LOCATION_POP>
>
>;
};
}
declare module 'redux-location-state/lib/parseQuery' {
import type {ParamSetup} from 'redux-location-state';
export function parseQuery(setupObject: ParamSetup, payload: any): Record<string, any>;
}
declare module 'redux-location-state/lib/constants' {
export const LOCATION_PUSH: 'REDUX-LOCATION-POP-ACTION';
export const LOCATION_POP: 'REDUX-LOCATION-PUSH-ACTION';
}
declare module 'redux-location-state/lib/helpers' {
import type {Location} from 'history';
import type {ParamSetup} from 'redux-location-state';
export function getMatchingDeclaredPath(setupObject: ParamSetup, location: Location): string;
}
declare module 'redux-location-state/lib/stateToParams' {
import type {Location} from 'history';
import type {ParamSetup} from 'redux-location-state';
export function stateToParams<S, L extends Location>(
setupObject: ParamSetup,
state: S,
location: L,
): {location: L; shouldPush: boolean};
}