Vuex MutationAction decorator not assignable to TypedPropertyDescriptor

157 Views Asked by At

I'm new to Typescript and sorry in advance if this is a newbie issue.

I don't know how to fix this TS error:

@Module({ namespaced: true, name: "Admin" })
class Admin extends VuexModule {
  public adminUserList: UserList = [];

  @MutationAction({ mutate: ["adminUserList"] })
  async getAdminUserList(): Promise<Record<string, UserList>> {
    const req = (await Utils.async({
      data: adminUserList,
    })) as Record<string, UserList>;

    return {
      adminUserList: req.data as UserList,
    };
  }
}

enter image description here

1

There are 1 best solutions below

0
On

Ok so I just needed to change the return type of the action.

@Module({ namespaced: true, name: "Admin" })
class Admin extends VuexModule {
  public adminUserList: UserList = [];

  @MutationAction({ mutate: ["adminUserList"] })
  async getAdminUserList(): Promise<Record<"adminUserList", UserList>> {
    const req = (await Utils.async({
      data: adminUserList,
    })) as Record<string, UserList>;

    return {
      adminUserList: req.data as UserList,
    };
  }
}