Skip to content

Mutation not recognized when imported with mapMutations next to other methods #2592

@ntraut

Description

@ntraut
  • [x ] I have searched through existing issues
  • [x ] I have read through docs
  • [x ] I have read FAQ
  • [x ] I have tried restarting VS Code or running Vetur: Restart VLS

Info

  • Platform: Win
  • Vetur version: 0.31.3
  • VS Code version: 1.52.1

Problem

I try to import a mutation with the method ...mapMutations. If this is the only method in my vue file can use it without any warning. I have this in my script section:

  methods: {
    ...mapMutations(['increment'])
  }

and this in my template section:

<button @click="increment">X</button>

But if I add another method which is independent from my initial method:

  methods: {
    method2() {
      console.log('method2')
    },
    ...mapMutations(['increment'])
  }

I get the following error in my template:

Property 'increment' does not exist on type 'CombinedVueInstance<{ method2(): void; } & Record<never, any> & Vue, object, object, object, Record<never, any>>'.

The vue app is still working, I only get the error in vscode.

Reproducible Case

I did a minimal example starting from vue hello world:
https://github.com/ntraut/vue-hello-world

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions