Closed SeyyedKhandon closed 1 year ago
I know this question is pretty old, but for anyone else that stumbles upon it this is what I did:
const beforeEach = async (to: Route, from: Route, next: NavigationGuardNext): Promise<void> => {
// vuex-persist adds the restored property dynamically, wait for it so that state is ready
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await (store as any).restored
next()
}
I know this question is pretty old, but for anyone else that stumbles upon it this is what I did:
const beforeEach = async (to: Route, from: Route, next: NavigationGuardNext): Promise<void> => { // vuex-persist adds the restored property dynamically, wait for it so that state is ready // eslint-disable-next-line @typescript-eslint/no-explicit-any await (store as any).restored next() }
Is it ok to use any
? Can I use a specific type? What that type would be?
you may define your own type like:
type AsyncStorage = VuexStore<StateInterface> & { restored: Promise<boolean> }
and then use it:
await (store as AsyncStorage).restored
As the docs say we should use
await store.restored;
in the router guard when we uselocalforage
, everything is working, but the is an error which saysProperty 'restored' does not exist on type 'Store<State>'.ts(2339)
Further info:
How can we fix this?