Skip to content

Methods not found when using mapGetters #21

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

Closed
LeanderD opened this issue Nov 10, 2020 · 5 comments
Closed

Methods not found when using mapGetters #21

LeanderD opened this issue Nov 10, 2020 · 5 comments
Labels
question Further information is requested

Comments

@LeanderD
Copy link

First I would like to say that I like this extension. It's working well!

In my code I'm using mapGetters to well.. map the getters from my Vuex store.
Unfortunately, this is not working with Volar. It says it can't find these methods.

A "solution" would be to not use the mapGetters of course, but to me that's not really an option.
Hope this can be fixed!

@johnsoncodehk
Copy link
Member

Thanks for your attention and report! I didn't use vuex, but I searched and tested projects using mapGetters from github, and it seems to work. Can you give me a reproduction project?

@LeanderD
Copy link
Author

LeanderD commented Nov 10, 2020

I am using vue-class-component. So that probably has something to do with it.
The project is also set up as a mono-repo. I did have some issues with that before (with other extensions and resolving paths etc), but those have been resolved.

A simple component looks like this:

<template>
    <div>{{ getSomething(param) }}</div>
</template>

<script lang="ts">
import { Options, Vue } from 'vue-class-component';
import { mapGetters } from 'vuex';

@Options({
    computed: {
        ...mapGetters(['getSomething']),
    },
})
export default class SimpleComponent extends Vue {}

In this case it would tell me that it can't find getSomething (the one in the template).
It will build and work.. it just shows me an error in the editor.

Hope this is clear enough. Thanks for making this amazing extension!

@johnsoncodehk
Copy link
Member

johnsoncodehk commented Nov 11, 2020

I am not familiar with vue-class-component. I asked someone familiar with it. The problem is not from mapGetters, but because @Options decorator has no effect on the type. Decorator is runtime only. You need to use mixins instead.

I'm not sure if this is the best solution, so I suggest you propose it here: https://github.com/vuejs/vue-class-component/issues

@LeanderD
Copy link
Author

LeanderD commented Nov 12, 2020

Thank you for your answer! That does make sense. I will take a look at it!

Edit:
I found an answer there indeed:
vuejs/vue-class-component#109 (comment)

Thank you for your help!

@johnsoncodehk
Copy link
Member

Thanks for the update!

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

No branches or pull requests

2 participants