Home > other >  Property XXX does not exit on type 'Computed' using Typescript
Property XXX does not exit on type 'Computed' using Typescript

Time:11-25

The code runs and in the console for the browser prints out true. However on my local server I am getting an error Property 'authorities' does not exist on type 'Computed'. I am new to Typescript and Vuex. I checked and isAdmin is an object that has authorities that is an array

Here is my code

export default {
    name: "UserSettingsTabs",
      computed: {
    ...mapGetters({
      preferences: 'tab/preferences',
      administrations: 'tab/administrations',
      isAdmin: 'auth/currentUser'
    }),
    isUserAdmin() : boolean{
      console.log(this.isAdmin.authorities.includes('Admin'));
      return this.isAdmin.authorities.includes('Admin');
    }   }, }

CodePudding user response:

This is because you're using mapGetters which resolves isAdmin as a <Computed>

This is discussed here with some possible solutions

If you're ok with simple solution, you could use this.isAdmin as IIsAdmin with your custom interface or type.

You could also use a computed that pulls the value from vuex instead of using mapGetters.

  • Related