Open WesleyBuck opened 4 years ago
Same issue here, temporary fixed it like so:
// hacky solution since type declartion for restored is missing in vuex-persist
// waits for IndexedDB (localForage) to be loaded into vuex so mutations aren't overridden on start up
await ((store as unknown) as { restored: Promise<unknown> }).restored;
Use this workaround which worked for me: https://github.com/championswimmer/vuex-persist/issues/15#issuecomment-348308210
running into the same issue. the restored prop is not available... unable to use the suggested solutions above.
alright the solution is to provide asyncStorage: true
in the constructor options. This was not clear from the docs in the section 'notes on localForage'...
Same issue for me, solved with @BasNijhuis solution plus @Rinux55 solution. PLEASE ADD TO DOCS!
This stopped working for some reason, but I got it back by doing
await (store as any).original.restored;
in my router guard
and restoreState: key => localForage.getItem(key),
in const vuexLocalForage = new VuexPersistence<RootState>({
Currently, we have an older project that we are migrating from javascript to typescript. Implemented typescript router but still using javascript store. Tried npm install @types/vuex-persist with no such package available.
Ended up adding vuex-persist.d.ts, which solved the problem:
Is there a possibility to include types for future users that may experience the same problem?