@@ -29,13 +29,17 @@ describe('mapHelpers', () => {
2929 const useSetupStore = defineStore ( 'setupStore' , ( ) => {
3030 const a = ref ( 'on' as 'on' | 'off' )
3131 const upper = computed ( ( ) => a . value . toUpperCase ( ) )
32+ const writableUpper = computed ( {
33+ get : ( ) => a . value . toUpperCase ( ) ,
34+ set : ( v : 'on' | 'off' ) => ( a . value = v ) ,
35+ } )
3236 function toggleA ( ) {
3337 a . value = a . value === 'off' ? 'on' : 'off'
3438 }
3539 function setToggle ( aVal : 'on' | 'off' ) {
3640 return ( a . value = aVal )
3741 }
38- return { a, upper, toggleA, setToggle }
42+ return { a, upper, writableUpper , toggleA, setToggle }
3943 } )
4044
4145 const useCounter = defineStore ( {
@@ -161,6 +165,17 @@ describe('mapHelpers', () => {
161165 set : ( v : 'on' | 'off' ) => any
162166 }
163167 } > ( mapWritableState ( useSetupStore , [ 'a' ] ) )
168+
169+ expectTypeOf < {
170+ a : {
171+ get : ( ) => 'on' | 'off'
172+ set : ( v : 'on' | 'off' ) => any
173+ }
174+ writableUpper : {
175+ get : ( ) => string
176+ set : ( v : 'on' | 'off' ) => any
177+ }
178+ } > ( mapWritableState ( useSetupStore , [ 'a' , 'writableUpper' ] ) )
164179 } )
165180 } )
166181} )
0 commit comments