diff --git a/packages/pinia/test-dts/customizations.test-d.ts b/packages/pinia/test-dts/customizations.test-d.ts index 34815e09e9..640ae466ad 100644 --- a/packages/pinia/test-dts/customizations.test-d.ts +++ b/packages/pinia/test-dts/customizations.test-d.ts @@ -215,6 +215,33 @@ expectType<{ ) ) +expectType<{ + n: Ref + customN: Ref & { plusOne: () => void } + double: ComputedRef + myState: Ref + stateOnly: Ref +}>( + storeToRefs( + defineStore('a', () => { + const n = ref(1) + const customN = ref(1) as Ref & { plusOne: () => void } + const double = computed(() => n.value * 2) + + function plusOne() { + customN.value++ + } + + return { + n, + customN, + double, + plusOne, + } + })() + ) +) + expectType<{ n: Ref customN: Ref & { plusOne: () => void } @@ -231,6 +258,36 @@ expectType<{ getters: { double: (state) => state.n * 2, }, + actions: { + plusOne() { + this.n++ + }, + }, + })() + ) +) + +expectType<{ + n: Ref + customN: Ref & { plusOne: () => void } + double: ComputedRef + myState: Ref + stateOnly: Ref +}>( + storeToRefs( + defineStore('a', { + state: () => ({ + n: 1, + customN: ref(1) as Ref & { plusOne: () => void }, + }), + getters: { + double: (state) => state.n * 2, + }, + actions: { + plusOne() { + this.n++ + }, + }, })() ) )