Skip to content

Commit

Permalink
test: ref within computed types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Sep 26, 2024
1 parent dee897b commit 7a0e841
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/pinia/test-dts/storeToRefs.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {
expectType,
createPinia,
defineStore,
mapStores,
storeToRefs,
} from './'
import { App, computed, ComputedRef, ref, Ref, shallowRef } from 'vue'
import { expectType, defineStore, storeToRefs } from './'
import { computed, ComputedRef, ref, Ref, shallowRef } from 'vue'

const useOptionsStore = defineStore('main', {
state: () => ({
Expand Down Expand Up @@ -39,6 +33,9 @@ const useSetupStore = defineStore('main', () => {
n: 0,
ref: ref(0),
}),
// https://github.com/vuejs/pinia/issues/2658
accidentallyNestedComputed: computed(() => computed(() => 'a')),
computedRef: computed(() => ref(0)),
}
})

Expand All @@ -48,3 +45,5 @@ const setupRefs = storeToRefs(setupStore)
expectType<Ref<number>>(setupRefs.n)
expectType<Ref<{ n: number; ref: number }>>(setupRefs.ref)
expectType<Ref<{ n: number; ref: Ref<number> }>>(setupRefs.shallowRef)
expectType<ComputedRef<string>>(setupRefs.accidentallyNestedComputed.value)
expectType<Ref<number>>(setupRefs.computedRef.value)

0 comments on commit 7a0e841

Please sign in to comment.