Hi, great framework!
I have created a Quasar CLI project (1.9.5) using TypeScript. It all works great, but I’m getting a Typescript error when using
this.$router
outside a *.vue file
e.g.
this.$router.push(’/myPage’);
in ./store/module-example/actions.ts file.
The ERROR is: Property ‘$router’ does not exist on type ‘Store<StoreInterface>’.ts(2339)
Is it considered an anti-pattern to use router in actions.ts file or how can TypeScript be told about this.$router ?
Reason for usage in actions.ts file: I am using Firebase onAuthStateChanged. this.$router actually does work, but shows the error in VScode.
///actions.ts
const actions: ActionTree<ExampleStateInterface, StoreInterface> = {
handleAuthStateChanged({ commit }: { commit: any }) {
firebaseAuth.onAuthStateChanged(user => {
// Is triggered every time user state changes
if (user) {
// User is logged in
this.$router.push('myPage');
} else {
// User is logged out
this.$route.push('/login');
}
});
}
};