|
| 1 | +declare module "redux-persist/lib/interfaces" { |
| 2 | + export { |
| 3 | + Store, |
| 4 | + StoreEnhancer, |
| 5 | + } from "redux"; |
| 6 | + |
| 7 | + export interface Storage { |
| 8 | + setItem: Function; |
| 9 | + getItem: Function; |
| 10 | + removeItem: Function; |
| 11 | + getAllKeys: Function; |
| 12 | + } |
| 13 | + |
| 14 | + export interface PersistorConfig { |
| 15 | + blacklist?: string[]; |
| 16 | + whitelist?: string[]; |
| 17 | + storage?: Storage; |
| 18 | + transforms?: Array<Transform<any, any>>; |
| 19 | + debounce?: number; |
| 20 | + serialize?: boolean; |
| 21 | + } |
| 22 | + |
| 23 | + export interface TransformIn<State, Raw> { |
| 24 | + (state: State, key: string): Raw; |
| 25 | + } |
| 26 | + |
| 27 | + export interface TransformOut<Raw, State> { |
| 28 | + (raw: Raw, key: string): State; |
| 29 | + } |
| 30 | + |
| 31 | + export interface Transform<State, Raw> { |
| 32 | + in: TransformIn<State, Raw>; |
| 33 | + out: TransformOut<Raw, State>; |
| 34 | + } |
| 35 | + |
| 36 | + export interface OnComplete { |
| 37 | + (err?: any, result?: Object): void; |
| 38 | + } |
| 39 | + |
| 40 | + export interface Persistor { |
| 41 | + purge: (keys: string[]) => void; |
| 42 | + rehydrate: (incoming: Object, options: { serial: boolean }) => void; |
| 43 | + pause: () => void; |
| 44 | + resume: () => void; |
| 45 | + } |
| 46 | + |
| 47 | + export interface StateReconciler<PrevState, NextState> { |
| 48 | + (state: PrevState, inboundState: Object, reducedState: Object, log: boolean): NextState; |
| 49 | + } |
| 50 | + |
| 51 | + export interface AutoRehydrateConfig { |
| 52 | + log?: boolean; |
| 53 | + stateReconciler?: StateReconciler<any, any>; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +declare module "redux-persist/lib/autoRehydrate" { |
| 58 | + import { |
| 59 | + StoreEnhancer, |
| 60 | + AutoRehydrateConfig, |
| 61 | + } from "redux-persist/lib/interfaces"; |
| 62 | + |
| 63 | + function autoRehydrate<State>(autoRehydrateConfig: AutoRehydrateConfig): StoreEnhancer<State>; |
| 64 | + |
| 65 | + export default autoRehydrate; |
| 66 | +} |
| 67 | + |
| 68 | +declare module "redux-persist/lib/createPersistor" { |
| 69 | + import { |
| 70 | + Store, |
| 71 | + PersistorConfig, |
| 72 | + Persistor, |
| 73 | + } from "redux-persist/lib/interfaces"; |
| 74 | + |
| 75 | + function createPersistor<State>(store: Store<State>, persistorConfig: PersistorConfig): Persistor; |
| 76 | + |
| 77 | + export default createPersistor; |
| 78 | +} |
| 79 | + |
| 80 | +declare module "redux-persist/lib/createTransform" { |
| 81 | + import { |
| 82 | + TransformIn, |
| 83 | + TransformOut, |
| 84 | + Transform, |
| 85 | + } from "redux-persist/lib/interfaces"; |
| 86 | + |
| 87 | + export interface TransformConfig { |
| 88 | + whitelist?: string[]; |
| 89 | + blacklist?: string[]; |
| 90 | + } |
| 91 | + |
| 92 | + function createTransform<State, Raw>(transformIn: TransformIn<State, Raw>, transformOut: TransformOut<Raw, State>, config: TransformConfig): Transform<State, Raw>; |
| 93 | + |
| 94 | + export default createTransform; |
| 95 | +} |
| 96 | + |
| 97 | +declare module "redux-persist/lib/getStoredState" { |
| 98 | + import { |
| 99 | + OnComplete, |
| 100 | + PersistorConfig, |
| 101 | + } from "redux-persist/lib/interfaces"; |
| 102 | + |
| 103 | + function getStoredState(persistorConfig: PersistorConfig, onComplete: OnComplete): void; |
| 104 | + |
| 105 | + export default getStoredState; |
| 106 | +} |
| 107 | + |
| 108 | +declare module "redux-persist/lib/persistStore" { |
| 109 | + import { |
| 110 | + OnComplete, |
| 111 | + Store, |
| 112 | + PersistorConfig, |
| 113 | + Persistor, |
| 114 | + } from "redux-persist/lib/interfaces"; |
| 115 | + |
| 116 | + function persistStore<State>(store: Store<State>, persistorConfig: PersistorConfig, onComplete: OnComplete): Persistor; |
| 117 | + |
| 118 | + export default persistStore; |
| 119 | +} |
| 120 | + |
| 121 | +declare module "redux-persist/lib/purgeStoredState" { |
| 122 | + import { |
| 123 | + PersistorConfig, |
| 124 | + } from "redux-persist/lib/interfaces"; |
| 125 | + |
| 126 | + function purgeStoredState(persistorConfig: PersistorConfig, keys: string[]): Promise<void>; |
| 127 | + |
| 128 | + export default purgeStoredState; |
| 129 | +} |
| 130 | + |
| 131 | +declare module "redux-persist" { |
| 132 | + export { Storage } from "redux-persist/lib/interfaces"; |
| 133 | + |
| 134 | + export { default as autoRehydrate } from "redux-persist/lib/autoRehydrate"; |
| 135 | + export { default as createPersistor } from "redux-persist/lib/createPersistor"; |
| 136 | + export { default as createTransform } from "redux-persist/lib/createTransform"; |
| 137 | + export { default as getStoredState } from "redux-persist/lib/getStoredState"; |
| 138 | + export { default as persistStore } from "redux-persist/lib/persistStore"; |
| 139 | + export { default as purgeStoredState } from "redux-persist/lib/purgeStoredState"; |
| 140 | + |
| 141 | + export const storages: { |
| 142 | + asyncLocalStorage: Storage, |
| 143 | + asyncSessionStorage: Storage, |
| 144 | + }; |
| 145 | +} |
0 commit comments