Accessing state directly can be ok for some cases, but in others we need another representation of state.
This lesson will show you how Vuex getters solve that issue and how to type-safe these getters with TypeScript using the @Getter
decorator.
What is the advantage of using @Getter instead of :
get dones {
return this.$store.getters.dones
}
Just convenience, under the hood it does something like that. Decorators make it more declarative and easier to type.
Hi, I'm following the lesson, but I'm getting "Property 'todos' has no initializer and is not definitely assigned in the constructor.", unless I declare it like this @Getter todos!: Todo[];
, and I wonder if this the proper way of doing it?
I'm having the same issue as Ali, it's a good question.