Skip to content

Obtaining type of the store's instance through typeof #1054

Closed Answered by soc221b
DamianGlowala asked this question in Help and Questions
Discussion options

You must be logged in to vote

Is this what you need? 🤔

const useCounterStore = defineStore('counter', () => {
  const current = ref(0)
  const double = computed(() => current.value * 2)
  const increment = () => current.value++

  return {
    current,
    double,
    increment,
  }
})

type UseNullStore = ReturnType<typeof defineStore>
type NullStore = ReturnType<UseNullStore>
type CounterStore = ReturnType<typeof useCounterStore>
type CounterStoreSGA = Omit<CounterStore, keyof NullStore>

SGA: State, Getter, Action

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@DamianGlowala
Comment options

@yuqianma
Comment options

@kenny-reyes
Comment options

@svetamazz
Comment options

Answer selected by DamianGlowala
Comment options

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

This discussion was converted from issue #1052 on February 14, 2022 10:46.