Skip to content

Vuex/Typescript mappers issue: property does not exist on type 'CombinedVueInstance<Vue, ...>' #1220

@mzymta

Description

@mzymta

Version

3.0.1

Reproduction link

https://github.com/mzymta/vuex-mappers-issue

Steps to reproduce

Add mapped methods using mapMutations, mapActions, create another component method that uses any of the mapped methods. Build fails with error:

Error: Property NAME_OF_MAPPED_METHOD does not exist on type 'CombinedVueInstance<Vue, ...>'

The below code works fine if there is no methodThatUsesActionOrMutation() method.
With methodThatUsesActionOrMutation() method build fails with error:

TS2339: Property 'pushStringArray' does not exist on type 'CombinedVueInstance<Vue, {}, { methodThatUsesActionOrMutation(): void; }, { newStr: any; getLongS...'.

import Vue from 'vue';
import {mapActions, mapGetters, mapMutations} from 'vuex'

export default Vue.extend({
  computed: {
    ...mapGetters({
      getStringsArray: 'getStringsArray'
    }),
    newStr: {
      get(): string {
        return this.$store.state.newStr;
      },
      set(value: string) {
        this.$store.commit('setNewStr', value);
      }
    }
  },
  methods: {
    ...mapMutations({
      pushStringArray: 'pushStringArray'
    }),
    ...mapActions({
      pushStringArrayAsync: 'pushStringArrayAsync'
    }),
    methodThatUsesActionOrMutation() {
      // HERE COMES THE ERROR
      this.pushStringArray();
      console.log('done');
    }
  }
}

What is expected?

mapped method pushStringArray() can be used in other component methods - build doesn't fail

What is actually happening?

Build fails with error:
TS2339: Property 'pushStringArray' does not exist on type 'CombinedVueInstance<Vue, {}, { methodThatUsesActionOrMutation(): void; }, { newStr: any; }, Reado...'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions