-
Notifications
You must be signed in to change notification settings - Fork 863
/
Copy pathtypes.d.ts
151 lines (130 loc) · 3.63 KB
/
types.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
declare module "redux-persist/es/types" {
import { StoreEnhancer } from "redux";
interface PersistState {
version: number;
rehydrated: boolean;
}
type PersistedState = {
_persist: PersistState;
} | undefined;
type PersistMigrate =
(state: PersistedState, currentVersion: number) => Promise<PersistedState>;
type StateReconciler<S> =
(inboundState: any, state: S, reducedState: S, config: PersistConfig<S>) => S;
/**
* @desc
* `HSS` means HydratedSubState
* `ESS` means EndSubState
* `S` means State
* `RS` means RawState
*/
interface PersistConfig<S, RS = any, HSS = any, ESS = any> {
version?: number;
storage: Storage;
key: string;
/**
* @deprecated keyPrefix is going to be removed in v6.
*/
keyPrefix?: string;
blacklist?: Array<string>;
whitelist?: Array<string>;
transforms?: Array<Transform<HSS, ESS, S, RS>>;
throttle?: number;
migrate?: PersistMigrate;
stateReconciler?: false | StateReconciler<S>;
/**
* @desc Used for migrations.
*/
getStoredState?: (config: PersistConfig<S, RS, HSS, ESS>) => Promise<PersistedState>;
debug?: boolean;
serialize?: boolean;
timeout?: number;
writeFailHandler?: (err: Error) => void;
}
interface PersistorOptions {
enhancer?: StoreEnhancer<any>;
manualPersist?: boolean;
}
interface Storage {
getItem(key: string, ...args: Array<any>): any;
setItem(key: string, value: any, ...args: Array<any>): any;
removeItem(key: string, ...args: Array<any>): any;
}
interface WebStorage extends Storage {
/**
* @desc Fetches key and returns item in a promise.
*/
getItem(key: string): Promise<string | null>;
/**
* @desc Sets value for key and returns item in a promise.
*/
setItem(key: string, item: string): Promise<void>;
/**
* @desc Removes value for key.
*/
removeItem(key: string): Promise<void>;
}
interface MigrationManifest {
[key: string]: (state: PersistedState) => PersistedState;
}
/**
* @desc
* `SS` means SubState
* `ESS` means EndSubState
* `S` means State
*/
type TransformInbound<SS, ESS, S = any> =
(subState: SS, key: keyof S, state: S) => ESS;
/**
* @desc
* `SS` means SubState
* `HSS` means HydratedSubState
* `RS` means RawState
*/
type TransformOutbound<SS, HSS, RS = any> =
(state: SS, key: keyof RS, rawState: RS) => HSS;
interface Transform<HSS, ESS, S = any, RS = any> {
in: TransformInbound<HSS, ESS, S>;
out: TransformOutbound<ESS, HSS, RS>;
}
type RehydrateErrorType = any;
interface RehydrateAction {
type: 'persist/REHYDRATE';
key: string;
payload?: object | null;
err?: RehydrateErrorType | null;
}
interface Persistoid {
update(state: object): void;
flush(): Promise<any>;
}
interface RegisterAction {
type: 'persist/REGISTER';
key: string;
}
type PersistorAction =
| RehydrateAction
| RegisterAction
;
interface PersistorState {
registry: Array<string>;
bootstrapped: boolean;
}
type PersistorSubscribeCallback = () => any;
/**
* A persistor is a redux store unto itself, allowing you to purge stored state, flush all
* pending state serialization and immediately write to disk
*/
interface Persistor {
pause(): void;
persist(): void;
purge(): Promise<any>;
flush(): Promise<any>;
dispatch(action: PersistorAction): PersistorAction;
getState(): PersistorState;
subscribe(callback: PersistorSubscribeCallback): () => any;
}
}
declare module "redux-persist/lib/types" {
export * from "redux-persist/es/types";
}