Property xxx doest not exist on type xxx in store getters #475
-
Hello! I am having an issue within getters using the latest version of TS
And the error says: Property 'user' does not exist on type '{ currentUser(): any; }' Do you have any ideas on how to fix it? Is that a problem with the environment? I am using VSCode My package.json:
|
Beta Was this translation helpful? Give feedback.
Answered by
posva
May 5, 2021
Replies: 1 comment 2 replies
-
You need to explicitly type the getter if it uses getters: {
currentUser(): UserData {
return this.user.data?.user;
},
// or don't use `this` if possible
currentUser(state) {
return state.user.data?.user;
},
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
posva
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to explicitly type the getter if it uses
this
. See the example at https://pinia.esm.dev/core-concepts/getters.html