When utilizing mapGetters
, TypeScript lacks insight into the getters linked to the Vue component, leading to error messages. For instance:
import Vue from 'vue';
import { mapActions, mapGetters } from 'vuex';
export default Vue.extend({
computed: {
...mapGetters('ui', ['navCollapsed']),
minimizerIconClass(): string {
return `fa${this.navCollapsed ? '' : 'r'} fa-window-maximize`;
},
},
TypeScript is flagging an issue related to this.navCollapsed
:
TS2339: Property 'navCollapsed' does not exist on type 'CombinedVueInstance<Vue, {}, { openMobileMenu(): void; }, { minimizerIconClass: string; }, Readon...'.
How can this be resolved? One possible workaround is to avoid using mapGetters()
.