Skip to content

Typescript issue with getter within getter #2685

Closed Answered by posva
Glandos asked this question in Help and Questions
Discussion options

You must be logged in to vote

You probably need to explicitly type some of the getters or actions to avoid a cyclic type reference (that’s why you might see any)

Edit: yes that's what's missing:

export const useOtherStore = defineStore('second_store', {
  getters: {
    currentId() {
      return 1
    },
    addedId() {
      return useStore().added(1).result
    },
    addedIdBug(): number {
      return useStore().added(this.currentId).result
    },
  },
})

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2684 on June 06, 2024 20:13.