championswimmer / vuex-module-decorators

TypeScript/ES7 Decorators to create Vuex modules declaratively
https://championswimmer.in/vuex-module-decorators/
MIT License
1.8k stars 170 forks source link

Update README.md to reflect `this` type on MutationAction #374

Closed NikhilVerma closed 2 years ago

NikhilVerma commented 3 years ago

From this PR https://github.com/championswimmer/vuex-module-decorators/issues/372 it's evident that people can misunderstand how MutationAction works.

By updating the documentation to explain how to correctly set the this type inside it will help them to understand how the context works for that decorator.

hlysine commented 3 years ago

This feels like a dirty workaround, and Typescript still throws an error when this MutationAction is called:

import HGAPIModule from './path/to/HGAPIModule.ts`;

await HGAPIModule.fetchAll();
// The 'this' context of type 'HGAPIModule' is not assignable to method's 'this' of type 'Store<HGAPIModule>'.
championswimmer commented 2 years ago

This has been fixed actually. This is the state now.