[Vuejs]-Property does not exist on type 'never'

0๐Ÿ‘

// Here you say categories will be an array.
let categories = ref<BaseCategory[]>([]);

const getBaseCategories = async () => {
   await store.getBaseCategories();

   // here you treat categories as an object.
   categories.value = store.categories;

   // maybe this should be
   categories = store.categories;
};

0๐Ÿ‘

According to the async MutationAction === magic in your used module. You should tell your action to mutate which state like following code (mark1).

// ignore other codes .......
class BaseCategoryModule extends VuexModule {
  categories: IBaseCategory[] = [];

  // ========= mark1 =========
  @MutationAction({ mutate: ['categories'] })
  async getBaseCategories() {
    const result = await api.get('/v1/basecombicategories');
    const data = result.data as IBaseCategory[];

    return {
      categories: data,
    };
  }
}

export default getModule(BaseCategoryModule);

0๐Ÿ‘

Unbelievable โ€ฆ maybe I drunk to much ๐Ÿ™‚ There was another *.vue file with old code. I removed the old code and everything works perfectly. Shame on me !

0๐Ÿ‘

I was having problem with state, and I was need to declare object properties.
like this

I had to change this

  state: () => ({
    training: {},
   }),

to this

 state: () => ({
    training: { id: '', name: '' },
  }),

Leave a comment