Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ntraut opened this issue Dec 24, 2020 · 3 comments
Open
Labels

Comments

@ntraut
Copy link
Contributor

ntraut commented Dec 24, 2020

  • [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

@yoyo930021
Copy link
Member

yoyo930021 commented Dec 26, 2020

It's a type limit in Vuex.

Ref:
vuejs/vuex#1417
vuejs/vuex#1121

@yoyo930021
Copy link
Member

Temporarily open issue to confirm.

@ntraut
Copy link
Contributor Author

ntraut commented Dec 26, 2020

This problem is too complicated for I can understand it fully but what seems strange to me is that if there is only ...mapMutations we don't get any warning: even if we type the wrong name, vs code tells increment0 is a mutation method. But if we add another method with no link we get the warning.

In my opinion the warning should occur either in both cases or none of them...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants