'How to do getter with parameter using vuex-module-decorators?

I'm trying to implement a vuex getter function (with parameter) using the Typescript/ES7 Decorators provided by vuex-module-decorators.

the normal vuex implementation would look like this:

export default new Vuex.Store({
    state: {
        students: []
    },
    getters: {
        findStudent: state => id => state.students.find(s => s.id == id)
    }
})

The vuex-module-decorators style guide says to use Typescript getter accessor

@Module
class MyModule extends VuexModule {
  students = []

  get findStudent(id) {
    return students.find(s => s.id == id)
  }
}

Therefor, of course my linter complains A 'get' accessor cannot have parameters

What would then be the best practice to implement such getter? Or should do the logic of such function into my vue component?



Solution 1:[1]

From github

Return a function from the getter

get getUser() { return function (id: string) { /* ... */ } }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mike Two